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-30 9:44

>>19
I have no idea what (3) is, but I'm a newbie. I thought the [ | ] syntax was for lists, was in [a + b | (a, b) <- zip fib (tail fib)]

I realized however that your flip flip approach is basically a hidden permutation of three arguments, namely the permutation (1 2). (which 'flip's the first and second argument).
If you don't know what I'm talking about see this http://en.wikipedia.org/wiki/Cyclic_permutation

Would it be possible to write a generalized flip, as in,

Suppose f is of type a -> b -> c -> d
Then genflip would,
genflip (1, 2) 3 f -- evaluates to a function of type
-- b -> a -> c -> d
-- note the second argument to genflip is the number of arguments for f


Though that's probably nonsense and can't be done.

You can however do this in common lisp with a macro. I'm not sure if it can be done for lists coming from other sources (i.e. input).

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