DEV Community

Stream.unfold/2

Lasse Skindstad Ebert on October 13, 2019

In Elixir's core lib, there is a function called Stream.unfold/2. When I first started to have a look at this function, I could not make sense of ...
Collapse
 
mhspradlin profile image
Mitch Spradlin

I think the general term for what unfold/2 implements is an anamorphism, while fold is a catamorphism. There are other kinds of morphisms too - this page gives an overview (with fun mnemonics!): reasonablypolymorphic.com/blog/rec...

Collapse
 
lasseebert profile image
Lasse Skindstad Ebert

Thanks, didn't know those terms. I tried quick-reading the post you linked to, but I think it's the kind of post I need focus to read 😁 Goes to my reading list πŸ‘

Collapse
 
robertdober profile image
Robert Dober

I would not say that Stream.unfold is a bad name, however, for folks of my generation it is what we know as cons_stream from SIOCP

Collapse
 
lasseebert profile image
Lasse Skindstad Ebert

I didn't know that ☺️