Is there a predefined procedure that takes a list of procedures and applies them to get a list of values. Something like (define (inverted-map procs arg)
(map (lambda (proc) (proc arg)) procs))
(or a generalization)
Not really. foldl
is similarly almost there, but not quite: > (foldl (λ (f acc) (f acc)) 2 (list add1 / displayln))
1/3
Funny, I’ve ended up writing the same thing in SML a few times: fun mapp fs x = map (fn f => f x) fs
fun mapps fs xs = ListPair.map (fn (f, x) => f x) (fs, xs)
I use mapp
as a cutesy spelling of map
+ app
, since app
is the (SML) function with signature ('a -> unit) -> 'a list -> unit
But racket could probably use something similar
And the second one should probably be zipmap or pointwise-map or …
@haasis_noah has joined the channel