Talk:Scheme (programming language): Difference between revisions

Content deleted Content added
Sokleidas (talk | contribs)
Sokleidas (talk | contribs)
Line 134:
==> ((1 0) (1 0) (2 1) (2 2) (3 2) (3 3) (4 4) (5 4) (5 5))
</syntaxhighlight>
 
[[User:Sokleidas|Sokleidas]] ([[User talk:Sokleidas|talk]]) 21:53, 7 November 2012 (UTC)
It is of course a matter of taste an style, but functional parts of a program should be separated from imperative parts (cf. e. g. Conrad Barski, Land of Lisp, San Francisco 2011, p. 302). Displaying the results could be done with <code>for-each</code>, which according to R5RS is explicitly to be called because of its side-effects:
 
<syntaxhighlight lang="Scheme">
(for-each (lambda (item)
(begin
(display (car item))
(display " ")
(display (cdr item))
(display "\n")))
(hofstaedter-male-female 8))
 
===> #<unspecified>
 
1 0
1 0
2 1
2 2
3 2
3 3
4 4
5 4
5 5
</syntaxhighlight>
[[User:Sokleidas|Sokleidas]] ([[User talk:Sokleidas|talk]]) 2122:5328, 7 November 2012 (UTC)