sydney.lambda
2019-9-2 19:20:23
(define (make-processor-operator op)
(lambda args
(lambda (processor)
(modulo (for/fold ([res 0])
([arg args])
(match arg
[(? number?) (op res arg)]
[(? lens?) (op res (lens-view arg processor))]
[(? procedure?) (op res (arg processor))]))
256))))
(define :+ (make-processor-operator +))
(define :- (make-processor-operator -))
(define (:= src dest)
(lambda (processor)
(lens-set src processor (dest processor))))
((:= A (:+ A 1)) (Processor 0))
I think your “lensify” idea turned out to be the better approach overall. For the sake of a : prefix (and maybe a little performance penalty due to more function calls) here and there, no macros necessary :)
again, I really don’t think I would have came up with this purely on my own, so thanks a lot.
notjack
2019-9-2 20:57:40
I’m glad I could help :)