Minor code correction in the Quick Start docs #21

Closed
opened 5 years ago by thelonious · 2 comments
thelonious commented 5 years ago (Migrated from github.com)

I tried using the following code from the Quick Start section in the docs:

(define (tokenize s)
  (for/list ([str (regexp-match* #px"\\(\|\\)\|\\w+" s)])
    (match str
      ["("
       (token 'LEFT-PAREN str)]
      [")"
       (token 'RIGHT-PAREN str)]
      [else
       (token 'WORD str)])))

Racket complained about the use of else in the last clause. I was able to change that to _ and then it worked fine.

I tried using the following code from the Quick Start section in the docs: ```scheme (define (tokenize s) (for/list ([str (regexp-match* #px"\\(\|\\)\|\\w+" s)]) (match str ["(" (token 'LEFT-PAREN str)] [")" (token 'RIGHT-PAREN str)] [else (token 'WORD str)]))) ``` Racket complained about the use of `else` in the last clause. I was able to change that to `_` and then it worked fine.
mbutterick commented 5 years ago (Migrated from github.com)

Strange. What version of Racket? else is a little misleading in the context of match, but it should work the same way as _.

Strange. What version of Racket? `else` is a little misleading in the context of `match`, but it should work the same way as `_`.
thelonious commented 5 years ago (Migrated from github.com)

Hmm, seems to be fine now. It must have been a copy/paste error on my part. My apologies.

Hmm, seems to be fine now. It must have been a copy/paste error on my part. My apologies.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/brag#21
Loading…
There is no content yet.