Racket - Match Function -


i'm learning how use "match" function in racket i'm not sure how can work in contexts.

for example, problem have use match replace every occurrence of lambda in program word "lumbda".

    > (lambda->lumbda '(lambda (lambda) lambda))      (lumbda (lambda) lambda) 

it should change function "lambda" "lumbda", not variables. have no clue how go this.

try this:

(define (lambda->lumbda exp)   (match exp     [(list 'lambda args body) (list 'lumbda args body)]     [_ (error "unknown expression")])) 

for example:

(lambda->lumbda '(lambda (lambda) lambda))  => (lumbda (lambda) lambda) 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -