4 ms·
Huh interesting. And I've never seen someone make curryable functions in lisp, though I'm not surprised you can lol.
by runevault 4y ago
Huh interesting. And I've never seen someone make curryable functions in lisp, though I'm not surprised you can lol.
- taeric 4y agoFor machine learning, it makes a lot of sense. Effectively, training is a function that returns a function, after all.
- runevault 4y agoOh yeah not disagreeing with that, just interesting because I'd never seen anyone rig up curried functions in scheme/lisp before as it obviously isn't default behavior in a traditional lisp. I'm assuming using some sort of wrapper function or macro.
- taeric 4y agohttps://mitpress.ublish.com/ebook/the-little-learner-a-straight-line-to-deep-learning-preview/12735/C1 https://mitpress.ublish.com/ebook/the-little-learner-a-strai... has the first two chapters. The forward plants the seed for the fact that it will be currying. When the chapters start, they don't use the term and just show functions returning functions. Immediately.
- kazinator 4y agoThe examples look like normal Scheme to me. There is nothing odd going on with custom macros. They have broken some argument lists into currying, that's all. (define line (lambda (x) (lambda (w b) (+ (* w x) b)))) Firstly, it's not full currying; the w and b parameters are not separated from each other into different lambdas. These kinds of nested lambdas are not unheard of in Lisp and Scheme programming. Lisps do not have automatic partial application. If you have a (f x y z) function, you cannot just call it (f 42) to partially apply it, to obtain a function which takes the y and z arguments. You have to do a clumsy thing with an explicit lambda like this: (lambda (y z) (f 42 y z)). There are macros for that, which can make it look like (op f 42) or what have you. If you need partial application regularly over some functions, it may behave you to write the function in the curried style. Passing all the parameters becomes a bit less convenient: ((line 1) 2 3) ;; versus just (line 1 2 3) but the partial application you want is a lot less verbose: (line 1) ;; versus (lambda (w b) (line 1 w b)). So basically it looks like the authors may be after low-verbosity partial application without macro assistance.
- runevault 4y agoAh ha, yeah having a pre set one or two step currying setup is a lot easier sure. Just return a lambda that captures the value passed in from the first one.