Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Concurrent-computing/LFE/concurrent-computing.lfe
Normal file
26
Task/Concurrent-computing/LFE/concurrent-computing.lfe
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
;;;
|
||||
;;; This is a straight port of the Erlang version.
|
||||
;;;
|
||||
;;; You can run this under the LFE REPL as follows:
|
||||
;;;
|
||||
;;; (slurp "concurrent-computing.lfe")
|
||||
;;; (start)
|
||||
;;;
|
||||
(defmodule concurrent-computing
|
||||
(export (start 0)))
|
||||
|
||||
(defun start ()
|
||||
(lc ((<- word '("Enjoy" "Rosetta" "Code")))
|
||||
(spawn (lambda () (say (self) word))))
|
||||
(wait 2)
|
||||
'ok)
|
||||
|
||||
(defun say (pid word)
|
||||
(lfe_io:format "~p~n" (list word))
|
||||
(! pid 'done))
|
||||
|
||||
(defun wait (n)
|
||||
(receive
|
||||
('done (case n
|
||||
(0 0)
|
||||
(_n (wait (- n 1)))))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue