Functional and Logic Programming
Functional and Logic Programming
Greater Noida
SESSION : 2014-15
SUBMITTED TO :
Mrs Anuradha
SUBMITTED BY:
INDEX
S.No.
01
02
03
04
05
06
07
08
09
10
11
12
NAME OF PROGRAM
DATE
PAGE No.
SIGN.
Program-1
#include<stdio.h>
#include<conio.h>
int main()
{
int array[100], search, c, n;
{
printf("%d is present at location %d.\n", search, c+1);
break;
}
}
if (c == n)
printf("%d is not present in array.\n", search);
return 0;
}
Program-2
#include<stdio.h>
#include<conio.h>
int main()
{
int c, first, last, middle, n, search, array[100];
first = 0;
last = n - 1;
middle = (first+last)/2;
return 0;
}
Program-3
#include<stdio.h>
#include<conio.h>
int main()
{
int array[100], n, c, d, swap;
= array[d];
array[d] = array[d+1];
array[d+1] = swap;
}
}
}
return 0;
}
Program-4
#include<stdio.h>
#include<conio.h>
void quicksort(int [10],int,int);
int main(){
int x[20],size,i;
quicksort(x,0,size-1);
return 0;
}
void quicksort(int x[10],int first,int last){
int pivot,j,temp,i;
if(first<last){
pivot=first;
i=first;
j=last;
while(i<j){
while(x[i]<=x[pivot]&&i<last)
i++;
while(x[j]>x[pivot])
j--;
if(i<j){
temp=x[i];
x[i]=x[j];
x[j]=temp;
}
}
temp=x[pivot];
x[pivot]=x[j];
x[j]=temp;
quicksort(x,first,j-1);
quicksort(x,j+1,last);
}
}
Program-5
Program-6
Program in Lisp to convert the Fahrenheit degree to the equivalent Celsius degree
(defun convert ()
(format t "Enter Fahrenheit ")
(LET (fahr)
(SETQ fahr (read fahr))
(APPEND '(celsisus is) (*(- fahr 32)(/ 5 9)) )
)
)
Program-7
Program in LISP for inserting new properties in the old properties of the any existing
function
Program-8
Program in LISP for Depth First Search and Breadth First Searches
Program-9
(cond
((< (first-jug state) 4) (mk-state 4 (second-jug state))))))
(defun fill-second (state)
(cond
((< (second-jug state) 3) (mk-state (first-jug state) 3))))
(defun pour-first-second (state)
(let ( (f (first-jug state))
(s (second-jug state)))
(cond
((zerop f) nil)
((= s 3) nil)
; Second full
((<= (+ f s) 3)
(mk-state 0 (+ f s)))
(t
((= f 4) nil)
; First full
((<= (+ f s) 4)
(mk-state (+ f s) 0))
(t
Program-10
Program-11
Program-12