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
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
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)]
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]
>
4 matches
Mail list logo