-
-
Save Invizory/0bd2d52ea48a60ae704a25553918a78d to your computer and use it in GitHub Desktop.
Практикум, 27.09.2023
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let plus = (x, y) => x + y; | |
let plus_2 = (x) => ((y) => x + y); | |
let plus_3 = (x, y) => (+)(x, y); | |
let inc = (+)(1); | |
let greet = (name) => "hello, " ++ name; | |
let (+++) = (x, y) => x ++ ", " ++ y; | |
let greet_2 = (name) => "hello" +++ name; | |
let greet_3 = (+++)("hello"); | |
// let (|>) = (x, f) => f(x); | |
let () = { | |
Stdio.print_endline("hello, world"); | |
"world" |> greet |> Stdio.print_endline; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type cycle = | |
| A | |
| B | |
| C | |
| D; | |
let next = w => | |
switch (w) { | |
| A => B | |
| B => C | |
| C => D | |
| D => A | |
}; | |
type color = | |
| Black | |
| White | |
| Gray(float); | |
let inverse = x => | |
switch (x) { | |
| Black => White | |
| White => Black | |
| Gray(f) => Gray(-. f) | |
}; | |
type rgb = { | |
red: int, | |
green: int, | |
blue: int, | |
}; | |
let inverse = c => { | |
red: 255 - c.red, | |
green: 255 - c.green, | |
blue: 255 - c.blue, | |
}; | |
let inverse = ({red: red1, green: green1, blue: blue1}) => { | |
red: 255 - red1, | |
green: 255 - green1, | |
blue: 255 - blue1, | |
}; | |
let inverse = ({red, green, blue}) => { | |
red: 255 - red, | |
green: 255 - green, | |
blue: 255 - blue, | |
}; | |
let sum = ({red, green, blue}) => red + green + blue; | |
let red_1 = ({red, _}) => red; | |
type color = | |
| Black | |
| White | |
| RGB({ | |
red: int, | |
green: int, | |
blue: int, | |
}); | |
let inverse = c => | |
switch (c) { | |
| Black => White | |
| White => Black | |
| RGB({red, green, blue}) => | |
RGB({red: 255 - red, green: 255 - green, blue: 255 - blue}) | |
}; | |
type bar = X | Y | Z(int); | |
type foo = A | B | C(bar, int); | |
let f = (x) => switch (x) { | |
| C(Z(x), y) => x + y | |
| _ => 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment