[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: Loop is cool

William James

3/6/2016 2:41:00 AM

> The task is to take a single string with embedded newlines and chop it
> up into a list of strings without newlines, and here is what I came up
> with:
>
> (setq *log* "1234
> 5678
> 90")
>
> (loop with log = *log*
> for start = 0 then (1+ index)
> for index = (position #\Newline log :start start)
> collect (subseq log start index)
> while index)
>
> ;=> ("1234" "5678" "90")

SML:

String.tokens (Char.contains "\r\n") "a\r\nb\n\nc\n\n\n";
===>
["a", "b", "c"]

--
[W]e had enough employees who made more than 85 to fill all the openings. The
highest score that any of the blacks scored on the test was 11. The lowest
score that any black made on the test was 4. All four of those blacks went
into skilled-trades training.
https://archive.org/download/TheOldmanArchives/oldman29-...