stackerizer-mb macro flatten arity mismatch #5

Closed
opened 7 years ago by jpeinelt · 3 comments
jpeinelt commented 7 years ago (Migrated from github.com)

In the middle of the page (http://beautifulracket.com/stackerizer/the-expander.html) where the input gets flatten the shown code:

(define-macro (stackerizer-mb EXPR ...)
  #'(#%module-begin
     (for-each displayln (reverse (flatten EXPR ...)))))

fails with

flatten: arity mismatch;
 the expected number of arguments does not match the given number
  expected: 1
  given: 5
  arguments...:

the code should be

(define-macro (stackerizer-mb EXPR ...)
  #'(#%module-begin
     (for-each displayln (reverse (flatten EXPR))) ...))
In the middle of the page (http://beautifulracket.com/stackerizer/the-expander.html) where the input gets flatten the shown code: ``` (define-macro (stackerizer-mb EXPR ...) #'(#%module-begin (for-each displayln (reverse (flatten EXPR ...))))) ``` fails with ``` flatten: arity mismatch; the expected number of arguments does not match the given number expected: 1 given: 5 arguments...: ``` the code should be ``` (define-macro (stackerizer-mb EXPR ...) #'(#%module-begin (for-each displayln (reverse (flatten EXPR))) ...)) ```
mbutterick commented 7 years ago (Migrated from github.com)

What is the specific input that’s causing the arity-mismatch error?

What is the specific input that’s causing the arity-mismatch error?
zenspider commented 7 years ago (Migrated from github.com)

@mbutterick any input file with more than one expression. I had to do this same fix but I did mine slightly different:

(define-macro (stackerizer-mb EXPR ...)
  #'(#%module-begin
     (begin (printf ";; ~a~n" EXPR)
            (for-each displayln (reverse (flatten EXPR)))
            (newline)) ...))

(this also made the output more readable for me)

Here's my repro:

#lang s-exp "stackerizer.rkt"
(+ 5 4 3 2 1)
(+ 1 (+ 2 (+ 3 (+ 4 5))))
(* 1 2 (+ 3 4 (* 5 6 (+ 7 8 (* 9 10)))))
@mbutterick any input file with more than one expression. I had to do this same fix but I did mine slightly different: ``` (define-macro (stackerizer-mb EXPR ...) #'(#%module-begin (begin (printf ";; ~a~n" EXPR) (for-each displayln (reverse (flatten EXPR))) (newline)) ...)) ``` (this also made the output more readable for me) Here's my repro: ``` #lang s-exp "stackerizer.rkt" (+ 5 4 3 2 1) (+ 1 (+ 2 (+ 3 (+ 4 5)))) (* 1 2 (+ 3 4 (* 5 6 (+ 7 8 (* 9 10))))) ```
mbutterick commented 7 years ago (Migrated from github.com)

I see your point, but stackerizer makes a program for stacker, which in turn represents a single expression. Therefore, it only makes sense that stackerizer be restricted to one expression. I will adjust the tutorial to make this ground rule clearer.

I see your point, but `stackerizer` makes a program for `stacker`, which in turn represents a single expression. Therefore, it only makes sense that `stackerizer` be restricted to one expression. I will adjust the tutorial to make this ground rule clearer.
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/beautiful-racket#5
Loading…
There is no content yet.