Created
August 18, 2010 06:16
-
-
Save jonsterling/533666 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #include <stdio.h> | |
| int main () { | |
| size_t n = 100; | |
| int odds[n]; | |
| size_t i; | |
| for(i = 0; i < n; ++i) { | |
| odds[i] = 2 * i + 1; | |
| } | |
| size_t j; | |
| for(j = 0; j < n; ++j) { | |
| printf("%s%i%s", (j != 0 ? "," : "["), odds[j], (j == (n-1) ? "]" : "")); | |
| } | |
| return 0; | |
| } |
This file contains hidden or 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
| main = print [2*i + 1 | i <- [0..99]] |
This file contains hidden or 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
| #include <stdio.h> | |
| int main () { | |
| size_t n = 100; | |
| int odds[n]; | |
| size_t i; | |
| for(i = 0; i < n; ++i) { | |
| odds[i] = 2 * i + 1; | |
| } | |
| size_t j; | |
| int s = 0; | |
| for(j = 0; j < n; ++j) { | |
| s = s + odds[j]; | |
| printf("%s%i%s", (j != 0 ? "," : "["), odds[j], (j == (n-1) ? "]" : "")); | |
| } | |
| printf("\nsum: %i", s); | |
| return 0; | |
| } |
This file contains hidden or 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
| main = print odds >> print ("sum: " ++ (show . sum) odds) | |
| where odds = [2*i + 1 | i <- [0..99]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment