0

In one case of my cond, I need to do multiple procedures then return a value at the end. However, my current implementation gives me an error:

application: not a procedure; expected a procedure that can be applied to arguments

(cond
    [(string? expr) expr]
    [(number? expr) expr]
    [(list? expr) (begin 
        (hash-set! my-table (car expr) (cdr expr))
        ("hi")  ; I want to return this
    )
    ]
)

Can anybody help me understand how I'd have multiple lines in a cond?

MarksCode
  • 8,074
  • 15
  • 64
  • 133
  • Possible duplicate of [My code signals the error "application: not a procedure" or "call to non procedure"](https://stackoverflow.com/questions/48064955/my-code-signals-the-error-application-not-a-procedure-or-call-to-non-procedu). Look at the "wrapping variables" part though you are wrapping literals. – Sylwester Jan 24 '18 at 20:51

1 Answers1

2

It's not multiple lines in the cond that's your problem, it's the ("hi"). You're trying to call "hi" as a procedure by putting it in the parens and "hi" is a string, not a procedure.

In fact, you don't need the (begin ...) form to have multiple lines in there. Just put the lines you want after the test.

DBridgham
  • 136
  • 4