Тёмный

Generating infinite sequences in Elixir with Stream.unfold/2 

German Velasco
Подписаться 1,5 тыс.
Просмотров 426
50% 1

Ever want to create an infinite sequence?
Me neither. But it’s really cool to see how we can do that with Stream.unfold/2.
You can think of unfold as something like the opposite of reduce. When we reduce, we grab a list (or sequence) and iterate over the values to generate a final value. With unfold, we start with a single value (the seed) and then generate a sequence by applying a transformation on each subsequent value.
Check out more at www.elixirstreams.com/tips/cr...

Наука

Опубликовано:

 

28 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 2   
@EugenKandakov
@EugenKandakov 11 месяцев назад
Good stuff! Never used unfold before instead I always created some kind of fixed ranges which felt weird. This is the syntactic sugar I looked for thanks. btw. this should be enough to generate the fib seq. You only need to match for the starting 0 and the rest is just adding the two values for the next one. 0 -> {0, {0, 1}} {ix, iy} -> {iy, {iy, ix + iy}}
@germanvelasco
@germanvelasco 11 месяцев назад
Yeap, thanks for the tip on the fib sequence. I noticed that after I edited the video. Didn't feel like redoing the whole thing 😅.
Далее
ExUnit. It's an app!
1:19
Просмотров 299
LISA - ROCKSTAR (Official Music Video)
02:48
Просмотров 34 млн
Ummmm We "HAIR" You!
00:59
Просмотров 3,1 млн
A Simpler Way to See Results
19:17
Просмотров 98 тыс.
Why Does Scrum Make Programmers HATE Coding?
16:14
Просмотров 496 тыс.
All Rust string types explained
22:13
Просмотров 151 тыс.
Use Arc Instead of Vec
15:21
Просмотров 136 тыс.
Mojo🔥: a deep dive on ownership with Chris Lattner
48:50
Encoding the Fibonacci Sequence Into Music
2:40
Просмотров 7 млн
Clash of Clans Most Unbelievable Bases...
8:01
Просмотров 7 млн
9 Game Endings Almost No One Has Ever Seen
12:12
Просмотров 26 млн
Самый СТРАННЫЙ смартфон!
0:57
Просмотров 32 тыс.