Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Isn't that nice?

by John M. Dlugosz (Monsignor)
on Aug 30, 2002 at 13:57 UTC ( #194110=note: print w/ replies, xml ) Need Help??


in reply to Isn't that nice?

enhancements that are entirely new to any language: dedicated applications of functions by making a parameter constant,

What's that?

—John


Comment on Re: Isn't that nice?
Re: Re: Isn't that nice?
by jepri (Parson) on Aug 30, 2002 at 14:37 UTC
    I'm not sure, but maybe prebinding parameters?

    ____________________
    Jeremy
    I didn't believe in evil until I dated it.

      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.

        The mutant offspring of COBOL and ML? You want me to be *familiar* with something like that?!

        Yes, it looks a little bit like OCaml (i.e. I'm not sure this has never been seen in any other language). :-)

        # 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

        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.
        Is that really going to be in Perl 6 like that?

        How is that an improvement over sub half { divide($_[0]/2) }; ? Especially when you consider that to write sub half assuming... as shown you have (apparently) to know that divide has a $y to which to assign 2.

        Probably more like:
        my &half := &divide.assuming( $y => 2 )
        But that's the general idea.

        Larry

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://194110]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2014-12-25 00:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls