Use table->unary-function in table->function/list.

This commit is contained in:
Sergiu Ivanov 2023-03-03 10:21:31 +01:00
parent 09c14907ca
commit 6783b97add

View file

@ -280,11 +280,10 @@
(: table->function/list (All (a) (-> (Listof (Listof a)) (: table->function/list (All (a) (-> (Listof (Listof a))
(-> (Listof a) a)))) (-> (Listof a) a))))
(define (table->function/list table) (define (table->function/list table)
(define ht-tab (table->unary-function
(for/hash ([line (in-list table)]) : (HashTable (Listof a) a) (for/list ([line (in-list table)]) : (Listof (List (Listof a) a))
(define-values (x fx) (split-at-right line 1)) (define-values (ins out) (split-at-right line 1))
(values x (car fx)))) (list ins (car out)))))
(λ (x) (hash-ref ht-tab x)))
(module+ test (module+ test
(test-case "table->function/list" (test-case "table->function/list"