Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^5: If I was forced to use only one kind of loop for the rest of my days it would be a

by ambrus (Abbot)
on Sep 30, 2005 at 15:59 UTC ( [id://496454]=note: print w/replies, xml ) Need Help??


in reply to Re^4: If I was forced to use only one kind of loop for the rest of my days it would be a
in thread If I was forced to use only one kind of loop for the rest of my days it would be a

Please read what I said in the parent node.

That's not a proper list, so r5rs doesn't guarantee this will work. It does work with some scheme implementations, but MzScheme says

for-each: expects type <proper list> as 2nd argument, given: #0=(1 . # +0#); other arguments were: #<procedure:STDIN::59>
if I type this code in it.

Update: let me quote from the r5rs.

Pairs are used primarily to represent lists. A list can be defined recursively as either the empty list or a pair whose cdr is a list. More precisely, the set of lists is defined as the smallest set X such that

  • The empty list is in X.
  • If LIST is in X, then any pair whose cdr field contains LIST is also in X.
and later
library procedure: map proc list1 list2 ...,
The LISTs must be lists, and PROC must be a procedure taking as many arguments as there are lists and returning a single value. If more than one LIST is given, then they must all be the same length. `Map' applies PROC element-wise to the elements of the LISTs and returns a list of the results, in order. The dynamic order in which PROC is applied to the elements of the LISTs is unspecified.
library procedure: for-each proc list1 list2 ...,
The arguments to `for-each' are like the arguments to `map', but `for-each' calls PROC for its side effects rather than for its values. Unlike `map', `for-each' is guaranteed to call PROC on the elements of the LISTs in order from the first element(s) to the last, and the value returned by `for-each' is unspecified.
  • Comment on Re^5: If I was forced to use only one kind of loop for the rest of my days it would be a
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://496454]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2025-05-17 02:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.