You are on page 1of 7

LISP Advance Assignment

Q.1. What are the 3 AI based Programming Languages?  Highlight their importance by
comparison of history, functions supported, style of programming and so on.  (like to see best
possible answer)

AI based Programming Languages

1. PYTHON

Python is considered to be in the first place in the list of all AI development languages
due to the simplicity. The syntaxes belonging to python are very simple and can be
easily learnt. Therefore, many AI algorithms can be easily implemented in it. Python
takes short development time in comparison to other languages like Java, C++ or Ruby. 

2. R

R is one of the most effective language and environment for analyzing and manipulating
the data for statistical purposes. Using R, we can easily produce well-designed
publication-quality plot, including mathematical symbols and formulae where needed.
Apart from being a general purpose language, R has numerous of packages like RODBC,
G models, Class and Tm which are used in the field of machine learning

3. Java

Java can also be considered as a good choice for AI development. Artificial intelligence
has lot to do with search algorithms, artificial neural networks and genetic
programming. Java provides many benefits: easy use, debugging ease, package services,
simplified work with large-scale projects, graphical representation of data and better
user interaction.

Comparison between AI Based Programming Language


PYTHON R JAVA
 Intended use  Intended use  Intended use

It is used in Application, It is used in It is used in


general, web, scripting, Application, statistics Application, business,
artificial intelligence, client side, general,
scientific computing. mobile development,
and server-side
website.
History History History
Python was conceived in R was created by Ross Java, having been developed
the late 1980s by Guido Ihaka and Robert in 1991, is a relatively new
van Rossum at Centrum Gentleman at the programming language. At
Wiskunde & Informatics University of Auckland, that time, James Gosling
(CWI) in the Netherlands New Zealand, and is from Sun Microsystems and
as a successor to the ABC currently developed by his team began designing the
language (itself inspired by the R Development Core first version of Java.
SETL), capable of exception Team .
handling and interfacing
with the Amoeba
operating system.

Style of Programming Style of Programming Style of Programming


Python has four  Class name should be
 File Names: end
programming(coding) style noun starting with
in .R
uppercase letter. 
 Imperative  Line Length:
 method name should
 Functional maximum 80
either be verb or verb
 Object-oriented characters
noun combination
 Procedural  All comments begin
starting with lower
with # followed by
letter
a space; inline
comments need  Variable name should
two spaces before be noun starting with
the # lowercase letter.

Features Features Features


 Easy to  A lot of Techniques  Java is Simple (The
code(Python is very (such as linear and
Java programming
easy to learn non-linear
language as modelling, language is easy to
compared to other clustering, learn)
language like c, c#, classification, etc.)  Java is an Object-
java script, java etc)  It complies with
Oriented
 Free and Open other programming
Source(Python languages like C, C+
programming
language is freely + or Java
available at official  R has a progressive language
website) community that  Java supports
 Object-Oriented influences its Functional
Language (One of modifications,
the key features of which allows R to programming (Java is
python is Object- run on almost any updated with
Oriented operating system functional
programming. including Windows programming feature
Python supports and Linux.
like functional
object oriented
language and interfaces and
concepts of classes, Lambda Expressions)
objects
 Java is Platform
encapsulation etc.
 GUI Programming Independence
Support(Graphical
Users interfaces
can be made using
a module such as
PyQt5, PyQt4, w-x-
Python or T-k in
python)
Built-in Function Built-in Function Built-in Function
 Bool ()  abs(x)  equals ()
 ceiling(x)  concat ()
 Bytes ()  substr (x,  substring () 
start=n1,stop=n2)
 Callable ()
Advantages Advantages Advantages
 Interpreted  R allows us to do  Distributed computing
Language various machine
learning operations  Memory allocation
 Vast Libraries such as
Support classification and  Multithreaded (It has
regression the potential for a
 Dynamically Typed program to perform
 It has array of
many tasks at the
packages
same time.
 R is a constantly
evolving
programming
language

Disadvantages Disadvantages Disadvantages


 The line by line  R lacks basic  Java is memory-
execution of code security consuming and
often leads to slow  R is a very significantly slower
execution complicated than natively
 The Python language, and it compiled languages
programming has a steep such as C or C++.
language is not learning curve
memory efficient  The main  Java is Single-
because uses disadvantage of R paradigm language
a large amount of is, it does not have because The addition
memory. support for of static imports in
 Runtime Errors (A dynamic or 3D Java 5.0 the
variable containing graphics. procedural paradigm
integer number is better
may hold a string in accommodated than
the future, which in earlier versions of
can lead to Runtime Java.
Errors)

Q.2. How to create these lists using set-q command:


a. L1 = (a b c d e f g h)

(setq l1 ‘(a b c d e f g h))

b. L2 = ((a b c) (d) e (f g) h)

(setq L2 ‘((a b c) (d) e (f g) h))

c. L3 = ((a) (b (c) d) e (f g) h)

(setq l3 ‘((a) (b (c) d) e (f g) h))

d. L4 = ((a b) c (d) e (f g) h)

(setq l4 ‘((a b) c (d) e (f g) h))

e. L5 = ((a (b) c) (d e f) (g) h)

(setq l5 ‘((a (b) c) (d e f) (g) h))

f. L6 = ((a (b c) (d) e (f g) h))

(setq l6 ‘((a (b c) (d) e (f g) h))

g. 8 Fruits

(setq fruits ‘(apricot banana kiwi orange strawberry mango grapes pineapple watermelon))

h. 6 Vegetables

(setq vegetables ‘(chilli cucumber lettuce pumpkin tomato beetroot potato))


i. First 6 Odd numbers

(setq oddnum ‘(1 3 5 7 9 11))

j. First 5 Even numbers

(setq evennum ‘(0 2 4 6 8))

Q.3. How to add 6 odd numbers and how to add 5 even numbers using LISP?
Even Numbers:

(setq even ‘(0 2 4 6 8))

(+ 0 2 4 6 8)

(eval even)

20

Odd Numbers:

(setq odd ‘(1 3 5 7 9 11))

(+1 3 5 7 9 11)

(eval odd)

36

Q.4. How to create functions using defun for SQUARE, CUBE, QUAD and adding 2 numbers


a+b , subtracting 2 numbers a-b, multiplying 2 numbers a*b and dividing 2 numbers a/b and
then extending it to the third variable of result like c=a+b, c=a-b, c=a*b and c=a/b.

1. (defun square(x)(* x x))


2. (defun cube(x)(* x x x))
3. (defun quad()())
4. (defun add(a b) (let* (c (+ a b)) c))
5. (defun sub(a b) (let* (c (- a b)) c))
6. (defun mult(a b) (let* (c (* a b)) c))
7. (defun div(a b) (let* (c (/ a b)) c))

Q.5. Download LISP Compiler as a freeware.  Apply your Basic LISP Assignment and Advance


LISP Assignment and share your feedback with me here.  Have you get the right answers or
there are issues for applying?  What are they?
I have downloaded the lisp compiler CLISP as freeware easily. And I got the correct answers but I
faced difficulty to create functions using defun for Quad and adding 2 number because lisp compiler
give error when I make function for Quad.

You might also like