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
1 changed files with 4 additions and 5 deletions

View File

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