10From [T.J. Corcoran](https://github.com/TJamesCorcoran/nock/blob/master/nock.rb):
15 str.scan(/\+|\=|\?|\/|\*|\[|\]|\d+/).each do |token|
20 ret = arr.is_a?(Array) ? [max_depth(arr[0]), max_depth(arr[1])].max + 1 : 1
25 depth = max_depth(arr)
29 min = 2 ** (depth - 1)
30 max = (2 ** depth) - 1
31 min.upto(max) { |axis|
37 return arr unless arr.is_a?(Array)
40 arr[size - 2] = [ arr[size - 2], arr.pop ]
42 arr = arr.map { |x| norm(x) }
46 arr.is_a?(Array) ? YES : NO
50 raise "not an atom" unless atom.is_a?(Fixnum)
55 raise "not pair" unless arr.is_a?(Array) && arr.size == 2
56 ( arr[0] == arr[1] ) ? YES : NO
59def slot(axis, arr, allow_error = true)
60 raise "axis on atom" unless arr.is_a?(Array)
61 return arr if axis == 1
62 return arr[0] if axis == 2
63 return arr[1] if axis == 3
64 return slot(2, slot(axis/2, arr)) if (axis %2) == 0
65 return slot(3, slot(axis/2, arr))
70 raise "error: nocking an atom" unless arr.is_a?(Array)
77 return [ nock( [ a, [b, c]]), nock( [a, d]) ]
91 nock( [ nock([a, b_primce]), nock([a, c]) ])
106 nock( norm([a, 2, [0, 1], 2, [1, c, d], [1, 0], 2, [1, 2, 3], [1, 0], 4, 4, b]) )
111 nock( norm ([a, 2, b_prime, 1, c]))
116 nock( norm ([a, 7, [[7, [0, 1], b_prime], 0, 1], c]))
121 nock( norm ([a, 7, c, 2, [0, 1], 0, b_prime]))
124 if wut(slot(2,b)) == TRUE
129 nock( norm ([a, 8, c, 7, [0, 3], d]))
133 nock( norm ([a, 10, [b, c]]))
136 raise "error: unknown opcode #{oper.inspect}"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list