Hello, list. I hope that you're all well. I just started using pattern matching and I'd kindly ask for your help to better understand how things work.
The goal is to implement an *ifthenelseif* function that takes cond-then pairs as arguments except the last set of arguments that are cond-then-else. The function should look like this, ifthenelseif(C1, T1, C2, T2, Cn, Tn, E); and unfold into this, if(C1, T1, if(C2, T2, if(Cn, Tn, E))); . I had a look at Julius' section on pattern matching where he explains the *count* and *take* functions. So I thought that a workaround to simplify things could have been to pass the arguments to the functions as lists, as in, ifthenelseif((C1, T1), (C2, T2), (Cn, Tn, E)); following the structure of *take, *but I don't see how to parse the last set of elements as list instead of single elements. For example, process = take(3, ((1,2,3),(4,5,6),(7,8,9))); gives "7", instead of 7,8,9, whereas process = take(2, ((1,2,3),(4,5,6),(7,8,9))); gives "4,5,6". I tried rewriting *take* as follows, thinking that parentheses could help, but they make no difference: takeblock(1, ((xs),(xxs))) = (xs); takeblock(1, (xs)) = (xs); takeblock(n, ((xs),(xxs))) = takeblock(n-1, (xxs)); How could you treat the last set of elements as a list? And would it be possible to write ifthenelseif so that you give a single set of arguments and pattern matching understands to take them into pairs from the beginning until the last three? Thanks for your help, Dario
_______________________________________________ Faudiostream-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/faudiostream-users
