[ prog / sol / mona ]

prog


Help on the Way

5 2022-04-07 19:39

>>4
Because COND works a bit differently (it is one of the special forms): https://api.call-cc.org/5/doc/scheme/cond or https://schemers.org/Documents/Standards/R5RS/

You need to do it like this:

#!/usr/bin/guile -s
!#
;coding: utf-8
;; those 3 lines above are Guile specific stuff:
;; https://www.gnu.org/software/guile/manual/html_node/The-Top-of-a-Script-File.html


; (you can replace the square brackets with regular parenthesis)
(define (fizzbuzz n)
	(cond
		[(zero? (remainder n 5)) 'buzz]
		[(zero? (remainder n 3)) 'fizz]
		[else n]))

(map fizzbuzz '(1 2 3 4 5 6 7 8 9 10))

More about special forms (in general): https://www.cs.utexas.edu/ftp/garbage/cs345/schintro-v14/schintro_17.html

103


VIP:

do not edit these