Assignment 6Roll No: 20L-2367Question #1:fib(0, ).fib(1, [1,0]).fib(N, [R,X,Y|Zs]) :-N > 1,N1 is N - 1,fib(N1, [X,Y|Zs]),R is X + Y.Question #2:move(1,X,Y,_) :-write('Move top disk from '),write(X),write(' to '),
PART D::- use_module(library(clpfd)).nums_evensumsq(,0).nums_evensumsq([X|Xs],S0) :-X mod 2 #= 0,nums_evensumsq(Xs,S1),S0 #= S1 + X * X.nums_evensumsq([X|Xs],S) :-X mod 2 #= 1,nums_evensumsq(Xs,S).
Question #4:ADA was the easiest among LISP, ADA and PROLOG. Because it’s syntax is most related tothe modern High level programming languages like C or C++, Java etc.Lisp is a homoiconic language, which means that the code is expressed in the same form (s-expressions) as data structures in the language. i.e. "code is data". This has big advantages ifyou are writing code that modifies/manipulates other code, e.g. genetic algorithms orsymbolic manipulation.Lisp's macro system makes it well suited for defining problem-specific DSLs. Most Lisp developers effectively "extend the language" to do what they need.Again the fact that Lisp is homoiconic helps enormously here.There is some historicalconnection, in that Lisp became popular at about the same time as a lot of the early AIresearch. Lisp works pretty well as a functional programming language. This is quite a gooddomain fit for AI (where you are often just trying to get the machine to learn how toproduce the correct output for a given input). Subjective view: Lisp seems to appeal topeople with a mathematical mindset, which happens to be exactly whet you need for a lotof modern AI.....this is possible due to the fact that Lisp is pretty closely related to theuntyped lambda calculus.