add more seq->list & list->vec morphisms

This commit is contained in:
Michael Sippel 2024-10-28 21:17:54 +01:00
parent 689ac95486
commit af34fc9976
Signed by: senvas
GPG key ID: F96CF119C34B64A6

View file

@ -84,6 +84,20 @@ pub fn init_ctx(ctx: Arc<RwLock<Context>>) {
}
);
let seq_morph_to_list_char = GenericReprTreeMorphism::new(
Context::parse(&ctx, "<Seq Char>"),
Context::parse(&ctx, "<Seq Char>~<List Char>"),
{
let ctx = ctx.clone();
move |src_rt, σ| {
src_rt.attach_leaf_to(
Context::parse(&ctx, "<List Char>"),
src_rt.view_seq::<char>().to_list()
);
}
}
);
let list_morph_to_vec_char = GenericReprTreeMorphism::new(
Context::parse(&ctx, "<List Char>"),
Context::parse(&ctx, "<List Char>~<Vec Char>"),
@ -98,6 +112,34 @@ pub fn init_ctx(ctx: Arc<RwLock<Context>>) {
}
);
let seq_morph_to_list_u64 = GenericReprTreeMorphism::new(
Context::parse(&ctx, "<Seq machine.UInt64>"),
Context::parse(&ctx, "<Seq machine.UInt64>~<List machine.UInt64>"),
{
let ctx = ctx.clone();
move |src_rt, σ| {
src_rt.attach_leaf_to(
Context::parse(&ctx, "<List machine.UInt64>"),
src_rt.view_seq::<u64>().to_list()
);
}
}
);
let list_morph_to_vec_u64 = GenericReprTreeMorphism::new(
Context::parse(&ctx, "<List machine.UInt64>"),
Context::parse(&ctx, "<List machine.UInt64>~<Vec machine.UInt64>"),
{
let ctx = ctx.clone();
move |src_rt, σ| {
src_rt.attach_leaf_to(
Context::parse(&ctx, "<Vec machine.UInt64>"),
src_rt.view_list::<u64>()
);
}
}
);
let list_morph_from_vec_char = GenericReprTreeMorphism::new(
Context::parse(&ctx, "<List Char>~<Vec Char>"),
Context::parse(&ctx, "<List Char>"),
@ -129,7 +171,10 @@ pub fn init_ctx(ctx: Arc<RwLock<Context>>) {
ctx.write().unwrap().morphisms.add_morphism( list_morph_editsetup1 );
ctx.write().unwrap().morphisms.add_morphism( list_morph_editsetup3 );
ctx.write().unwrap().morphisms.add_morphism( list_morph_from_vec_char );
ctx.write().unwrap().morphisms.add_morphism( seq_morph_to_list_char );
ctx.write().unwrap().morphisms.add_morphism( seq_morph_to_list_u64 );
ctx.write().unwrap().morphisms.add_morphism( list_morph_to_vec_char );
ctx.write().unwrap().morphisms.add_morphism( list_morph_to_vec_u64 );
ctx.write().unwrap().morphisms.add_morphism( list_morph_to_vec_edittree );
}