Created
May 7, 2013 14:01
-
-
Save davespanton/5532793 to your computer and use it in GitHub Desktop.
Columnz challenge 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
USING: kernel locals sequences ; | |
IN: columnz | |
:: all-equal-first? ( col -- ? ) | |
col [ col first = ] all? ; | |
: sum-or-first ( seq -- n ) | |
dup all-equal-first? [ first ] [ sum ] if ; | |
: sum-or-first-seq ( seq -- seq ) | |
flip [ sum-or-first ] map ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment