User Tools

Site Tools


cs326:lab3

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cs326:lab3 [2021/09/28 16:13]
scarl
cs326:lab3 [2021/09/28 16:26] (current)
scarl
Line 3: Line 3:
 The purpose of this exercise is to gain experience using Lazy Streams. The purpose of this exercise is to gain experience using Lazy Streams.
  
-In this lab, first work through ​each example from the Elixir Guide regarding [[https://​elixir-lang.org/​getting-started/​enumerables-and-streams.html#​the-pipe-operator|the pipe operator]] and [[https://​elixir-lang.org/​getting-started/​enumerables-and-streams.html#​streams|streams]].+As a warmup, first work through ​the example from the Elixir Guide regarding [[https://​elixir-lang.org/​getting-started/​enumerables-and-streams.html#​the-pipe-operator|the pipe operator]] and the first four here[[https://​elixir-lang.org/​getting-started/​enumerables-and-streams.html#​streams|streams]].
  
-Then, try each set of exercises in turn:+Then, try each set of exercises in turn, recording results and answering any questions:
  
   - This example from Chapter 10 of the text should work on Linux or MacOS. Try it and record the result:<​code>​File.read!("/​usr/​share/​dict/​words"​) |> String.split |> Enum.max_by(&​String.length/​1)</​code>​   - This example from Chapter 10 of the text should work on Linux or MacOS. Try it and record the result:<​code>​File.read!("/​usr/​share/​dict/​words"​) |> String.split |> Enum.max_by(&​String.length/​1)</​code>​
Line 21: Line 21:
     - Call ''​speaker = printer |> Stream.each(&​Countdown.say/​1)''​ which is a surprise (if it works!)     - Call ''​speaker = printer |> Stream.each(&​Countdown.say/​1)''​ which is a surprise (if it works!)
     - Now ask for a certain number of seconds, for example the next 5 seconds: ''​speaker |> Enum.take(5)''​     - Now ask for a certain number of seconds, for example the next 5 seconds: ''​speaker |> Enum.take(5)''​
-Explain what happens.+Do this several times in a row. Explain what happens.
  
cs326/lab3.1632863625.txt.gz ยท Last modified: 2021/09/28 16:13 by scarl