| [reply] |
Forgive the duff syntax, been busy and I can't find an example, I'd have thought the lecture notes would be available online somewhere.., and I can't recall all the details precisely.
sub divide( $x, $y ) {
$x / $y
}
sub half assuming divide( $y=2 )
Uh does that look familiar to anyone?
--
Brother Frankus.
| [reply] [d/l] |
Probably more like:
my &half := ÷.assuming( $y => 2 )
But that's the general idea.
Larry
| [reply] [d/l] |
It's just currying. The syntax is unique to perl, but the semantics are reasonably common in functional programming languages. The 'new' thing about perl 6's 'assuming' operator is that, according to Damian, it doesn't actually create a new function, but that's not really going to be user visible.
| [reply] |
# let divide ~x ~y = x / y;;
val divide : x:int -> y:int -> int = <fun>
# let half = divide ~y:2;;
val half : x:int -> int = <fun>
# half 120;;
- : int = 60
| [reply] [d/l] |
The mutant offspring of COBOL and ML? You want me to be *familiar* with something like that?!
| [reply] |
| [reply] [d/l] [select] |