Coder Social home page Coder Social logo

jargon-nock's Introduction

A noun is defined as either an atom, which is defined as a natural number, or a cell, which is defined as an ordered pair of nouns. A pair has exactly two items in it.

[a b] is a way to write a cell that consists of two nouns, a and b. In a cell [a b], we say the head of the cell is a and the tail is b. If you have a cell [a b] where b is [c d], that the tail of [a b] is still b. If you have a cell [a b] where a is [e f], that the tail of [a b] is still a.
[a [b c]] is a way to write a cell that consists of a noun a in the head and a tail consisting of a cell containing b and c, which are also nouns.
The previous expression can be written as [a b c] with an implicit right association, and is the preferred way to write the expression. Most expressions are written with implicit right association.

Let's define a few logical operators that may be applied to input nouns to provide a resulting output noun:

We define the noun type logical operator, ? that can be applied to any noun 'a'.
?a will evaluate to 0 for a cell, and 1 for an atom.

We define the increment logical operator, + that can be applied to any noun 'a'.
+a will evaluate to (1 + a) if a is an atom, and will crash if a is a cell.

We define the equivalence logical operator, = that can be applied to any two nouns.

=[a a] will evaluate to 0, and =[a b] where b is a different noun than a will evaluate to 1.
In our defined operations, when the two input nouns are the same, the equivalence operator evaluates to 0, and when they are different the equivalence operator evaluates to 1.

We define the / logical operator that may be applied to nouns:
/(1 a) will output a, and may be applied to any noun.
/(2 [a b]) will output a (the head of the cell), and may only be applied to a cell. If it is applied to an atom, crash.
/(3 [a b]) will output b (the tail of the cell), and may only be applied to a cell. If it is applied to an atom, crash.
If the head atom is greater than 3, will recursively apply the '/' operator using the following reduction:
/(2a b) will reduce to /(2 /(a b)) which will then be further evaluated until it reaches one of the base cases I described to you.
/((2a + 1) b) will reduce to /(3 /(a b)) which will then be further evaluated until it reaches one of the base cases I described to you.


We define the Nock function as a function that takes an input noun (described as a cell of [subject formula]), and returns an output noun or crashes. The Nock function is defined below.

A valid Nock formula is always a cell. If the head of the formula is a cell, Nock treats both head and tail as formulas, evaluates each against the subject, and produces the cell of their products. If the head of the formula is an atom, it's an instruction from 0 to 5. If the head of the formula is higher than 5, it is not valid. Invalid Nock instructions result in a crash.

Nock(a) evaluates to *a.
In the following examples, a is a subject and the following cell is the formula:
*[a 0 b] evaluates to /(b a)
*[a 1 b] evaluates to b
*[a 2 b c] evaluates to *[*[a b] *[a c]]. (Note that the first subformula generates a new subject, the second subformula generates a new formula, and then the old subject and formula are discarded. Then, the new formula is evaluated against the new subject as follows: *[new-subject new-formula] ). Remember, 1. compute new subject, 2. compute new formula, 3. run new formula against new subject.
*[a 3 b evaluates to ?*[a b]
*[a 4 b] evaluates to +*[a b]
*[a 5 b c] evaluates to =[*[a b] *[a c]]


Please evaluate the following Nock expression: [[55 0 1] [2 [0 2] [0 3]]]

jargon-nock's People

Contributors

tacryt-socryp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

risruc-habteb

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.