#![allow(dead_code)]
use hfs::prelude::*;
fn spair(x: Set, y: Set) -> Set {
unsafe { x.clone().singleton().insert_unchecked(x.pair(y)) }
}
fn ssplit(x: &Set) -> Option<(&Set, &Set)> {
fn test<'a>(fst: &'a Set, snd: &'a Set) -> Option<(&'a Set, &'a Set)> {
match snd.as_slice() {
[a] => {
if fst == a {
Some((a, a))
} else {
None
}
}
[a, b] => {
if fst == a {
Some((a, b))
} else if fst == b {
Some((b, a))
} else {
None
}
}
_ => None,
}
}
match x.as_slice() {
[fst, snd] => test(fst, snd).or_else(|| test(snd, fst)),
_ => None,
}
}
fn main() {
let nat = Set::nat(2);
let (a, b) = ssplit(&nat).unwrap();
println!("2 = ({a}, {b})");
}