Here is the second erlang program that I learnt today . . .
It is called rot 13
[addition: it works on number too by shifting by 5]
-module(rot13).
-export([start/0]).
%% run as "# erl -noshell -s rot13 <>
run(io:get_chars('', 1)).
run(eof) ->
init:stop();
run([Char]) ->
io:format("~c", [rot13(Char)]),
run(io:get_chars('', 1)).
rot13(X) when X >= $a,
X < $n; X >= $A,
X < $N ->
X+13;
rot13(X) when X >= $n,
X < ${; X >= $N,
X < $[ ->
X-13;
rot13(X) when X >= $0,
X < $5 ->
X+5;
rot13(X) when X >= $5,
X < $: ->
X-5;
rot13(X) ->
X.
Saturday, August 19, 2006
Introduction
Hello . . .
This is my first program in erlang
-module(l).
-export([len/1)]
len([])-> 0;
len([H|T]) ->
1 + len(T).
This is my first program in erlang
-module(l).
-export([len/1)]
len([])-> 0;
len([H|T]) ->
1 + len(T).
Subscribe to:
Posts (Atom)
