Skip to content

Instantly share code, notes, and snippets.

@shirok
Created December 16, 2021 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirok/19953e667a1084918b0e49b52fbad623 to your computer and use it in GitHub Desktop.
Save shirok/19953e667a1084918b0e49b52fbad623 to your computer and use it in GitHub Desktop.
(define (filter pred xs)
(define (skip xs)
(cond [(null? xs) xs]
[(pred (car xs)) xs]
[else (skip (cdr xs))]))
(unfold (^[xs] (null? (skip xs)))
(^[xs] (car (skip xs)))
(^[xs] (cdr (skip xs)))
xs))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment