Skip to content
New issue

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

CCBool: Add functions if_then and if_then_else #442

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

BridgeTheMasterBuilder
Copy link
Contributor

Just some cute boolean combinators.

Example usage:

[true;false;true;false;true] |> List.filter_map (Bool.if_then (Fun.const 1));;
- : int list = [1; 1; 1]

[true;false;true;false;true] |> List.map (Bool.if_then_else (Fun.const 1) (Fun.const 0));;
- : int list = [1; 0; 1; 0; 1]

let t () = print_endline "Yes" in
let f () = print_endline "No" in
let select = Bool.if_then_else t f in
select true;
select false;;
Yes
No
- : unit = ()

etc.

@c-cube c-cube merged commit 77bfa34 into c-cube:main Nov 27, 2023
8 of 9 checks passed
@c-cube
Copy link
Owner

c-cube commented Nov 27, 2023

Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants