Skip to content

Instantly share code, notes, and snippets.

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::*;
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"
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
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)
@lalaithion
lalaithion / scope.rs
Last active May 24, 2021 03:17
Reproducing code for Double Unroot issue
// [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;