Skip to content

Commit 457bbb4

Browse files
formatting
1 parent d7e931c commit 457bbb4

File tree

11 files changed

+517
-385
lines changed

11 files changed

+517
-385
lines changed

content/_index.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ Def Fizzbuzz (
1313
Let N be Of (Integer?);
1414
Def Multiple as (Zero? Modulo Swap N);
1515
16-
If Multiple of 15 then "fizzbuzz"
17-
If Multiple of 3 then "fizz"
18-
If Multiple of 5 then "buzz"
19-
else N
16+
If Multiple of 15 then "fizzbuzz"
17+
If Multiple of 3 then "fizz"
18+
If Multiple of 5 then "buzz"
19+
else N
2020
);
2121
2222
For each in Range 1 to 100 (Print Fizzbuzz);
@@ -35,9 +35,9 @@ Def Move discs as (
3535
Let C be third rod;
3636
3737
Unless Zero? N (
38-
Move - 1 N discs from A via C to B;
39-
Prints ("Move disc " N " from " A " to " C);
40-
Move - 1 N discs from B via A to C;
38+
Move - 1 N discs from A via C to B;
39+
Prints ("Move disc " N " from " A " to " C);
40+
Move - 1 N discs from B via A to C;
4141
)
4242
);
4343
@@ -63,7 +63,7 @@ Def Factor (Zero? Modulo Swap);
6363
6464
Def Primes (
6565
Fold (
66-
Let I be our potential prime;
66+
Let I be our potential prime;
6767
Let Primes are the found primes;
6868
Let To-check be Take-while (<= Sqrt I) Primes;
6969
When None (Factor of I) To-check

content/learn.md

+30-30
Original file line numberDiff line numberDiff line change
@@ -178,26 +178,26 @@ Now that this (hopefully) makes some sense, we can finally introduce the `If` st
178178

179179
```cognate
180180
Print
181-
If == X 1 then "foo"
182-
If == X 2 then "bar"
183-
else "baz";
181+
If == X 1 then "foo"
182+
If == X 2 then "bar"
183+
else "baz";
184184
```
185185

186186
We can combine this with `Do` to have conditional code execution.
187187

188188
```cognate
189189
Do
190-
If == X 1 then ( Print "foo" )
191-
If == X 2 then ( Print "bar" )
192-
else ( Print "baz" );
190+
If == X 1 then ( Print "foo" )
191+
If == X 2 then ( Print "bar" )
192+
else ( Print "baz" );
193193
```
194194

195195
Now, let's use our knowledge of blocks to define our own control flow function `Thrice`, which should evaluate a block three times in a row. This demonstrates a different use of `Def` in which we bind a block from the stack.
196196

197197
```cognate
198198
Def Thrice as (
199-
Def F;
200-
F F F
199+
Def F;
200+
F F F
201201
);
202202
203203
Thrice (
@@ -355,9 +355,9 @@ The table type provides an efficient, immutable, unordered mapping between keys
355355

356356
```cognate
357357
Let T be Table (
358-
"foo" is 1;
359-
"bar" is Range 2 to 10;
360-
12 is 13; ~~ Keys can be of any type except box or block
358+
"foo" is 1;
359+
"bar" is Range 2 to 10;
360+
12 is 13; ~~ Keys can be of any type except box or block
361361
);
362362
363363
Print . "foo" T;
@@ -368,9 +368,9 @@ Print . "bar" T;
368368

369369
```cognate
370370
Def Remove-baz (
371-
Remove "baz"
372-
from Of (Has "baz")
373-
Of (Table?);
371+
Remove "baz"
372+
from Of (Has "baz")
373+
Of (Table?);
374374
);
375375
376376
Insert "baz" is Range 11 to 100 into T;
@@ -400,12 +400,12 @@ Earlier when we defined loops, you may have noticed something missing -- the bre
400400
Let I be 1;
401401
402402
Begin (
403-
Def Break;
404-
While (True) (
405-
Print Unbox I;
406-
Set I to + 1 of Unbox I;
407-
When == 101 Unbox I ( Break out of the begin );
408-
)
403+
Def Break;
404+
While (True) (
405+
Print Unbox I;
406+
Set I to + 1 of Unbox I;
407+
When == 101 Unbox I ( Break out of the begin );
408+
)
409409
);
410410
```
411411

@@ -415,16 +415,16 @@ This essentially allows any control flow to have a break statement, not just loo
415415
~~ Inefficiently decrements a number 100 times
416416
~~ If it reaches zero, returns zero instead.
417417
Def F (
418-
Begin (
419-
Def Return;
420-
Let X be Box Of (Integer?);
421-
422-
Times 100 (
423-
Set X to - 1 Unbox X;
424-
When Zero? Unbox X ( Return 0 );
425-
);
426-
Return Unbox X;
427-
)
418+
Begin (
419+
Def Return;
420+
Let X be Box Of (Integer?);
421+
422+
Times 100 (
423+
Set X to - 1 Unbox X;
424+
When Zero? Unbox X ( Return 0 );
425+
);
426+
Return Unbox X;
427+
)
428428
);
429429
```
430430

public/categories/index.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
33
<channel>
44
<title>Categories on Cognate: Readable and concise concatenative programming</title>
5-
<link>https://cognate-lang.github.io/categories/</link>
5+
<link>http://localhost:1313/categories/</link>
66
<description>Recent content in Categories on Cognate: Readable and concise concatenative programming</description>
77
<generator>Hugo</generator>
88
<language>en-us</language>
9-
<atom:link href="https://cognate-lang.github.io/categories/index.xml" rel="self" type="application/rss+xml" />
9+
<atom:link href="http://localhost:1313/categories/index.xml" rel="self" type="application/rss+xml" />
1010
</channel>
1111
</rss>

public/index.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ <h2 id="readable-and-concise-concatenative-programming">Readable and concise con
2323
Def Fizzbuzz (
2424
Let N be Of (Integer?);
2525
Def Multiple as (Zero? Modulo Swap N);
26-
Print
27-
If Multiple of 15 then "fizzbuzz"
28-
If Multiple of 3 then "fizz"
29-
If Multiple of 5 then "buzz"
30-
else N
26+
27+
If Multiple of 15 then "fizzbuzz"
28+
If Multiple of 3 then "fizz"
29+
If Multiple of 5 then "buzz"
30+
else N
3131
);
3232

3333
For each in Range 1 to 100 (Print Fizzbuzz);

public/index.xml

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
33
<channel>
44
<title>About on Cognate: Readable and concise concatenative programming</title>
5-
<link>https://cognate-lang.github.io/</link>
5+
<link>http://localhost:1313/</link>
66
<description>Recent content in About on Cognate: Readable and concise concatenative programming</description>
77
<generator>Hugo</generator>
88
<language>en-us</language>
9-
<atom:link href="https://cognate-lang.github.io/index.xml" rel="self" type="application/rss+xml" />
9+
<atom:link href="http://localhost:1313/index.xml" rel="self" type="application/rss+xml" />
1010
<item>
1111
<title>Learn Cognate</title>
12-
<link>https://cognate-lang.github.io/learn/</link>
12+
<link>http://localhost:1313/learn/</link>
1313
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
14-
<guid>https://cognate-lang.github.io/learn/</guid>
14+
<guid>http://localhost:1313/learn/</guid>
1515
<description>Learn Cognate A brief introduction to the language Install First install CognaC the Cognate Compiler from here using the provided instructions. Currently CognaC will run on recent Linux or Mac systems. Windows users can install it onto the Windows Subsystem for Linux &amp;ndash; native Windows support is planned.&#xA;Invoking CognaC is simple. If you have a file named foo.cog containing a Cognate program, it can be compiled into an executable named foo with the following command.</description>
1616
</item>
1717
<item>
1818
<title>Prelude</title>
19-
<link>https://cognate-lang.github.io/reference/prelude/</link>
19+
<link>http://localhost:1313/reference/prelude/</link>
2020
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
21-
<guid>https://cognate-lang.github.io/reference/prelude/</guid>
21+
<guid>http://localhost:1313/reference/prelude/</guid>
2222
<description>Prelude Drop Discard the top stack item.&#xA;Print Drop &#34;foo&#34; &#34;bar&#34;; Source Def Drop as ( Let X ); Swap Swaps the top two stack items.&#xA;Print Swap 1 2; Source Def Swap as ( Let X ; Let Y ; Y X ); Do Execute a block.&#xA;Do ( Print &#34;hello world!&#34; ); Source Def Do as ( Def F ; F ); Any? Takes a parameter of any type and returns True</description>
2323
</item>
2424
</channel>

public/reference/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
<!doctype html>
33
<html>
4-
<head>
4+
<head><script src="/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=livereload" data-no-instant defer></script>
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<link rel="stylesheet" href="/main.min.css" />

public/reference/index.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
33
<channel>
44
<title>Reference on Cognate: Readable and concise concatenative programming</title>
5-
<link>https://cognate-lang.github.io/reference/</link>
5+
<link>http://localhost:1313/reference/</link>
66
<description>Recent content in Reference on Cognate: Readable and concise concatenative programming</description>
77
<generator>Hugo</generator>
88
<language>en-us</language>
9-
<atom:link href="https://cognate-lang.github.io/reference/index.xml" rel="self" type="application/rss+xml" />
9+
<atom:link href="http://localhost:1313/reference/index.xml" rel="self" type="application/rss+xml" />
1010
<item>
1111
<title>Prelude</title>
12-
<link>https://cognate-lang.github.io/reference/prelude/</link>
12+
<link>http://localhost:1313/reference/prelude/</link>
1313
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
14-
<guid>https://cognate-lang.github.io/reference/prelude/</guid>
14+
<guid>http://localhost:1313/reference/prelude/</guid>
1515
<description>Prelude Drop Discard the top stack item.&#xA;Print Drop &#34;foo&#34; &#34;bar&#34;; Source Def Drop as ( Let X ); Swap Swaps the top two stack items.&#xA;Print Swap 1 2; Source Def Swap as ( Let X ; Let Y ; Y X ); Do Execute a block.&#xA;Do ( Print &#34;hello world!&#34; ); Source Def Do as ( Def F ; F ); Any? Takes a parameter of any type and returns True</description>
1616
</item>
1717
</channel>

0 commit comments

Comments
 (0)