Rahul Kumar Saurabh

A Recursive LISP function which takes one argument as a list and return list except last element of the list.

           Programs in lisp with output



SOFTWARE USED:  LispWorks 6.1
THEORY:-
Assuming this is about Common Lisp, there is a function  which return list except last element of the list containing the except last item of a list.  If you use this function which applies a given function to each element of a list and returns the concatenated results.

SOURCE CODE ( IF INCLUDED )
(defun except_last_element(any_xyz_list)
(reverse(rest(reverse any_xyz_list))))

EXCEPT_LAST_ELEMENT

(except_last_element' (r a h u l k))

(R A H U L)


 RESULT:-



CONCLUSION:-
We learned about writing the function to which takes one argument as a list and return list except last element of the list. 

A Recursive LISP function which takes one argument as a list and return last element of The list.

  
           Programs in lisp with output


SOFTWARE USED:  LispWorks 6.1

THEORY:-
Assuming this is about Common Lisp, there is a function which returns a list containing the last item of a list.  If you use this function which applies a given function to each element of a list and returns the concatenated results, you'll get what you want.


SOURCE CODE ( IF INCLUDED )

(defun last_element(any_xyz_list)
(first(reverse any_xyz_list)))

LAST_ELEMENT

(last_element '(p q r s))

s


RESULT:-


CONCLUSION:-

We learned about writing the function to evaluate takes one argument as a list and return last element of The list.

A Recursive LISP function to compute factorial of a given number.

          Programs in lisp with output


SOFTWARE USED:  LispWorks 6.1

THEORY:-
Factorial
The factorial of a non-negative integer n , denoted by n! , is the product of all positive integers less than or equal to n.


Example-
                       4! = 4 * 3 * 2 * 1 = 24
similarly         6! = 6 * 5 * 4 * 3 * 2 * 1 =  720
The value of 0! is 1, according to the convention for an empty product.

SOURCE CODE ( IF INCLUDED )
(defun factorial (n)
  
(if (= n 1)
 1
 (* n (factorial (- n 1)))))

(factorial 4)
24

(factorial 6)
720

RESULT:-



CONCLUSION:-
We learned about writing the function to compute factorial of a given number.


A Recursive LISP function to solve Ackermann’s Function.

   Programs in lisp with output


SOFTWARE USED:- LispWorks 6.1.

THEORY:-
ACKERMANN's  FUNCTION
The Ackermann function, named after Wilhelm Ackermann  is one of the simplest and earliest-discovered examples of a total computable function that is not primitive recursive. All primitive recursive functions are total and computable, but the Ackermann function illustrates that not all total computable functions are primitive recursive.
After Ackermann's publication of his function (which had three nonnegative integer arguments), many authors modified it to suit various purposes, so that today "the Ackermann function" may refer to any of numerous variants of the original function. One common version, the two-argument Ackermann–Peter function, is defined as follows for nonnegative integers m and n:-

SOURCE CODE ( IF INCLUDED )
(defun ackermann (m n)
(cond ((= m 0) (+ n 1))
      ((= m 1) (+ n 2))
      ((= m 2) (+ 3 (* n 2)))
      ((= m 3) (+ 5 (* 8 (- (expt 2 n) 1))))
      (t (cond ((= n 0) (ackermann (- m 1) 1))
               (t (ackermann (- m 1) (ackermann m (- n 1))))
         ))
))

 (ackermann 2 3 )
 9

RESULT:-


CONCLUSION:-

We defined a LISP function to compute Ackermann's Function and test it on various values.

Define a LISP function to compute difference of squares


            Programs in lisp with output


SOFTWARE USED:   LispWorks 6.1

THEORY:-
DIFFERENCE OF SQUARE
Difference of square means by subtracting the squares of two numbers.
Example
                Difference of square of x,y= ( x * x ) - ( y * y )
Now in prefix expression it should be written as
( - ( * x x ) ( * y y ) )


SOURCE CODE ( IF INCLUDED )
(defun diffsqr(x y)
 ( - ( *  x  x ) ( *  y  y ) )
( diffsqr 4 3 )
7

RESULT:-



CONCLUSION:-

We  defined a LISP function to compute difference of square and test it on various values.

Define a LISP function to compute sum of squares.

 Programs in lisp with output

Q. Define a LISP function to compute sum of squares.

SOFTWARE USED:  LispWorks 6.1


THEORY:-

SUM OF SQUARE
Sum of square means by adding the squares of two numbers.
Example
                Sum of Square of x ,y= ( x * x ) + ( y * y )
Now in prefix expression it should be written as
( + ( * x x ) ( * y y ) )

SOURCE CODE ( IF INCLUDED )
(defun sumsqr(x y)

( + ( * x x )( *  y  y )))

 (sumsqr 2 3 )

13               

RESULT:-



CONCLUSION:-
We defined a LISP function to compute sum of square and test it on various values.

sql program to ALTER ( ADD, DROP,MODIFY,RENAME) table

OBJECTIVE:-  Program to ALTER table.

SOFTWARE USED:  Oracle SQL
THEORY:-
ALTER:- It is a DDL command.
The ALTER TABLE statement is used to add, delete, rename or modify columns in an existing table.

SOURCE CODE ( IF INCLUDED )
(1) ADD:-
SYNTAX:-
ALTER  table  table_name
ADD  new_column  Data_type(Size);

QUERY: -To add a column subject  in table stud_itsengg.

OUTPUT:-




(2 ) DROP:-
SYNTAX:-
ALTER  table  table_name
DROP  column  column_name;

QUERY:- To drop the column marks in table stud_itsengg.

OUTPUT:-


(3) MODIFY:-
SYNTAX:-
ALTER  table  table_name
MODIFY  column_name  new_datatype  (New Size);

QUERY:- To modify the column  subject  in table  stud_itsengg.

OUTPUT:-


(4) RENAME:-
SYNTAX:-
ALTER  table  table_name
RENAME column   column_name  to  new_column_name;

QUERY:- To rename the  column  subject  to subject_marks  in table stud_itsengg.
OUTPUT:-

CONCLUSION:-

We learned about writing the program to ALTER table..

sql program to insert and delete value in table.

OBJECTIVE:-  Program to insert and delete value in table.

SOFTWARE USED:  Oracle SQL
THEORY:-

INSERT:- It is a DDL command .The insert statement uses the set clause, which specifies the values of a column. You can use more than one set clause per insert statement, and each set clause can set the values in more than one column. Multiple set clauses are not separated by commas. If you specify an optional list of columns, then you can set a value only for a column that is specified in the list of columns to be inserted .and when character value insert then apply  (' ') example ('value') otherwise not apply.

SOURCE CODE ( IF INCLUDED )
insert into table_name
values(value<,....,value>);                                    

PROCEDURE


OUTPUT:-



DELETE:- It is a DDL command .the delete statement is used to delete rows in a table.

SOURCE CODE ( IF INCLUDED )
delete from table_name
where (some_column=some_value);
                   

PROCEDURE


OUTPUT:-



CONCLUSION:-

We learned about writing the program to insert and delete value in table.




sql program to create table


OBJECTIVE:-  Program to create table.

SOFTWARE USED:  Oracle SQL

THEORY:-
CREATE:- It is a DDL command.
It is used to create table in SQL.

SOURCE CODE ( IF INCLUDED )
Create table table_name
(
Attribute _name1   Data_type (Size),
Attribute _name2   Data_type (Size),
……….
Attribute _name n  Data_type(Size)
);

PROCEDURE



RESULT:-


CONCLUSION:-
We learned about writing the program to create table.