on master help sign in
nock implementations converted to umd
eda2a83joshuareagan
docs/tutorials/nock/implementations/c.umd+6−6
@@ -1,9 +1,9 @@
1−---
2−navhome: /docs/
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'6'
3−title: C
4+ title/'C'
4−sort: 6
5+ ==
5−next: true
6+;>
6−---
7
7
8# C
8# C
9
9
docs/tutorials/nock/implementations/clojure.umd+6−6
@@ -1,9 +1,9 @@
1−---
2−navhome: /docs/
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'5'
3−title: Clojure
4+ title/'Clojure'
4−sort: 5
5+ ==
5−next: true
6+;>
6−---
7
7
8# Clojure
8# Clojure
9
9
docs/tutorials/nock/implementations/csharp.umd+6−6
@@ -1,9 +1,9 @@
1−---
2−navhome: /docs/
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'12'
3−title: C#
4+ title/'C#'
4−sort: 12
5+ ==
5−next: true
6+;>
6−---
7
7
8# C#
8# C#
9
9
docs/tutorials/nock/implementations/groovy.umd+6−6
@@ -1,9 +1,9 @@
1−---
2−navhome: /docs/
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'7'
3−title: Groovy
4+ title/'Groovy'
4−sort: 7
5+ ==
5−next: true
6+;>
6−---
7
7
8# Groovy
8# Groovy
9
9
docs/tutorials/nock/implementations/haskell.umd+6−6
@@ -1,9 +1,9 @@
1−---
2−navhome: /docs/
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'3'
3−title: Haskell
4+ title/'Haskell'
4−sort: 3
5+ ==
5−next: true
6+;>
6−---
7
7
8# Haskell
8# Haskell
9
9
docs/tutorials/nock/implementations/hoon.umd+6−5
@@ -1,8 +1,9 @@
1−---
2−navhome: /docs/
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'11'
3−title: Hoon
4+ title/'Hoon'
4−sort: 11
5+ ==
5−---
6+;>
6
7
7# Hoon
8# Hoon
8
9
docs/tutorials/nock/implementations/javascript.umd+7−7
@@ -1,15 +1,15 @@
1−---
2−navhome: /docs/
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'9'
3−title: Javascript
4+ title/'Javascript'
4−sort: 9
5+ ==
5−next: true
6+;>
6−---
7
7
8# Javascript
8# Javascript
9
9
10From [Joe Bryan](https://github.com/joemfb/nock.js/blob/master/nock.js):
10From [Joe Bryan](https://github.com/joemfb/nock.js/blob/master/nock.js):
11
11
12−```js
12+```
13(function (self, factory) {
13(function (self, factory) {
14 'use strict'
14 'use strict'
15
15
docs/tutorials/nock/implementations/python.umd+6−6
@@ -1,9 +1,9 @@
1−---
2−navhome: /docs/
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'1'
3−title: Python
4+ title/'Python'
4−sort: 1
5+ ==
5−next: true
6+;>
6−---
7
7
8# Python
8# Python
9
9
docs/tutorials/nock/implementations/ruby.umd+6−6
@@ -1,9 +1,9 @@
1−---
2−navhome: /docs/
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'2'
3−title: Ruby
4+ title/'Ruby'
4−sort: 2
5+ ==
5−next: true
6+;>
6−---
7
7
8# Ruby
8# Ruby
9
9
docs/tutorials/nock/implementations/scala.umd+32−30
@@ -1,11 +1,11 @@
1−---
2−navhome: /docs/
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'4'
3−title: Scala
4+ title/'Scala'
4−sort: 4
5+ ==
5−next: true
6+;>
6−---
7
7
8−# Scala
8+# Scala
9
9
10From [Steve Randy Waldman](https://github.com/swaldman/nnnock/blob/master/src/main/scala/com/mchange/sc/v1/nnnock/package.scala):
10From [Steve Randy Waldman](https://github.com/swaldman/nnnock/blob/master/src/main/scala/com/mchange/sc/v1/nnnock/package.scala):
11
11
@@ -20,12 +20,13 @@ package object nnnock {
20
20
21 def nock( a : Noun ) : Noun = *(a)
21 def nock( a : Noun ) : Noun = *(a)
22
22
23+
23 object Cell {
24 object Cell {
24 private def apply( nl : List[Noun] ) : Cell = {
25 private def apply( nl : List[Noun] ) : Cell = {
25 nl match {
26 nl match {
26− case a :: b :: Nil => Cell(a, b);
27+ case a :: b :: Nil => Cell(a, b);
27− case a :: b :: c :: Nil => Cell(a, Cell(b, c));
28+ case a :: b :: c :: Nil => Cell(a, Cell(b, c));
28− case a :: b :: c :: tail => Cell(a, this.apply( b :: c :: tail ) );
29+ case a :: b :: c :: tail => Cell(a, this.apply( b :: c :: tail ) );
29 }
30 }
30 }
31 }
31 def apply(a : Noun, b : Noun, tail : Noun*) : Cell = apply( a :: b :: tail.toList );
32 def apply(a : Noun, b : Noun, tail : Noun*) : Cell = apply( a :: b :: tail.toList );
@@ -59,28 +60,29 @@ package object nnnock {
59 /(Cell(num, /(Cell(a, b))));
60 /(Cell(num, /(Cell(a, b))));
60 }
61 }
61 case a => /( a ); //intentional endless spin
62 case a => /( a ); //intentional endless spin
62− }
63+ }
64+
63
65
64− def *( noun : Noun ) : Noun = noun match {
66+ def *( noun : Noun ) : Noun = noun match {
65− case Cell( a, Cell(Cell(b, c), d) ) => Cell( *(Cell(a,b,c)), *(Cell(a,d)) );
67+ case Cell( a, Cell(Cell(b, c), d) ) => Cell( *(Cell(a,b,c)), *(Cell(a,d)) );
66− case Cell( a, Cell(Atom(value), tail) ) => {
68+ case Cell( a, Cell(Atom(value), tail) ) => {
67− (value, tail) match {
69+ (value, tail) match {
68− case (0, b) => /( Cell(b, a) );
70+ case (0, b) => /( Cell(b, a) );
69− case (1, b) => b;
71+ case (1, b) => b;
70− case (2, Cell(b, c)) => *( Cell( *( Cell(a,b) ), *( Cell(a,c) ) ) );
72+ case (2, Cell(b, c)) => *( Cell( *( Cell(a,b) ), *( Cell(a,c) ) ) );
71− case (3, b) => ?( *( Cell(a,b) ) );
73+ case (3, b) => ?( *( Cell(a,b) ) );
72− case (4, b) => plus( *( Cell(a,b) ) );
74+ case (4, b) => plus( *( Cell(a,b) ) );
73− case (5, b) => heq( *( Cell(a,b) ) );
75+ case (5, b) => heq( *( Cell(a,b) ) );
74− case (6, Cell(b, Cell(c, d))) => *( Cell(a,2,Cell(0,1),2,Cell(1,c,d),Cell(1,0),2,Cell(1,2,3),Cell(1,0),4,4,b) ); //wtf?
76+ case (6, Cell(b, Cell(c, d))) => *( Cell(a,2,Cell(0,1),2,Cell(1,c,d),Cell(1,0),2,Cell(1,2,3),Cell(1,0),4,4,b) ); //wtf?
75− case (7, Cell(b, c)) => *( Cell(a,2,b,1,c) );
77+ case (7, Cell(b, c)) => *( Cell(a,2,b,1,c) );
76− case (8, Cell(b, c)) => *( Cell(a,7,Cell(Cell(7,Cell(0,1),b),0,1),c) ); //wtf2
78+ case (8, Cell(b, c)) => *( Cell(a,7,Cell(Cell(7,Cell(0,1),b),0,1),c) ); //wtf2
77− case (9, Cell(b, c)) => *( Cell(a,7,c,2,Cell(0,1),0,b) );
79+ case (9, Cell(b, c)) => *( Cell(a,7,c,2,Cell(0,1),0,b) );
78− case (10, Cell(Cell(b,c),d)) => *( Cell(a,8,c,7,Cell(0,3),d) );
80+ case (10, Cell(Cell(b,c),d)) => *( Cell(a,8,c,7,Cell(0,3),d) );
79− case (10, Cell(b, c)) => *( Cell(a,c) );
81+ case (10, Cell(b, c)) => *( Cell(a,c) );
80− case _ => *( noun ); //intentional endless spin
82+ case _ => *( noun ); //intentional endless spin
83+ }
81 }
84 }
85+ case a => *( a ); //intentional endless spin
82 }
86 }
83− case a => *( a ); //intentional endless spin
84 }
87 }
85−}
86```
88```
docs/tutorials/nock/implementations/scheme.umd+6−6
@@ -1,9 +1,9 @@
1−---
2−navhome: /docs/
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'8'
3−title: Scheme
4+ title/'Scheme'
4−sort: 8
5+ ==
5−next: true
6+;>
6−---
7
7
8# Scheme
8# Scheme
9
9
docs/tutorials/nock/implementations/swift.umd+7−7
@@ -1,13 +1,13 @@
1−---
2−navhome: /docs/
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'10'
3−title: Swift
4+ title/'Swift'
4−sort: 10
5+ ==
5−next: true
6+;>
6−---
7
7
8# Swift
8# Swift
9
9
10−```swift
10+```
11import Foundation
11import Foundation
12// 1 :: A noun is an atom or a cell.
12// 1 :: A noun is an atom or a cell.
13// 2 :: An atom is a natural number.
13// 2 :: An atom is a natural number.