WJ wrote:
> Pascal Bourguignon wrote:
>
> > > just a quick question. Let's say I have a list of numbers and a
> > > variable bounded to another number. Is it possible to compare each
> > > number of the list with the variable using anonymous functions instead
> > > of loops, etc...also can it be done with letters too?
> >
> > Your specifications are rather imprecise. Do you mean this:
> >
> > (let ((a-list-of-numbers '(1 37 42 442 1024))
> > (a-variable-bounded-to-another-number 42))
> > (mapcar (lambda (a-number)
> > (cond ((= a-number a-variable-bounded-to-another-number) '=)
> > ((< a-number a-variable-bounded-to-another-number) '<)
> > (t '>))) a-list-of-numbers))
> > --> (< < = > >)
MatzLisp (Ruby):
list = 1, 37, 42, 442, 1024
var = 42
list.map{|n| [:"=", :>, :<][n <=> var]}
==>[:<, :<, :"=", :>, :>]
--
Let us be brought to believe it is ... favorable to ... our interest to
transfer the African to his native clime, and we shall find a way to do it,
however great the task may be. --- A. Lincoln, Sept. 22, 1856