#ifndef __LIST_CHH__ #define __LIST_CHH__ %define(listSelect,crit,lst, %locals(newlst, %\ %foreach(el,%&lst, %if(%crit(%&el), %lappend(%&newlst,%&el) ) )\ %&newlst ))\ \ %define(listSearch,lst,crit, %locals(length,pos, %\ %\ %while(%and(%[pos )\ %if(%[pos\ %\ %for(i,0,%[%llength(%lsts[0]) - 1],1, %\ %for(j,0,%[numlsts - 1], %lappend(%&lst,%&lsts[%j][%i]) )\ %lappend(%&newlst,%apply(%&mapping,%&lst)) )\ %&newlst ))\ \ %define(listLeftAccumulate,accumulator,lst,zero, %if(%[%llength(%lst)==0], %&zero , %locals(sum, %\ %for(i,1,%[%llength(%lst)-1],1, % )\ %&sum ) ) )\ \ %define(listRightAccumulate,accumulator,lst,zero, %if(%[%llength(%lst)==0], %&zero , %locals(sum, %\ %for(i,%[%llength(%lst)-2],0,-1, % )\ %&sum ) ) )\ \ %define(listJoin,sep,lst, %listLeftAccumulate(%lambda(a,b,%a%sep%b),%&lst,%'') )\ #endif