Shoggoth
kiwifarms.net
- Joined
- Aug 9, 2019
Sometimes I think Hoon is one of the only mistakes in Urbit. I hate syntax. On the other hand, unlike other languages, Hoon's syntax in unambiguous and regular, so it's trivial to parse (as if).I'm not smart enough to understand any of this but it looks interesting, haven't seen anything like the programming language either.
Code:|= end=@ :: 1 =/ count=@ 1 :: 2 |- :: 3 ^- (list @) :: 4 ?: =(end count) :: 5 ~ :: 6 :- count :: 7 $(count (add 1 count))
I can sort of read it. The terms have been translated to human speak because if I'm calling it core, gate, arm, subject, etc, I get a feeling someone on the forum will find me and put a bomb under my car
1. |= function, receives one parameter, end, of type atom (@) which is a number
2. =/ local parameter count of type atom initialized to 1
3. function body starts
4. I think this is a return type hint. List of numbers
5. Branch. if end == count, nil, else
6 :- construct a cell (like cons in lisp) out of count and
7 $ recur with count bound to count++
If I read this correctly, this builds up a list of numbers from 1 to end.
Translated to Scheme:
Code:
(define (foo end)
(define (bar count)
(if (= count end)
'()
(cons count (bar (+ 1 count)))))
(bar 1))
scheme@(guile-user)> (foo 5)
$3 = (1 2 3 4)
Last edited: