From 34a8e91898d551d036742fd6fb45c57b8e95ad52 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 18 Sep 2015 22:54:47 -0700 Subject: New function: flatcar. * eval.c (eval_init): Register flatcar intrinsic. * lib.c (flatcar): New function. * lib.h (flatcar): Declared. * txr.1: Documented. --- lib.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib.c') diff --git a/lib.c b/lib.c index b912e9b0..6de77669 100644 --- a/lib.c +++ b/lib.c @@ -1512,6 +1512,15 @@ val lazy_flatten(val list) } } +val flatcar(val tree) +{ + if (atom(tree)) + return cons(tree, nil); + if (cdr(tree)) + return nappend2(flatcar(car(tree)), flatcar(cdr(tree))); + return flatcar(car(tree)); +} + static val tuples_func(val env, val lcons) { list_collect_decl (out, ptail); -- cgit v1.2.3