Python syntax in Lisp and Scheme
james anderson
james.anderson at setf.de
Tue Oct 7 19:27:41 EDT 2003
Eli Barzilay wrote:
>
> ...
>
> > > Yes, but I was talking about the difference approaches, for
> > > example:
> > >
> > > (dolist (x foo)
> > > (bar x))
> > >
> > > vs:
> > >
> > > (mapc #'bar foo)
> >
> > are these not two examples of coding in common-lisp. how do they
> > demonstrate that "scheme is much more functional"?
>
> The first is very popular, the second is hardly known.
somehow i wonder if we're discussing the same language.
> R5RS has
> `for-each' which is exactly like `mapc', but no `dolist' equivalent.
> In Scheme, this is not a problem, in Lisp, the syntax makes me worry
> for the extra effort in creating a closure.
>
what me worry? about syntax?
? (defmacro Barzilay (type operator &rest lists)
`(map ',type (function ,operator) , at lists))
BARZILAY
? (BARZILAY vector evenp '(1 2 3 4))
#(NIL T NIL T)
? (defmacro Barzilac (operator &rest lists)
`(mapc (function ,operator) , at lists))
BARZILAC
? (Barzilac (lambda (x) (print x)) '(1 2 3 4))
1
2
3
4
(1 2 3 4)
? (defmacro Barzilar (operator &rest lists)
`(mapcar (function ,operator) , at lists))
BARZILAR
? (Barzilar + '(1 2 3 4) '(5 6 7 8))
(6 8 10 12)
?
...
More information about the Python-list
mailing list