This homework has to do with mupl (a Made Up Programming Language). mupl programs are written directly in Racket by using the constructors defined by the structs here:
(provide (all-defined-out)) ;; so we can put tests in a second file
;; definition of structures for MUPL programs - Do NOT change
(struct var (string) #:transparent) ;; a variable, e.g., (var "foo")
(struct int (num) #:transparent) ;; a constant number, e.g., (int 17)
(struct add (e1 e2) #:transparent) ;; add two expressions
(struct ifgreater (e1 e2 e3 e4) #:transparent) ;; if e1 > e2 then e3 else e4
(struct fun (nameopt formal body) #:transparent) ;; a recursive(?) 1-argument function
(struct call (funexp actual) #:transparent) ;; function call
(struct mlet (var e body) #:transparent) ;; a local binding (let var = e in body)
(struct apair (e1 e2) #:transparent) ;; make a new pair
(struct fst (e) #:transparent) ;; get first part of a pair
(struct snd (e) #:transparent) ;; get second part of a pair
(struct aunit () #:transparent) ;; unit value -- good for ending a list
(struct isaunit (e) #:transparent) ;; evaluate to 1 if e is unit else 0
;; a closure is not in "source" programs but /is/ a MUPL value; it is what functions evaluate to
(struct closure (env fun) #:transparent)
here is the function I'm asking about
(define (racketlist->mupllist e)
(cond [(null? e) (aunit)]
[#t (apair (car e) (racketlist->mupllist (cdr e)))]))
It's one identifier, not two identifiers separated by an arrow – Scheme identifiers are not limited to alphanumerical characters and underscore like many other languages.
The conventional name of conversion functions from type A to type B is A->B
, so racketlist->mupllist
is a sensible name since it converts a Racket list into a mupl list.