Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.lisp
Re: (funcall #'or my-list
William James
12/28/2015 10:39:00 PM
Rob St. Amant wrote:
> I've lately found a use for a function that calls a predicate on each
> element of a list and returns all non-null results. (I bring this up
> here because it has a SOME-like flavor).
>
> (defun all-such-that (predicate list &key key)
> "Return non-nil PREDICATE results for elements in LIST."
> (loop for elt in list
> as value = (if key
> (funcall predicate (funcall key elt))
> (funcall predicate elt))
> when value
> collect value))
MatzLisp (Ruby):
def filter_map array
result = []
array.each{|elt| val=yield(elt); result << val if val}
result
end
filter_map([2,3,4,5]){|n| n.odd? && n*n}
==>[9, 25]
--
Amazon bans book. After nearly a month on the site, all traces of the book and
its 80 reviews have been removed.
http://jamesfetzer.blogspot.com/2015/11/debunking-sandy-hook-debunk...
https://www.youtube.com/watch?v=E...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: (funcall #'or my-list
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password