We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Original bug ID: 3715 Reporter: administrator Status: closed Resolution: won't fix Priority: normal Severity: feature Category: ~DO NOT USE (was: OCaml general)
I looked all through the standard list library for a function like this and couldn't find it, but it should definately be in there.
let rec apply n list = match list with [] -> [] | h::t -> (h n) :: (apply n t);; val apply : 'a -> ('a -> 'b) list -> 'b list =
or tail recursively...
let rec apply n list res = match list with [] -> res | h::t -> (apply n t) ((h n) :: res);; val apply : 'a -> ('a -> 'b) list -> 'b list =
The text was updated successfully, but these errors were encountered:
Comment author: administrator
I looked all through the standard list library for a function like this and couldn't find it, but it should definately be in there. let rec apply n list = match list with [] -> [] | h::t -> (h n) :: (apply n t);; val apply : 'a -> ('a -> 'b) list -> 'b list =
It's not in the standard library because:
let apply n list = List.map (fun f -> f n) list;;
BTW, your tail-recursive version is broken.
-- Damien
Sorry, something went wrong.
wish denied DD 2005-07-08
No branches or pull requests
Original bug ID: 3715
Reporter: administrator
Status: closed
Resolution: won't fix
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)
Bug description
I looked all through the standard list library for a function like
this and couldn't find it, but it should definately be in there.
let rec apply n list =
match list with
[] -> []
| h::t -> (h n) :: (apply n t);;
val apply : 'a -> ('a -> 'b) list -> 'b list =
or tail recursively...
let rec apply n list res =
match list with
[] -> res
| h::t -> (apply n t) ((h n) :: res);;
val apply : 'a -> ('a -> 'b) list -> 'b list =
The text was updated successfully, but these errors were encountered: