Skip to content

Instantly share code, notes, and snippets.

@ClarkeRemy
Last active August 7, 2023 16:45
Show Gist options
  • Save ClarkeRemy/7fdde966741b86dfd05466ae07b48b40 to your computer and use it in GitHub Desktop.
Save ClarkeRemy/7fdde966741b86dfd05466ae07b48b40 to your computer and use it in GitHub Desktop.
Swappy
#[derive(Debug)]
enum Switchy<A,B>
{ Nil
, Cons(A, Box<Switchy<B,A>>)
}
impl<A,B> Switchy<A,B>
{ fn cons(t : A, tail : Switchy<B,A>)->Self
{ Self::Cons(t, Box::new(tail)) }
}
pub fn main()
{ type L<A,B> = Switchy<A,B>
; let l = L::cons(1, L::cons("horror", L::cons(3, L::cons("why", L::cons(4, L::Nil)))))
; println!{"{l:?}"}
;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment