Help docs : Puzzle and Solutions

Hi,

I Need an explanation please for this example given in the tutorial :

$ brun ‘(+ 2 5)’ ‘(40 50)’
90

What I understand is the puzzle ( first parenthesis expression ) is used to do operations on the solution ( 2nd parenthesis expression )
So, what is the action of 2 and 5 in the puzzle ?
And why does it return 90 ?


Edit :

I understand another thing that is unquoted integers are variable environment.
So it would be an addition of 2 in the binary tree and 5 ?
But to me there is only 3 elements in the binary tree : 1 would be (40 50) ; 2 would be 40 ; and 3 would be 50 ? …
Help would be appreciated thanks :slight_smile:

Okay so if you have () it’s a list.
1 would be the entire list (tree)
But then it gets more complicated, but the tree is shown here in the documentation 1 - CLVM Basics | Chialisp
So the (+ 2 5) is an addition by integer reference of variable (list), position in the tree 2 and 5, and because lists are to some degree recursive, first element on left leaf, then right leaf is the ‘rest of the list’ as it’s own new tree, so 3 would be the root of ‘the rest’ and 5 would be the first element, the 7th element would be the ‘rest’ of any more elements.
Say the list was (40 50 60 70)
then 1 would be (40 50 60 70)
2 (40)
3 (50 60 70)
5 (50)
7 (60 70)
11 (60)
30 (70)

Ok, more clear to me now , actually I tried to recover all the tree with brun, and what I see is :

1 : (40 50) => actually is (40 . ( 50 . () ) )
2: 40 => without parenthesis , it’s an atom, right ?
3: (50) => with prenthesis , still a list composed with con box (50 . () )
5: 50 => atom
7 : () => last atom

Because all lists are composed of con boxes and the last con box of the list ends with null ! :smiley:

Cool, i’m not an expert so check the docs rather than take my word for it, i’m likely wrong in some spots.

Thanks you helped me :slight_smile:

1 Like