PDF

Transkrypt

PDF
lists:seq(2,5) → (lists:seq 2 5)
2+3 → +(2,3) → (+ 2 3)
lists:map(fun (X) -> 2*(X+3) end, [9, 4, 3]).
(lists:map (lambda (x) (* 2 (+ 3 x))) (list 9 4 3))
io:format("~s, ~s!~n", ["Witaj", "swiecie"]).
(io:format "~s, ~s!~n" '("Witaj" "swiecie"))
???
(lists:seq 2 8)
zwraca
(2 3 4 5 6 7 8)
lists:seq(2,8) → (lists:seq 2 8)
[2,3,4,5,6,7,8] → (2 3 4 5 6 7 8)
Wywołanie funkcji i zwrócone liczby
są wyrażane przez tą samą
strukturę danych- LISTĘ
Czy można odpiąć głowę od
wywołania funkcji i dokleić inną?
(let
(((cons _ argumenty) '(+ 8 3 2)))
(apply #'-/3 argumenty))
(defmacro podmien (a) (cons '- (cdr a)))
(podmien (+ 8 3 2))
Przerwa na kotka
Ciekawoski
●
●
●
●
Robert Virding stworzył LFE w 2007r. bo chciał
zobaczyć jak wyglądałby Lisp w Erlangu
Jego build-tool oparty na rebarze (lfetool) nie
działa (u mnie)
LFE nie jest używany poza projektami
hobbistycznymi
Licencja: Apache License 2.0
(defmodule messenger-back
(export (print-result 0) (send-message 2)))
(defun print-result ()
(receive
((tuple pid msg)
(io:format "Received message: '~s'~n" (list msg))
(io:format "Sending message to process ~p ...~n" (list pid))
(! pid (tuple msg))
(print-result))))
(defun send-message (calling-pid msg)
(let ((spawned-pid (spawn 'messenger-back 'print-result ())))
(! spawned-pid (tuple calling-pid msg))))
----------------------------> (c "messenger-back.lfe")
> (: messenger-back send-message (self) "Witam!")

Podobne dokumenty