Created
August 21, 2014 00:58
-
-
Save statonjr/128dfbe60240311faf97 to your computer and use it in GitHub Desktop.
Summing digits in Factor
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
: 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