[Haskell-beginners] case statement
Imants Cekusins
imantc at gmail.com
Tue Jul 7 14:06:47 UTC 2015
Thank you Brandon.
Well in Erlang you can mix and match patterns with outer scope
variables. It is very handy, I agree. Here is an example.
You can try this code in browser here:
http://tryerl.seriyps.ru/#id=e3f2
% -*- coding: utf8 -*-
-module(main).
-export([main/0]).
main() ->
check(2),
check({other,4}).
check(X)->
A1 = 1,
A2 = 2,
case X of
A1 -> io:format("A1~n");
A2 -> io:format("A2~n");
{other,X1} -> io:format("~p~n",[X1])
end.
More information about the Beginners
mailing list