#lang racket ; CSC324 — 2023W — Assignment 1 — Evo Implementation
; Task: implement evo according to A1.evo-test.rkt.
(contract-out (evo (any/c . -> . (list/c any/c (hash/c symbol? list?)))))
; Add any helper functions you tested in A1.evo-test.rkt.
; Whether you add contracts to them is optional.
#;a-helper)
; · Support: indexer and Void
(provide (contract-out (indexer (any/c . -> . (-> symbol?)))))
(define (indexer prefix)
(define last-index -1)
(local-require (only-in racket/syntax format-symbol))
(set! last-index (add1 last-index))
(format-symbol “~a~a” prefix last-index)))
; There is no literal nor variable for the void value (although it has a printed
; representation when printed inside compound values), so we’ll name it here and
; and also export it for testing.
(provide (contract-out (Void void?)))
(define Void (void))
; Produce a two-element list with the value and the environment-closure table
; from evaluating an LCO term.
(define (evo term)
; A mutable table of environments and closures.
(define environments-closures (make-hash))
; Iterators to produce indices for environments and closures.
(define En (indexer ‘E))
(define λn (indexer ‘λ))
; Task: complete rec.
(define (rec t E) t)
(list (rec term (En))
(make-immutable-hash (hash->list environments-closures))))