Created
September 29, 2021 15:11
-
-
Save christianvdstap/2d5502252c7180d615bec65d6e918066 to your computer and use it in GitHub Desktop.
Infinite loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tail(v) = | |
let(n=len(v)) | |
n > 0 | |
? [for (i=[1:n-1]) v[i]] | |
: [] | |
; | |
function head(v) = | |
let(n=len(v)) | |
n > 0 | |
? [v[0]] | |
: [] | |
; | |
function filter(v, predicate=function(x) true, acc=[]) = | |
let(n=len(v)) | |
n > 0 | |
? filter(tail(v), predicate, predicate(v[0]) ? concat(acc, head(v)) : acc) | |
: acc | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment