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

Pages: 1-

The Great Debate

Name: Anonymous 2012-10-24 2:45

(define (f x)
  ...)


or

(define f (lambda (x)
  ...)

Name: Anonymous 2012-10-24 2:46

both

/thread

Name: Anonymous 2012-10-24 2:51

DEFMACRO *SHOVES LEGO BLOCKS UP MY NOSE*

Name: The Greate Masterbate 2012-10-24 2:58


function f(x) {
    ...
}

or

var f = function(x) {
    ...
}

Name: Anonymous 2012-10-24 3:00

Scheme's syntactic sugar for function definitions is quite brilliant because not only does the function definition match the function call (i.e. (define (f x) ...) => (f x) in Scheme vs. (defun f (x) ..) => (f x) in Common Lisp), but if implemented correctly if can be layered to create simplified higher-order functions.

]=> (define ((make-adder x) y)
      (+ x y))
make-adder
]=> (define add-3 (make-adder 3))
add-3
]=> (add-3 4)
7

Name: Anonymous 2012-10-24 5:00

>>5
Nice idea. I should ass something like (makeAdder X) Y = X+Y to Symta.

Name: Anonymous 2012-10-24 5:00

>>6
I should add
self fix.

Name: Anonymous 2012-10-24 5:16

>>5
babby's first currying

Name: Anonymous 2012-10-24 6:22

>>6
What's cool is that it's not even an idea really, it's just a side-effect.

All that needs to implemented is (define var val). Then have a macro that expands (define (func . args) body) to (define func (lambda args body)). Then the following expansion is automatic:

(define (((f x) y) z) ...)
(define ((f x) y) (lambda (z) ...))
(define (f x) (lambda (y) (lambda (z) ...)))
(define f (lambda (x) (lambda (y) (lambda (z) ...))))


Some implementations like chibi-scheme however evaluate function definitions differently than variable definitions, so it doesn't work.

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