Skip to main content
1 of 2
Leo
  • 12.9k
  • 1
  • 33
  • 63

Husk, 16 bytes

ΘGȯ`J₁J',e₁₀ "() 

Try it online!

Trees or arbitrarily nested lists are not a thing in Husk, so this builds a string representation of the tree, where a leaf is represented as "()" and a node with a Left child L and a right child R is represented as "(L,R)".

Returns the infinite list of Fibonacci trees, which get printed one per line.

Explanation

I've started from what's probably the second shortest way of computing Fibonacci numbers in Husk (the shortest being the builtin İf):

ΘG+1₀ 

Try it online!

This puts a 0 at the beginning of the sequence (with Θ), then scans (G) recursively the same list with +, starting from 1 and summing every time the last result to the next element in the list.

With this, we just need to alter the starting values and the + operator to make it compute Fibonacci trees.

The 1 now becomes "()" (moved to the next line so we can reuse it later) and the 0 turns into "" automagically thanks to Husk understanding that the list is now a list of strings rather than numbers. The operator that generates a new tree from the two previous ones is a bit more complex:

`J₁J',e Input: left subtree "L", right subtree "R" e Put the two trees together in a list ["L","R"] J', Join the list of strings with a comma "L,R" `J Flipped join: use this string to join the list ₁ "()" Output: "(L,R)" 
Leo
  • 12.9k
  • 1
  • 33
  • 63