on master help sign in
nock implementations converted to umd
commiteda2a8391ef82c61e7b8ec5c047f5dc317e52b40 authorjoshuareagan <joshuareagan@gmail.com> dateMon 24 Sep 2018, 15:37 (8 years ago) parentece6841
12 files changed+100−97
docs/tutorials/nock/implementations/c.umd+6−6 docs/tutorials/nock/implementations/clojure.umd+6−6 docs/tutorials/nock/implementations/csharp.umd+6−6 docs/tutorials/nock/implementations/groovy.umd+6−6 docs/tutorials/nock/implementations/haskell.umd+6−6 docs/tutorials/nock/implementations/hoon.umd+6−5 docs/tutorials/nock/implementations/javascript.umd+7−7 docs/tutorials/nock/implementations/python.umd+6−6 docs/tutorials/nock/implementations/ruby.umd+6−6 docs/tutorials/nock/implementations/scala.umd+32−30 docs/tutorials/nock/implementations/scheme.umd+6−6 docs/tutorials/nock/implementations/swift.umd+7−7
docs/tutorials/nock/implementations/c.umd+6−6
@@ -1,9 +1,9 @@
1−---
2−navhome: /docs/
3−title: C
4−sort: 6
5−next: true
6−---
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'6'
4+ title/'C'
5+ ==
6+;>
77
88# C
99
docs/tutorials/nock/implementations/clojure.umd+6−6
@@ -1,9 +1,9 @@
1−---
2−navhome: /docs/
3−title: Clojure
4−sort: 5
5−next: true
6−---
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'5'
4+ title/'Clojure'
5+ ==
6+;>
77
88# Clojure
99
docs/tutorials/nock/implementations/csharp.umd+6−6
@@ -1,9 +1,9 @@
1−---
2−navhome: /docs/
3−title: C#
4−sort: 12
5−next: true
6−---
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'12'
4+ title/'C#'
5+ ==
6+;>
77
88# C#
99
docs/tutorials/nock/implementations/groovy.umd+6−6
@@ -1,9 +1,9 @@
1−---
2−navhome: /docs/
3−title: Groovy
4−sort: 7
5−next: true
6−---
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'7'
4+ title/'Groovy'
5+ ==
6+;>
77
88# Groovy
99
docs/tutorials/nock/implementations/haskell.umd+6−6
@@ -1,9 +1,9 @@
1−---
2−navhome: /docs/
3−title: Haskell
4−sort: 3
5−next: true
6−---
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'3'
4+ title/'Haskell'
5+ ==
6+;>
77
88# Haskell
99
docs/tutorials/nock/implementations/hoon.umd+6−5
@@ -1,8 +1,9 @@
1−---
2−navhome: /docs/
3−title: Hoon
4−sort: 11
5−---
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'11'
4+ title/'Hoon'
5+ ==
6+;>
67
78# Hoon
89
docs/tutorials/nock/implementations/javascript.umd+7−7
@@ -1,15 +1,15 @@
1−---
2−navhome: /docs/
3−title: Javascript
4−sort: 9
5−next: true
6−---
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'9'
4+ title/'Javascript'
5+ ==
6+;>
77
88# Javascript
99
1010From [Joe Bryan](https://github.com/joemfb/nock.js/blob/master/nock.js):
1111
12−```js
12+```
1313(function (self, factory) {
1414 'use strict'
1515
docs/tutorials/nock/implementations/python.umd+6−6
@@ -1,9 +1,9 @@
1−---
2−navhome: /docs/
3−title: Python
4−sort: 1
5−next: true
6−---
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'1'
4+ title/'Python'
5+ ==
6+;>
77
88# Python
99
docs/tutorials/nock/implementations/ruby.umd+6−6
@@ -1,9 +1,9 @@
1−---
2−navhome: /docs/
3−title: Ruby
4−sort: 2
5−next: true
6−---
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'2'
4+ title/'Ruby'
5+ ==
6+;>
77
88# Ruby
99
docs/tutorials/nock/implementations/scala.umd+32−30
@@ -1,11 +1,11 @@
1−---
2−navhome: /docs/
3−title: Scala
4−sort: 4
5−next: true
6−---
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'4'
4+ title/'Scala'
5+ ==
6+;>
77
8−# Scala
8+# Scala
99
1010From [Steve Randy Waldman](https://github.com/swaldman/nnnock/blob/master/src/main/scala/com/mchange/sc/v1/nnnock/package.scala):
1111
@@ -20,12 +20,13 @@ package object nnnock {
2020
2121 def nock( a : Noun ) : Noun = *(a)
2222
23+
2324 object Cell {
2425 private def apply( nl : List[Noun] ) : Cell = {
2526 nl match {
26− case a :: b :: Nil => Cell(a, b);
27− case a :: b :: c :: Nil => Cell(a, Cell(b, c));
28− case a :: b :: c :: tail => Cell(a, this.apply( b :: c :: tail ) );
27+ case a :: b :: Nil => Cell(a, b);
28+ case a :: b :: c :: Nil => Cell(a, Cell(b, c));
29+ case a :: b :: c :: tail => Cell(a, this.apply( b :: c :: tail ) );
2930 }
3031 }
3132 def apply(a : Noun, b : Noun, tail : Noun*) : Cell = apply( a :: b :: tail.toList );
@@ -59,28 +60,29 @@ package object nnnock {
5960 /(Cell(num, /(Cell(a, b))));
6061 }
6162 case a => /( a ); //intentional endless spin
62− }
63+ }
64+
6365
64− def *( noun : Noun ) : Noun = noun match {
65− case Cell( a, Cell(Cell(b, c), d) ) => Cell( *(Cell(a,b,c)), *(Cell(a,d)) );
66− case Cell( a, Cell(Atom(value), tail) ) => {
67− (value, tail) match {
68− case (0, b) => /( Cell(b, a) );
69− case (1, b) => b;
70− case (2, Cell(b, c)) => *( Cell( *( Cell(a,b) ), *( Cell(a,c) ) ) );
71− case (3, b) => ?( *( Cell(a,b) ) );
72− case (4, b) => plus( *( Cell(a,b) ) );
73− 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?
75− 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
77− 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) );
79− case (10, Cell(b, c)) => *( Cell(a,c) );
80− case _ => *( noun ); //intentional endless spin
66+ def *( noun : Noun ) : Noun = noun match {
67+ case Cell( a, Cell(Cell(b, c), d) ) => Cell( *(Cell(a,b,c)), *(Cell(a,d)) );
68+ case Cell( a, Cell(Atom(value), tail) ) => {
69+ (value, tail) match {
70+ case (0, b) => /( Cell(b, a) );
71+ case (1, b) => b;
72+ case (2, Cell(b, c)) => *( Cell( *( Cell(a,b) ), *( Cell(a,c) ) ) );
73+ case (3, b) => ?( *( Cell(a,b) ) );
74+ case (4, b) => plus( *( Cell(a,b) ) );
75+ case (5, b) => heq( *( Cell(a,b) ) );
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?
77+ case (7, Cell(b, c)) => *( Cell(a,2,b,1,c) );
78+ case (8, Cell(b, c)) => *( Cell(a,7,Cell(Cell(7,Cell(0,1),b),0,1),c) ); //wtf2
79+ case (9, Cell(b, c)) => *( Cell(a,7,c,2,Cell(0,1),0,b) );
80+ case (10, Cell(Cell(b,c),d)) => *( Cell(a,8,c,7,Cell(0,3),d) );
81+ case (10, Cell(b, c)) => *( Cell(a,c) );
82+ case _ => *( noun ); //intentional endless spin
83+ }
8184 }
85+ case a => *( a ); //intentional endless spin
8286 }
83− case a => *( a ); //intentional endless spin
8487 }
85−}
8688```
docs/tutorials/nock/implementations/scheme.umd+6−6
@@ -1,9 +1,9 @@
1−---
2−navhome: /docs/
3−title: Scheme
4−sort: 8
5−next: true
6−---
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'8'
4+ title/'Scheme'
5+ ==
6+;>
77
88# Scheme
99
docs/tutorials/nock/implementations/swift.umd+7−7
@@ -1,13 +1,13 @@
1−---
2−navhome: /docs/
3−title: Swift
4−sort: 10
5−next: true
6−---
1+:- :~ navhome/'/docs/'
2+ next/'true'
3+ sort/'10'
4+ title/'Swift'
5+ ==
6+;>
77
88# Swift
99
10−```swift
10+```
1111import Foundation
1212// 1 :: A noun is an atom or a cell.
1313// 2 :: An atom is a natural number.