0
votes
(define (most-common-word str)
  (let (wordslist str-split str " ")))

I am trying to do a inner variable of lists of strings. but I get the error "bad syntax".

I looked for answers here but the things I changed, didn't help.

str-split returns a list of strings with " " the separator.

thanks.

1
I still don't understandshay C
you have missing parens there.Will Ness
Possible duplicate of How does `let` work in Scheme?Leif Andersen

1 Answers

3
votes

It should look like:

(let ([word-list <VALUE>]) <BODY>)

... which establishes a local binding from word-list to the value <VALUE>. This binding is effective only inside the <BODY> form enclosed by the let.

Now, in order to compute <VALUE>, you have to call str-split with the arguments you want (i.e. str and " "). The way you perform a function call is to wrap it in parenthesis (this is valid only in a context where the form is evaluated as an expression, not where parenthesis mean binding, for example). So <VALUE> should really be:

(str-split str " ")