I hereby claim:
- I am gdejohn on github.
- I am gdejohn (https://keybase.io/gdejohn) on keybase.
- I have a public key whose fingerprint is 3FC3 DC5C BBCE 6B36 141A EC79 CB0E 1AE7 A8E6 DFF4
To claim this, I am signing this object:
package poker; | |
public record Card(Rank rank, Suit suit) {} |
"A state in a deterministic finite automaton." | |
shared interface State<in Symbol> { | |
"Returns [[true]] if this is an accept state, else [[false]]." | |
shared default Boolean accepting => false; | |
"Returns the next state given the next [[symbol]]." | |
shared default State<Symbol> transition(Symbol symbol) => trap; | |
"Returns [[true]] if the given [[string]] is accepted by the implicit DFA | |
starting at this state, else [[false]]. Accepted strings are words in the |
Float montePi(Integer samples) => 4.0 * count({random() ^ 2 + random() ^ 2 <= 1.0}.repeat(samples)) / samples; |
I hereby claim:
To claim this, I am signing this object:
import static java.util.Map.entry; | |
import static java.util.stream.IntStream.range; | |
import java.util.Map.Entry; | |
import java.util.stream.Stream; | |
public class FizzBuzz { | |
public static void main(String[] args) { | |
range(1, 100).mapToObj( | |
i -> Stream.of(entry(3, "Fizz"), entry(5, "Buzz")).filter( |
assert (exists x = loop(1.0)(cos).paired.find(([x, y]) => x == y)?.first); |
value fibonacci = loop([0, 1])(([x, y]) => [y, x + y]).map(Tuple.first); |
Element[] quicksort<Element>({Element*} elements) | |
given Element satisfies Comparable<Element> => | |
if (exists first = elements.first) | |
then [first.largerThan, first.notLargerThan] | |
.map(compose(quicksort<Element>, elements.rest.filter)) | |
.interpose([first]) | |
.reduce(concatenate<Element>) | |
else []; |
import Control.Applicative (liftA2) | |
import Data.List (partition) | |
import Data.List.Extra (list) | |
import Data.Tuple.Extra (both, second) | |
sort :: Ord a => [a] -> [a] | |
sort = [] `list` liftA2 (.) ((uncurry (++) .) . second . (:)) ((both sort .) . partition . (>)) |
import Data.List (find) | |
-- A state in a deterministic finite automaton. | |
data State a = State Accept (a -> State a) | Trap | |
-- Indicates whether a state is an accept state. | |
data Accept = Accept | Reject | |
-- Determines whether the implicit DFA starting at the given state recognizes | |
-- the given string. |