Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Higher Order fizzbuzz from reddit post
;; From reddit comments
doc higher-fizzbuzz
"( map seq -- seq ) Returns modified seq with map target factors."
fn higher-fizzbuzz
*xs <> setl
*m <> setl
let factor-map m
doc first-target-factor "( n -- fb-result )"
fn first-target-factor
*n <> setl
;; In order to sort it, turn it into a vector of map entries
[] factor-map into sort
(dup first n <> mod zero?
if [over second true <>] ? <> drop else drop nil then) <> map
(first true?) <> filter
*second <> map
*str <> reduce
dup nil? if drop n then
*first-target-factor xs map
{2 "blah" 3 "fizz" 5 "buzz"} 1 20 range higher-fizzbuzz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.