[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: A multiple valued position?

William James

5/10/2015 9:47:00 AM

Kent M. Pitman wrote:

> Mostly for your case, you'll find that
> (loop for index from 0
> for n in seq ; assumes seq is a list
> for primary = (if (numberp n) (sqrt n))
> when primary
> return (values index primary))
> will suffice to do the simple thing in the rare case it's needed, so it's

Gauche Scheme:

(any
(^(x i) (and (number? x) (values i (sqrt x))))
'(a b c 8 9)
(lrange 0))

===>
3
2.8284271247461903

--
Sweden is already a banana republic, perhaps on its way to becoming an Islamic
republic. Swedish culture is disappearing with astonishing speed in front of
our eyes. If the trend isn't stopped, the Swedish nation will simply cease to
exist in any meaningful way during the first half of this century. ---
fjordman.blogspot.ca/2005/05/is-swedish-democracy-collapsing.html
1 Answer

William James

1/15/2016 9:20:00 AM

0

WJ wrote:

> Kent M. Pitman wrote:
>
> > Mostly for your case, you'll find that
> > (loop for index from 0
> > for n in seq ; assumes seq is a list
> > for primary = (if (numberp n) (sqrt n))
> > when primary
> > return (values index primary))
> > will suffice to do the simple thing in the rare case it's needed, so it's
>
> Gauche Scheme:
>
> (any
> (^(x i) (and (number? x) (values i (sqrt x))))
> '(a b c 8 9)
> (lrange 0))
>
> ===>
> 3
> 2.8284271247461903

MatzLisp (Ruby):

n,i = [:a,:b,:c,8,9].each_with_index.find{|x,i| x.is_a? Numeric}
n and [i, Math.sqrt(n)]
===>
[3, 2.8284271247461903]

--
Elie [Wiesel] thus could have remained at Birkenau to await the Russians.
Although his father had permission to stay with him as a hospital patient or
orderly, father and son talked it over and decided to move out with the
Germans. --- Robert Faurisson