# How to make an infinate nested list

in python, there is

``````>>> a=[]
>>> a.append(a)
>>> a
[[...]]
``````

how to implement this in elixir?

In Elixir this bug is fixed

5 Likes

feature? bug?

Can you show what you’re actually trying to do? If you want a collection that emits an infinite number of values there is `Stream.repeatedly`. Beyond that, this feels like an X / Y problem.

2 Likes
``````def infinite(list \\ []) do
[infinite(list)]
end

infinite()
``````

Just for fun. Didn’t test it. It will take infinite time before it returns. And I expect the output to be 42.

1 Like

Closest thing I can think of would be a function that is infinitely callable, like this:

``````f = fn g -> fn -> g.(g) end end

h = f.(f)

h.().().().().().().().().()
``````
1 Like