Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The text on the website linked to is entirely vacant and content-free. It doesn’t actually describe what the language is or how it works.


You're expecting to see some forest of information which isn't there, because it's such a little language.

At the top of https://treecalcul.us/specification/ you have 5 rules. Your (valid) program will match one of the left-hand-sides. To execute your program, turn whichever LHS your program is into its corresponding RHS. Keep doing that until you can't, and you'll be left with your final answer.

It also provides 2 reference interpreters (OCaml and JS) on the same page. Each interpreter is just a single recursive function 'apply' (which does what I described in the above paragraph). Note the 'match a with' section in the OCaml version. That's essentially the 5 rules from the top translated to OCaml. (I'm not sure why they're slightly different but there's probably a good reason).

The JS interpreter is harder to read ("length"? "push"? "pop"? these aren't in the spec above). My guess is that a machine-friendly translation was needed so that JS wouldn't die from recursing too deeply.

I clicked on 'runjs.app' link, looked at the examples at the bottom, and added my own.

    apply(_not, apply(_not, _true));
and sure enough it yielded

    [ [] ]
which is what it calls '_true':

    const _true = [[]];


There's a lot of precise, technical language, including a specification - that seems very contentful and specific to me.

The code examples seem very straightforward and compelling to me.

    > # Setup: Simple function on strings     
    > f = λa λb concat ["Hello ",a," ",b,"!"] 
    > f "Jane" "Doe"                          
    Hello Jane Doe!                           
This requires some familiarity with languages like Lisp or Forth to follow, but otherwise it's very straightforward.

    > # What else can we do with a function?  
    > g = f "Admiral"                         
    > # Try to invert it:                     
    > invert g "Hello Admiral 
    Alice!"         
    Alice
That's a really concise and impressive demo to me! I've never seen a language that can invert functions!


> I've never seen a language that can invert functions!

prolog




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: