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::{fmt::Debug, rc::Rc}; | |
| const THE_JSON : &str = r#"{ | |
| "first_name": "John", | |
| "last_name": "Smith", | |
| "is_alive": true, | |
| "age": 27, | |
| "address": { | |
| "street_address": "21 2nd Street", | |
| "city": "New York", |
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
| #include <stdio.h> | |
| #include <stdint.h> | |
| #include <stddef.h> | |
| #define false 0 | |
| #define true !false | |
| char* input = "(a bc (def \n 5) 7)"; |
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
| #[derive(Debug,Clone)] | |
| enum Expr { | |
| Val(i32), | |
| Neg(Box<Expr>), | |
| Sum(Box<Expr>, Box<Expr>), | |
| Mul(Box<Expr>, Box<Expr>), | |
| Var(String), | |
| } |
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
| #include <stdalign.h> | |
| #include <stdint.h> | |
| #include <stddef.h> | |
| #include <stdio.h> | |
| struct List { | |
| enum { NODE, END } tag; | |
| union { | |
| struct { void* val; struct List* next; } node; | |
| struct { } end; |
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
| fn main(){ | |
| // let list = ["zabc", "ghjjklhgkj", "kgjgfhfgdg", "zabcd", "hghfgft", "afsbdgshng"]; | |
| let mut list = [3,6,2,1]; | |
| let mut list_ = [3,6,2,1]; | |
| let mut other_list = *b"abcd"; | |
| let mut other_list_ = *b"abcd"; | |
| let mut perm = Vec::new(); | |
| let mut perm_perm = Vec::new(); | |
| let mut perm_perm_perm = Vec::new(); |
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
| // Implements the cool-lex algorithm to generate (n,k)-combinations | |
| // @article{Ruskey:2009fk, | |
| // Author = {Frank Ruskey and Aaron Williams}, | |
| // Doi = {10.1016/j.disc.2007.11.048}, | |
| // Journal = {Discrete Mathematics}, | |
| // Month = {September}, | |
| // Number = {17}, | |
| // Pages = {5305-5320}, | |
| // Title = {The coolest way to generate combinations}, | |
| // Url = {http://www.sciencedirect.com/science/article/pii/S0012365X07009570}, |
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
| //! this library is largely "incorrect" in the sense that projectors should be exitentials and not part of type arguments | |
| // https://hackage.haskell.org/package/multiplate-0.0.3/docs/src/Data-Generics-Multiplate.html | |
| use std::{marker::PhantomData}; | |
| pub trait Funct { | |
| type F<T>; | |
| } |
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::marker::PhantomData; | |
| // CONTRAVARIANT | |
| struct Contra<'contra> (PhantomData< | |
| fn(&'contra ()) -> () | |
| >); | |
| // succeeds (contravariant "lengthening") | |
| fn contra_1<'a>( contra : Contra<'a>) -> Contra<'static> { | |
| contra | |
| } |
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
| type 'a list= List of { l : 'z . (unit -> 'z) -> ('a * 'a list -> 'z) -> 'z } | |
| let nil : 'a list = List{ l = fun f -> fun _ -> f()} | |
| let cons (v : 'a) (r : 'a list) : 'a list= | |
| List{ l = fun _ -> fun f -> f(v,r) } | |
| let ex : int list = cons 3 (cons 1 (cons 2 nil)) | |
| let length (l : 'a list) : int = |
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
| fAtoB_optionA_optionB(_, none, none). | |
| fAtoB_optionA_optionB(F, option(A), option(B)) :- C =.. [F,A,B], C. | |
| functor_map(option, fAtoB_optionA_optionB). | |
| fmapAtoB_fA_fB(Func, F_A, F_B) :- | |
| ( nonvar(F_A) -> F_A =.. [F| _] | |
| ; nonvar(F_B) -> F_B =.. [F| _] | |
| ), | |
| functor_map(F, Map), |
NewerOlder