networks,table->function: Store the function in a local binding.

This avoids reconstructing the function from the table every time the
lambda is called.
This commit is contained in:
Sergiu Ivanov 2020-03-19 23:17:23 +01:00
parent 9bcb5681ce
commit 80ef41eaa4

View File

@ -425,7 +425,8 @@
;;; meaning that it may be sometimes more expensive to compute than by ;;; meaning that it may be sometimes more expensive to compute than by
;;; using an direct symbolic implementation. ;;; using an direct symbolic implementation.
(define (table->function table) (define (table->function table)
(λ args ((table->function/list table) args))) (let ([func (table->function/list table)])
(λ args (func args))))
;;; Like table->function, but the produced function accepts a single ;;; Like table->function, but the produced function accepts a single
;;; list of arguments instead of individual arguments. ;;; list of arguments instead of individual arguments.