Recently I have been reading Maturana & Varela's ideas on the living. I buy what they say: everyday a living thing works hard at staying alive. In our case most of it is automatic, below awareness, whatever you want to call it, but it is there.
Talking to a computer is no different, our conscious acts get mingled with the parts in the basement of consciousness, and it gets hairy.
If any reader knows Scheme, you may sympathize with me, here it goes:
;; pass in an unspecified number of args
(define sum
(lambda (x . y) ; the dot precedes a list
(apply + x y))) ;(apply proc arg1 ... args)
(sum 2 2 2 2)
8
I have:
MIT/GNU Scheme running under GNU/Linux
Type `^C' (control-C) followed by `H' to obtain information about interrupts.
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2008 Massachusetts Institute of Technology
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Image saved on Thursday March 12, 2009 at 4:17:10 AM
Release 7.7.90.+ || Microcode 15.1 || Runtime 15.7 || SF 4.41
LIAR/i386 4.118 || Edwin 3.116
I did not get 8, I get this error message:
;The procedure #[compound-procedure 11 sum] has been called with 4 arguments; it requires exactly 1 argument.
;To continue, call RESTART with an option number:
; (RESTART 1) => Return to read-eval-print level 1.
Later, now is 10.14 PM
The problem was syntactic:
(define sum
(lambda (x . y)
(apply + x y)))
(sum 2 2 2 2)
8
I had written before x.y, and xy. Now I used x . y , and x y
This works. xy was taken as a new variable, also x.y was not interpreted correctly before.
From On Lisp by Paul Graham
Lisp is a programmable programming language.
No comments:
Post a Comment