Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
14
Task/Catamorphism/Prolog/catamorphism.pro
Normal file
14
Task/Catamorphism/Prolog/catamorphism.pro
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
:- use_module(library(lambda)).
|
||||
|
||||
% foldl is now a predicate of SWI-Prolog 6.3.1
|
||||
%
|
||||
catamorphism :-
|
||||
numlist(1,10,L),
|
||||
foldl(\XS^YS^ZS^(ZS is XS+YS), L, 0, Sum),
|
||||
format('Sum of ~w is ~w~n', [L, Sum]),
|
||||
foldl(\XP^YP^ZP^(ZP is XP*YP), L, 1, Prod),
|
||||
format('Prod of ~w is ~w~n', [L, Prod]),
|
||||
string_to_list(LV, ""),
|
||||
foldl(\XC^YC^ZC^(string_to_atom(XS, XC),string_concat(YC,XS,ZC)),
|
||||
L, LV, Concat),
|
||||
format('Concat of ~w is ~w~n', [L, Concat]).
|
||||
Loading…
Add table
Add a link
Reference in a new issue