This file contains hidden or 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
module Data.AltList | |
%access public export | |
%default total | |
data AltList : (a : Type) -> (b : Type) -> Type where | |
Nil : AltList a b | |
ConsB : b -> AltList a b -> AltList a b | |
ConsAB : a -> b -> AltList a b -> AltList a b |
This file contains hidden or 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
module Data.ToggleList | |
%access public export | |
%default total | |
data Next = A | B | |
next : Next -> Type -> Type -> Type | |
next A a _ = a | |
next B _ b = b |
This file contains hidden or 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
data CloserToZero : Integer -> Integer -> Type where | |
CTZ : So (x * x < y * y) -> CloserToZero x y | |
CTZInj : CloserToZero x y -> So (x * x < y * y) | |
CTZInj (CTZ oh) = oh | |
closerToZero : (x, y : Integer) -> Dec (CloserToZero x y) | |
closerToZero x y with (x * x < y * y) proof prf | |
closerToZero x y | True = Yes (CTZ (rewrite sym prf in Oh)) | |
closerToZero x y | False = No (absurd . the (So False) . rewrite prf in CTZInj) |
This file contains hidden or 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
module SParser | |
import Text.Lexer | |
import Text.Parser | |
data SParser : Type -> Type -> Bool -> Type -> Type where | |
MkSParser : (s -> Grammar t c (a, s)) -> SParser s t c a | |
Functor (SParser s t b) where | |
map f (MkSParser g) = MkSParser $ \s => map (\(v,s) => (f v, s)) (g s) |
This file contains hidden or 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
term : MRule Expr | |
term = pure $ let (x, xs) = !multChain in | |
foldl (Binary Mul) x xs | |
where | |
multChain : MRule (Expr, List Expr) | |
multChain = do x <- factor | |
xs <- (do let op = match (Op Mul) | |
op | |
commit | |
sepBy1 op factor) <|> pure [] |
This file contains hidden or 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
-0/-1 | |
-0/-2 | |
-1/-0 | |
-1/-1 | |
-2/-1 | |
-2/-2 | |
+0/+1 | |
+0/+2 | |
+1/+0 | |
+1/+1 |
This file contains hidden or 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::collections::HashSet; | |
use serde::{Deserialize, Serialize}; | |
struct Context { | |
applications: HashSet<String>, | |
} | |
impl Context { | |
pub fn new() -> Self { |
This file contains hidden or 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
class A { | |
final name = 'A'; | |
void printName() { | |
print(name); | |
} | |
} | |
class B extends A { | |
@override |
This file contains hidden or 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
from itertools import accumulate | |
MONTH_NAMES = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] | |
MONTH_LENGTHS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] | |
MONTH_STARTS = list(accumulate([0] + MONTH_LENGTHS[:-1])) # [0, 31, 31+28, 31+28+31, ...] | |
def is_leap_year(year: int) -> bool: | |
return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) |
OlderNewer