[fluxus] schemantics

nik gaffney nik at fo.am
Mon Jan 9 04:41:00 PST 2006


>> out of curiosity, is there some reason for all the anonymous functions in
>> the importer?
> 
> you mean the explicit use of lambda in the function definitions? I've just
> been learning how to write scheme properly lately :) I'm actually totally
> addicted now.

now your hooked, here is another dose,, . .

anonymous functions [ie. defined using lambdas] dont really give you much
advantage when used in standard function definitions.

(define (foo x) (do-stuff x)) vs. (define foo (lambda (x) (do-stuff x)))

where they are really useful, is where you return a function based on the input,
rather than the more common situations of returning a value, or relying on side
effects (eg. build-cube).

one of the most common uses for lambdas are in mapping functions, for example
returning a new function, which operates on lists of values, rather than a
single value (.. . some of you might remember this form the workshop)

say you had a function like so..

(define (glib x)
 (grab x)
 (pdata-slink)
 (ungrab))

you could define glib-list, which would do the same thing to a list of objects
as follows. ..

(define (glib-list objs)
  (map (lambda (x)
	 (grab x)
	 (pdata-slink)
	 (ungrab))
       objs))

or you could define a function, which 'converts' other functions to operate on
list.. .

(define (glob f1)
  (lambda (liszt)
    (map (lambda x)
      (f1 x)
     liszt)))

then glib-list can be defined like so..

(define glib-list (glob glib))

all of which should give you enough of a fix for the moment ;)







More information about the Fluxus mailing list