Re: [racket-users] Macro help

2019-05-23 Thread Michael Murdock MacLeod
Does this work? It uses a helper function, `prune`, to parse the var-val clauses. #lang racket (define-for-syntax (prune stx) (syntax-case stx () [() #'()] [((var val) others ...) (cons #'(var val) (prune #'(others ...)))] [(var others ...) (cons #'(var

Re: [racket-users] question about matching with "(? ...)"

2019-04-21 Thread Michael Murdock MacLeod
Match treats `empty` as an identifier to bind, not as a pattern for the empty list. This means that the first case will always be matched. You can use `(list)` or `'()` to match an empty list. Also, in the last catch-all case, you pass the function `rest` which returns the tail of a list to

Re: [racket-users] catch and bind an unbound id in a macro

2019-04-19 Thread Michael Murdock MacLeod
I'm in no ways a macro expert, but will this work? It uses identifier-binding to check if the identifier for the hash table is bound. (define-syntax (set/define stx) (syntax-case stx () [(_ ht key value) (cond [(identifier-binding #'ht) #'(hash-set! ht key value)]

Re: [racket-users] Help understanding cond expression

2019-01-15 Thread Michael Murdock MacLeod
On Saturday, January 12, 2019 8:34:35 PM PST Hassan Shahin wrote: > I have this definition for a procedure: > > (define type-of (lambda (item) > (cond >[(pair? item) 'pair] >[(null? item) 'empty-list] >