What are you working on, Jow Forums?
Ara ara...
Previous thread:
What are you working on, Jow Forums?
Ara ara...
Previous thread:
Other urls found in this thread:
github.com
twitter.com
%bellTriangle.pl
addToEnd([],X,[X]) :- !.
addToEnd([Y | Resto],X,[Y | List]) :-
addToEnd(Resto,X,List).
nthElement(Index,Index,[X|_],X) :- !.
nthElement(Index,Count,[_|R],Res) :-
Count1 is Count+1,
nthElement(Index,Count1,R,Res).
computeNext(Index,Index,_,NewList,NewList) :- !.
computeNext(Index,Count,List,NewList,Res) :-
nthElement(Count,0,List,PrevUpperElement),
nthElement(Count,0,NewList,PrevElement),
Sum is PrevUpperElement + PrevElement,
addToEnd(NewList,Sum,NewList1),
write(Sum),write(' '),
Count1 is Count+1,
computeNext(Index,Count1,List,NewList1,Res).
bellTriangle(N,N,_) :- !.
bellTriangle(N,0,List):-
nthElement(0,0,List,X),
write(X),nl,
bellTriangle(N,1,List).
bellTriangle(N,Index,List) :-
Indexx is Index-1,
nthElement(Indexx,0,List,LastElement),
addToEnd([],LastElement,NewList),
write(LastElement),write(' '),
computeNext(Index,0,List,NewList,NewList1),nl,
Index1 is Index+1,
bellTriangle(N,Index1,NewList1).
main_bellTriangle(N) :- bellTriangle(N,0,[1]).
?- main_bellTriangle(5).
1
1 2
2 3 5
5 7 10 15
15 20 27 37 52
true .
Just finished Bell's Triangle in Prolog. Thought It would take me a lot longer desu.
>What are you working on, Jow Forums?
getting my first $300k job. already have:
[x] learned Haskell
[x] Anime avatar
Btw, Prolog is the most unreadable language in existence.
[x] based
[x] redpilled
Have you tried J?
Still don't know what monads are
Whenever you ask it on Jow Forums there is always some autist who will try to """explain""" it in obscure way so nobody can understand it. Guess he fells smarter that way
I will stay with my OOP lang and actually earn money
stop trying to learn and use them
Why does nobody here talk about Erlang?
look just imagine a burrito