#!/usr/bin/ruby

#
## http://rosettacode.org/wiki/Partial_function_application
#

func fs(f) {
    func(*args) {
        args.map {f(_)}
    }
}

func double(n) { n  * 2 };
func square(n) { n ** 2 };

var fs_double = fs(double);
var fs_square = fs(square);

var s = (0 .. 3);
say "fs_double(#{s}): #{fs_double(s...)}";
say "fs_square(#{s}): #{fs_square(s...)}";

s = [2, 4, 6, 8];
say "fs_double(#{s}): #{fs_double(s...)}";
say "fs_square(#{s}): #{fs_square(s...)}";
