Skip to content

Instantly share code, notes, and snippets.

@vkgtaro
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save vkgtaro/bc54a012fd2f51b40541 to your computer and use it in GitHub Desktop.

Select an option

Save vkgtaro/bc54a012fd2f51b40541 to your computer and use it in GitHub Desktop.
curried
package main
import "fmt"
func div (x float32) func(float32) float32 {
return func(y float32) float32 { return x / y }
}
func main () {
inv := div(5.0)
fmt.Println(inv(10.0))
}
use strict;
use warnings;
# http://ja.wikipedia.org/wiki/%E3%82%AB%E3%83%AA%E3%83%BC%E5%8C%96
sub div {
my $x = shift;
return sub {
my $y = shift;
return $x / $y;
};
}
my $inv = div(5);
print $inv->(10);
def div (x):
def func (y):
return x / y
return func
inv = div(5.0)
print inv(10.0)
def div(x)
return lambda{|y| x / y }
end
inv = div(5.0)
puts inv.call(10.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment