Re: Python syntax in Lisp and Scheme
In article <y8vnhkcy.fsf@c cs.neu.edu>, Joe Marshall <jrm@ccs.neu.ed u>
wrote:
[color=blue]
> The problem with this is that you've essentially outlawed MAP.
>
> (map 'list (make-adder offset) some-list)
>
> The problem with this is that MAKE-ADDER is no less a lambda in drag,
> and it isn't even local.[/color]
I think you misunderstand me. I haven't outlawed map. I've simply asked
that it be used in a _named_ function or macro that expresses _what_ is
being done, not _how_. For example:
(defgeneric add-offset (some-sequence some-offset))
(defmethod add-offset ((some-list list) some-offset)
(map 'list #'(lambda (x) (+ x some-offset)) some-list))
(defmethod add-offset ((some-vector vector) some-offset)
(map 'vector #'(lambda (x) (+ x some-offset)) some-vector))
And the client code looks like your example:
(add-offset my-list current-offset) or
(add-offset my-vector vector-offset) etc.
Also see my reply to Thant Tessman entitled "Express What, not How."
In article <y8vnhkcy.fsf@c cs.neu.edu>, Joe Marshall <jrm@ccs.neu.ed u>
wrote:
[color=blue]
> The problem with this is that you've essentially outlawed MAP.
>
> (map 'list (make-adder offset) some-list)
>
> The problem with this is that MAKE-ADDER is no less a lambda in drag,
> and it isn't even local.[/color]
I think you misunderstand me. I haven't outlawed map. I've simply asked
that it be used in a _named_ function or macro that expresses _what_ is
being done, not _how_. For example:
(defgeneric add-offset (some-sequence some-offset))
(defmethod add-offset ((some-list list) some-offset)
(map 'list #'(lambda (x) (+ x some-offset)) some-list))
(defmethod add-offset ((some-vector vector) some-offset)
(map 'vector #'(lambda (x) (+ x some-offset)) some-vector))
And the client code looks like your example:
(add-offset my-list current-offset) or
(add-offset my-vector vector-offset) etc.
Also see my reply to Thant Tessman entitled "Express What, not How."
Comment