Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Partial application of arguments

Name: Anonymous 2013-07-29 16:52

I am trying to figure this out in C++, Haskell and Common Lisp, for anyone who cares. How'd you write a macro that does the following:


(foo (f _ y _))
==> (lambda (x z) (f x y z))


Same thing for Haskell, can it be done? What's the proper way to do this? What of C++?

Name: Anonymous 2013-07-29 23:02

You might be able to engineer something in C++ using templates, but it will be really ugly looking and will only work for the arities you define.

Here's a way in scheme that works well.


(define (curry f . args)
  (lambda args2
    (apply f (append args args2))))

((curry + 11 22) 33) ==> 66


Implicit currying is nice, but breaks varadic arguments.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List