Skip to content

Instantly share code, notes, and snippets.

@statonjr
Created August 21, 2014 00:58
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 statonjr/128dfbe60240311faf97 to your computer and use it in GitHub Desktop.
Save statonjr/128dfbe60240311faf97 to your computer and use it in GitHub Desktop.
Summing digits in Factor
: sum-digits ( n -- n ) number>string [EBNF rule=[0-9]+ EBNF] [ 1 swap <string> string>number ] map 0 [ + ] reduce ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment