[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: Style question: LOOP and multiple values

William James

8/7/2015 11:42:00 AM

Drew McDermott wrote:

> Plug for my 'repeat' macro:
>
> (defun foo (string)
> (repeat :for ((start = 0 :then pos) pos)
> :within
> (multiple-value-bind (object nextpos)
> (read-from-string string nil nil
> :start start)
> (:continue
> :while object
> :collect object
> (setq pos nextpos)))))

Gauche Scheme:

(define (foo string)
(with-input-from-string string
(cut generator-map identity read)))

(foo "2 3 4 5")
===>
(2 3 4 5)

--
An important part of the explanation is the role of mass media in Sweden. Not a
single TV-program, radio program, or big newspaper would give space to critics
of the multicultural project.
fjordman.blogspot.ca/2005/05/is-swedish-democracy-collapsing.html
1 Answer

William James

5/28/2016 2:05:00 AM

0

WJ wrote:

> Drew McDermott wrote:
>
> > Plug for my 'repeat' macro:
> >
> > (defun foo (string)
> > (repeat :for ((start = 0 :then pos) pos)
> > :within
> > (multiple-value-bind (object nextpos)
> > (read-from-string string nil nil
> > :start start)
> > (:continue
> > :while object
> > :collect object
> > (setq pos nextpos)))))
>
> Gauche Scheme:
>
> (define (foo string)
> (with-input-from-string string
> (cut generator-map identity read)))
>
> (foo "2 3 4 5")
> ===>
> (2 3 4 5)

OCaml:

#load "str.cma";;

" 2 3 4 5 "
|> Str.split (Str.regexp " +")
|> List.map int_of_string ;;

===>
[2; 3; 4; 5]

--
Europe is not going to be the monolithic societies that they once were in the
last century.... They are now going into a multicultural mode. Jews will be
resented because of our leading role. --- Barbara Spectre
archive.org/download/DavidDuke_videos/HowZionistsDivideAndConquer-fjjszxkm55o.ogv