For fun I've created a bunch of functions in Racket that create and combine other functions.
Now I've defined a recursive function in terms of them:
(define (my-flatten2 struct)
((<?> pair?
(<+> append <m>
(</> map my-flatten2)
(<Y> car cdr))
list)
struct))
I tried this first, but it didn't work (it gave me a can't reference identifier before its definition error):
(define my-flatten-error
(<?> pair?
(<+> append <m>
(</> map my-flatten-error)
(<Y> car cdr))
list))
Can anyone explain why it didn't work, and whether or not there is a way to fix it.
For the record
<+>is compose<Y>is create a function that applies a list of functions to one arg</>is partially apply<?>is choice