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::cmp::Ordering; | |
type U0 = Zero; | |
type U1 = Succ<Zero>; | |
type U2 = Succ<U1>; | |
type U3 = Succ<U2>; | |
type U4 = Succ<U3>; | |
type U5 = Succ<U4>; | |
fn main() { |
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::{sync::Arc}; | |
#[derive(PartialEq, Eq,Debug, PartialOrd, Ord)] | |
enum Reduced<A>{ | |
Continue(A), | |
Reduced(A) | |
} | |
#[derive(Clone)] |
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 dyn_compose<'val, 'func, In, Out, Middle>( | |
f: Box<dyn Fn(Middle) -> Out + 'func>, | |
g: Box<dyn Fn(In) -> Middle + 'func>, | |
) -> Box<dyn Fn(In) -> Out + 'func> | |
where | |
In : 'val, | |
Middle : 'val, | |
Out : 'val, | |
'val : 'func, |
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 sub = |x,y| Diff::Sub((Box::new(x), Box::new(y))); | |
let lit = |x| Diff::Lit(x); | |
let tree = sub(sub(lit(5.0), lit(2.0)), lit(3.0)); | |
let tree2 = tree.clone(); | |
println!("tree : {:?}\ntree2: {:?}", |
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 core::{marker::PhantomData, sync::atomic::{AtomicBool, Ordering}}; | |
fn main() { | |
println!("Hello, world!"); | |
let test = *b"aabba"; | |
let group_by_0 = GroupBy::new(test.into_iter(), |&x|x); | |
for (key, group) in group_by_0 { | |
println!("key: {} {{", key as char); |
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
///! Proposal for guaranteed Tail-Drop elimination for functions that do not return values. | |
///! | |
///! We revisit the `become` keyword limiting it to functions that do not return values | |
///! Given this constraint, it becomes much easier to implement. | |
///! A programmer can always supply the place to return to with a continuation anyways quite trivialy. | |
/// This is why it must be done at a language level. | |
/// The programmer cannot do this themselves or they would have a stack overflow. | |
/// If the programmer did try to do it themselves, it would require a very complex, type unsafe way to do it. | |
/// All parts can be guaranteed to be sound statically |
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(calc, [tokens//1, ast//1, ast_eval/2, eval_formatted/2, source_eval/2, source_evalFormatted/2]). | |
:- use_module(library(clpz)). | |
:- use_module(library(dcgs)). | |
:- use_module(library(lists)). | |
:- use_module(library(charsio)). | |
:- use_module(library(dif)). | |
:- use_module(library(debug)). | |
/** S-expression calculator |
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
cargo build && gdb --command="my.gdb" ./target/debug/asm_learn |
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 core::cell::RefCell; | |
macro_rules! call { | |
( $FUNCTION:ident $ARGS:expr => $RETURN:ident) => { | |
unsafe { $FUNCTION::LOCAL.set(Funct { args: $ARGS, ret: &mut $RETURN }) } | |
$FUNCTION(); | |
}; | |
} | |
fn main() -> std::process::ExitCode |
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
#![no_implicit_prelude] | |
pub(crate) extern crate alloc; // with heap | |
pub(crate) extern crate core; // fundamental | |
pub(crate) extern crate std; // OS | |
fn main() { | |
let _x = MyBox::new(alloc::vec![4]); | |
} | |
pub struct MyBox<T> { |