revision 1 of the 9.1 manual corrects some typos
Lutz
revision 1 of Manual and Reference 9.1
'bind' is in the code since 9.0 and not documented because I am not sure if it will stay. It binds all associations in a list of binary associations.
The functions 'bind', 'expand', and 'unify' constitute a family of logic programming functions, which I am experimenting with. Don't count on having 'bind' in future versions.
Lutz
Code: Select all
(bind '((x 1) (y 2))) => 2
x => 1
y => 2
Lutz
-
- Posts: 429
- Joined: Tue Nov 11, 2003 2:11 am
- Location: Brisbane, Australia
Yes, or like this (*):
or shorter faster:
the built-in 'bind' is still much faster (~ 10x)
Lutz
(*) when all args of a 'define-macro' are evaluated anyway, a simple 'define' will do the same faster
Code: Select all
(define (mybind L) (dolist (i L) (apply set i)))
Code: Select all
(define (mybind L) (apply set (flat L)))
Lutz
(*) when all args of a 'define-macro' are evaluated anyway, a simple 'define' will do the same faster
-
- Posts: 429
- Joined: Tue Nov 11, 2003 2:11 am
- Location: Brisbane, Australia
my-bind macro can bind lists whereas using flatten can't
viz
> (define-macro (my-bind _x) (dolist (z (eval _x)) (apply set z)))
(lambda-macro (_x)
(dolist (z (eval _x))
(apply set z)))
> (my-bind '((x (+ 2 3))(y 7)))
7
> x
(+ 2 3)
> (bind '((x (+ 2 3))(y 7)))
7
> x
(+ 2 3)
> (define (mybind L) (apply set (flat L)))
(lambda (L) (apply set (flat L)))
> (mybind '((x (+ 2 3))(y 7)))
symbol expected in function set : 2
called from user defined function mybind
>
NIgel
viz
> (define-macro (my-bind _x) (dolist (z (eval _x)) (apply set z)))
(lambda-macro (_x)
(dolist (z (eval _x))
(apply set z)))
> (my-bind '((x (+ 2 3))(y 7)))
7
> x
(+ 2 3)
> (bind '((x (+ 2 3))(y 7)))
7
> x
(+ 2 3)
> (define (mybind L) (apply set (flat L)))
(lambda (L) (apply set (flat L)))
> (mybind '((x (+ 2 3))(y 7)))
symbol expected in function set : 2
called from user defined function mybind
>
NIgel