[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
newlispfanclub.alh.net • View topic - (newbie) Listiness
Page 1 of 1

(newbie) Listiness

PostPosted: Sat Oct 25, 2014 6:40 am
by mark5009

Re: (newbie) Listiness

PostPosted: Sat Oct 25, 2014 12:15 pm
by bairui
Hi, Mark,

The dolist iterates the list one element at a time. Because you're not printing in that loop, the interpreter is silently throwing away each internal result. Finally the result of the whole loop (its final evaluation) is shown by the interpreter, which is (() 5), as you would expect.

For your stated goal of (() 1 2 3 4 5) you could merely do (cons bar foo)

-- bairui

Re: (newbie) Listiness

PostPosted: Sun Oct 26, 2014 1:57 am
by mark5009

Re: (newbie) Listiness

PostPosted: Sun Oct 26, 2014 3:53 am
by saulgoode
I'm sure there are Newlispers here who will be able to provide a much better solution (probably with just a single function), but nonetheless perhaps some of the following might spawn some ideas for you.

-----------------
> (set 'in-string (read-file "tmp/foo.tmp"))
"# stuff to ignore\n123:avc\n234:vvc\n# more to ignore and the following blank line as well\n\n# and there is the last stuff\n999:xxc\n"

> (set 'all-lines (parse in-string "\n"))
("# stuff to ignore" "123:avc" "234:vvc" "# more to ignore and the following blank line as well"
"" "# and there is the last stuff" "999:xxc" "")

> (set 'non-empty-lines (clean = all-lines)) ; monadic = compares to empty string
("# stuff to ignore" "123:avc" "234:vvc" "# more to ignore and the following blank line as well"
"# and there is the last stuff" "999:xxc")

> (define (comment? s) (starts-with s "#"))
> (set 'lines (clean comment? non-empty-lines))
("123:avc" "234:vvc" "999:xxc")

> (define (split-at-colons s) (parse s ":"))
> (set 'contents (map split-at-colons lines))
(("123" "avc") ("234" "vvc") ("999" "xxc"))

Re: (newbie) Listiness

PostPosted: Sun Oct 26, 2014 5:48 am
by ralph.ronnquist

Re: (newbie) Listiness

PostPosted: Sun Oct 26, 2014 11:09 pm
by mark5009
Thanks, guys! That is most helpful.

.. mark.

Re: (newbie) Listiness

PostPosted: Mon Oct 27, 2014 10:23 pm
by tomtoo