I'm new to Racket, and am struggling to find the right words to explain what I'm trying to do. The best I can come up with is this: How do I use the value of an argument as a symbol, without calling the function which has the same name as the value of the argument, and without just quoting the name of the argument?
Here is a minimal example to show this.
There is a function called ul
which does something.
There is another function called make-list
which has a single parameter, list-type
.
There is a third function, make-ul
, which calls make-list
with an argument ul
.
In the true branch, the function ul
is applied. Good so far.
In the false branch, I want to be able to use the value of the argument, which in this case is 'ul
, as a symbol. In effect, this line of code would run (λ args (list* 'ul args))
. How do I achieve this?
#lang racket
(define (ul . xs) `(div ,@xs))
(define (make-list list-type)
(if (equal? 'something 'something-else)
(λ args (apply list-type args)) ; true branch: call the function "ul"
(λ args (list* list-type args)))) ; false branch: how to use `ul without calling the "ul" function?
(define make-ul (make-list ul))