View scope.rs
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
// [dependencies] | |
// gc = { version = "0.4", features = ["derive"] } | |
// rpds = "0.9.0" | |
// fails with `thread 'scope::tests::test' panicked at 'Can't double-unroot a Gc<T>'` | |
use core::fmt::{Debug, Formatter, Result}; | |
use gc::{Finalize, Gc, Trace}; | |
use rpds::HashTrieMap; | |
use std::io::Write; |
View minimal.fut
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 sizetwice [n] = { | |
array: [n][n]i64 | |
} | |
let make_sizetwice (n: i64): sizetwice [n] = {array = replicate n (iota n)} | |
let consume_sizetwice [n] (x: sizetwice [n]): i64 = reduce (+) 0 (map (reduce (+) 0) x.array) | |
-- > consume_sizetwice (make_sizetwice 3i64) |
View perlin.fut
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
import "lib/github.com/diku-dk/cpprandom/random" | |
-- We'll need a random number generator. We don't need any good guarantees, | |
-- so we use the fastest one. | |
module dist = uniform_real_distribution f32 minstd_rand | |
-- Let's define some aliases for readability. | |
let split = minstd_rand.split_rng |
View bomb.hs
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
f :: Int -> Bool | |
f i = 23 == foldr ((+) . abs) i [-5..5] | |
main = do | |
putStrLn "Can you beat my Haskell puzzle?" | |
x <- getLine | |
if f (read x) then putStrLn "You beat my Haskell puzzle!" else putStrLn "Boom" |
View persistent-lazy.rs
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
use std::rc::Rc; | |
use std::fmt::{Display, Debug, Error, Formatter}; | |
/// Because we are dealing with immutable data, we shouldn't ever need the | |
/// owned variant of Lazy or the mutable version of Thunk. | |
use thunk::LazyRef; | |
use thunk::Thunk; | |
use crate::ListCell::*; |