Last active
August 29, 2015 14:08
-
-
Save vkgtaro/bc54a012fd2f51b40541 to your computer and use it in GitHub Desktop.
curried
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def div (x): | |
| def func (y): | |
| return x / y | |
| return func | |
| inv = div(5.0) | |
| print inv(10.0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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