#!/home/jj/bin/camilax =head1 from types do sexp with string =cut t2sexp(t) = sym2strl( gettype(strsym(t))); sym2strl(x) = if( x is-<> -> <>, x is- -> , else -> symstr(x) ); =head1 TUP - algebra... tup2ffstr: TupleValue -> (STR -> ANY) =cut tup2ffstr(x)= let(a = < p1(y)|y <- tl(t2sexp(symstr(type(x))))>, b = tup2seq(x)) in [ p1(y) -> p2(y) | y <- seqpair(a,b)]; =pod seq2tup: SeqValub x Tuplename -> Tuple =cut fapl(fname,li)= eval()>); seq2tup(x,tupname)= let(z=t2sexp(tupname)) in if(hd(z) == "TUP" -> fapl(tupname,x)); ; if(hd(z) == "TUP" -> eval()>)); ; if(hd(z) == "TUP" -> eval(>)); =pod tup2seq: TupValub -> ANY-seq =cut tup2seq(x)= let(z=symstr(type(x)), z1=t2sexp(z)) in < (eval(strsym(p1(y))))(x) | y <- tl(z1) > ; =head1 Miscelanious seqpair : A-seq x B-seq -> (A,b)-seq =cut seqpair(s1,s2)= do( /* princ(s1,"\n",s2,"----------\n"), */ if(s1 is-<> -> <>, else -> < : seqpair(tl(s1),tl(s2))>)); =head2 Testing... =cut TYPE id = n : STR a : INT c : id -set; ENDTYPE ;pp("x1"); x1 <- id("joao",12,{}); pp(x1); ;pp("x2"); x2 <- tup2seq(x1); pp(x2); ;pp("x3"); x3 <- tup2ffstr(x1); pp(x3); pp("x4"); x4 <- seq2tup(x2,"id"); pp(x4);