User Tools

Site Tools


cs330_f2016:erlang1

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
Next revision Both sides next revision
cs330_f2016:erlang1 [2017/03/10 01:10]
dhart [Deliverables:]
cs330_f2016:erlang1 [2017/11/02 23:09]
corey [Preparation:]
Line 1: Line 1:
-**Note: Specs incomplete, proceed at own risk.** 
- 
 ====Objective:​==== ====Objective:​====
  
Line 9: Line 7:
 ====Preparation:​==== ====Preparation:​====
  
-Install Elixir on your own machine. Use Erlang OTP version 19.  Note that Erlang is available on all of the open-lab linux machines as ''/​usr/​bin/​erl''​.+Install Elixir on your own machine. Use Erlang OTP version 19 (or more recent versions).
  
 ---- ----
Line 15: Line 13:
 ====Deliverables:​==== ====Deliverables:​====
  
-Create a module named ''​Elxir_Intro''​ that contains the following functions:+Create a module named ''​Elixir_Intro''​ that contains the following functions:
   * ''​fib/​1''​   * ''​fib/​1''​
   * ''​area/​2''​   * ''​area/​2''​
Line 53: Line 51:
 def map(function,​ vals) do ... def map(function,​ vals) do ...
 </​code>​ </​code>​
-Map takes a function and a list vals and applies that function to each item in the list. Note that when using higher order functions in Elixir, you use ''&​Module.functionName/​arity''​ to pass it, and ''​functionName.(…)''​ to call it. Thus,to test it, the call should look like this ''​map(&​Module.functionName/​arity,​ list)''​.+Map takes a function and a list vals and applies that function to each item in the list. Note that when using higher order functions in Elixir, you use ''&​Module.functionName/​arity''​ to pass it, and ''​functionName.(…)''​ to call it. Thus,to test it, the call should look like this ''​map(&​Module.functionName/​arity,​ list)''​. For this lab, you can assume the arity of the function being passed in is 1.
  
 === quickSortServer === === quickSortServer ===
Line 61: Line 59:
 quickSortServer will start a simple server that will receive a list and sort it and send it to the caller. It should sort via a modified version of quickSort as discussed in class. quickSort will choose the pivot randomly, and you will need to implement the new pivot functionality. The module ''​random''​ function '':​random.uniform(N)''​ will be useful for this, as well as '':​lists.nth(N,​ List)''​ quickSortServer will start a simple server that will receive a list and sort it and send it to the caller. It should sort via a modified version of quickSort as discussed in class. quickSort will choose the pivot randomly, and you will need to implement the new pivot functionality. The module ''​random''​ function '':​random.uniform(N)''​ will be useful for this, as well as '':​lists.nth(N,​ List)''​
  
-It might be helpful to set up a simple client module like this:+Remember that starting a new process would look like ''​pid = spawn &​Elixir_Intro.quickSortServer/​0''​ 
 + 
 +To test your quickSortServer(),​ it might be helpful to set up a simple client module like this:
 <code python> <code python>
 defmodule Client do defmodule Client do
-    def call(pid,nums) do+    def callServer(pid,nums) do
         send(pid, {nums, self()})         send(pid, {nums, self()})
-     ​listen + listen 
- end+    end
   
     def listen do     def listen do
         receive do         receive do
- {sorted, pid} -> sorted+     ​{sorted, pid} -> sorted
  end  end
     end     end
cs330_f2016/erlang1.txt · Last modified: 2021/06/30 23:42 (external edit)