-
Notifications
You must be signed in to change notification settings - Fork 0
Home
bosky101 edited this page Sep 13, 2010
·
2 revisions
Usage
test()→
Eg1Input = [a,b,c,d,a],
Eg1MapFn = fun(a)→{a,"apple"};(b)→{b,"ball"};©→{c,"cat"};(d)→{d,"dog"};(e)→{e,"emul"};(Else)→“unexpected” end ,
Eg1ReduceFn = fun({_K,V})→ lists:foldl( fun(Char,Ctr)→ Ctr+1 end , 0, V) end,
{slot1,"11"},
{slot1,"1111"},
{slot2,"2"},
{slot3,"3"},
{slot3,"333"},
{slot3,"2"},
{slot2,"22"},
{slot1,"11"}
],
Eg2MapFn = fun({Slot,X})→
case string:to_integer(X) of
{error,}→
0;
{Numb,_}→
{Slot,Numb}
end
end,
Eg2ReduceFn = fun({K,V})→ lists:foldl( fun(X,Max) when Max=:= -1 → X;(X,Max)→
case Max > X of
true→ Max;
_ → X
end
end , -1, V) end,