[racket-dev] Please help me to fix the code
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Yingjian,
On 05/31/11 01:17, Yingjian Ma wrote:
> Hi All,
>
> I wrote a piece of code to count the occurrance of a letter in a list. But
> it gave me an error saying "#<procedure:...uments..."
What makes you think it's an error?
> The code is below:
>
> (define (count-matches s l)
> (cond
> [(empty? l) 0]
> [(equal? s (first l)) (lambda (i)(+ i 1))]
> [else (count-matches s (rest l))]))
Part of this code reads:
compare s to the first element of list l and if they are equal return a
function that returns its argument plus one (and forget about the rest
of the list).
Marijn
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk3koL8ACgkQp/VmCx0OL2ztFwCfUG1WrfbagBXTp7F9prAvvaL8
sycAoJWBleSTJ/eE2CExwx1zt71Z1Lks
=e+cf
-----END PGP SIGNATURE-----