Skip to content

Commit

Permalink
nicer prime.cog example
Browse files Browse the repository at this point in the history
  • Loading branch information
StavromulaBeta committed Sep 24, 2024
1 parent 520adb3 commit 32f8cef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/fizzbuzz.cog
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Def Fizzbuzz (
Let N be Of ( Integer? );
Def Multiple as ( Zero? Modulo Swap N );
Let N be Of (Integer?);
Def Multiple as (Zero? Modulo Swap N);
Print
If Multiple of 15 then "fizzbuzz"
If Multiple of 3 then "fizz"
Expand Down
6 changes: 2 additions & 4 deletions examples/prime.cog
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
Def Factor (Zero? Modulo Swap);

Def Primes (
Let U is upper bound;
initially Empty;
For Range 2 to U (
Fold (
Let I be our potential prime;
Let Primes are the found primes;
Let To-check be Take-while (<= Sqrt I) Primes;
When None (Factor of I) To-check
(Append List (I)) to Primes;
)
) from List () over Range from 2
);

Print Primes up to 1000;

0 comments on commit 32f8cef

Please sign in to comment.