SlideShare a Scribd company logo
3.Implementation of Lisp_like list in java
AIM:
       To write a java program to implement the lisp_like list in java.
ALGORITHM:
       1.To implement the necessary packages needed.
       2.Implement the lisp_like list in java to perform functions like that
car(),cdr()
       3.Car() function
                         The car of a list is, quite simply, the first item in the list.
                         Thus the car of the list (rose violet daisy
                          buttercup) is rose.

Example:
    (car '(rose violet daisy buttercup))
               •After evaluating the expression, rose will appear in the
                  echo area.
       4.Cdr() function

                          •The cdr of a list is the rest of the list, that is, the cdr
                             function returns the part of the list that follows the first
                             item.
Example:
    (cdr '(rose violet daisy buttercup))
                          •When you evaluate this, (violet daisy buttercup)
                            will appear in the echo area.
       5.To create a arraylist and add the integer values
       6.To perform the car()&cdr() functions in above method ;
       7.Print the outputs and terminate the program.


PROGRAM:
import java.util.*;
/**
* @version 1.6.0
* @author Annal Sheeba Rani
*/
//To create a class Lisp using to perfom car()&cdr()functions
public class Lisp {
//To perform car() function
public int car(List l){
Object ob=l.get(0);
String st=ob.toString();
System.out.println("Using a L.car() function");
return Integer.parseInt(st);
}
//To perform cdr() function
public List cdr(List l){
Object ob=l.remove(0);
Object obj[]=l.toArray();
System.out.println("Using a L.cdr() function");
List list=Arrays.asList(obj);


return list;
}


public static void main(String[] args)
{
// To add the integer value in the ArrayList
List<Integer> l=new ArrayList<Integer>();
l.add(3);
l.add(0);
l.add(2);
l.add(5);
//To print the Return values of Car(),Cdr()functions
Lisp L=new Lisp();
int val=L.car(l);
System.out.println(val);
List list=L.cdr(l);
System.out.print(list);


}
}
OUTPUT:
Using a L.car() function
3
Using a L.cdr() function
[0, 2, 5]

More Related Content

Viewers also liked (8)

DOC
Autonomic computer
Elanthendral Mariappan
 
DOC
Cybercrimes
Elanthendral Mariappan
 
DOC
Autonomic computer
Elanthendral Mariappan
 
DOC
Packet filtering using jpcap
Elanthendral Mariappan
 
DOC
Image+processing
Elanthendral Mariappan
 
DOC
Routing security in ad hoc wireless network
Elanthendral Mariappan
 
PPT
Ad-HOc presentation
Elanthendral Mariappan
 
PDF
The Outcome Economy
Helge Tennø
 
Autonomic computer
Elanthendral Mariappan
 
Autonomic computer
Elanthendral Mariappan
 
Packet filtering using jpcap
Elanthendral Mariappan
 
Image+processing
Elanthendral Mariappan
 
Routing security in ad hoc wireless network
Elanthendral Mariappan
 
Ad-HOc presentation
Elanthendral Mariappan
 
The Outcome Economy
Helge Tennø
 

Similar to Ex3 lisp likelist in java (19)

PPTX
Functional Programming.pptx
PremBorse1
 
PDF
201801 CSE240 Lecture 20
Javier Gonzalez-Sanchez
 
PPTX
Class 7: Programming with Lists
David Evans
 
PPT
INTRODUCTION TO LISP
Nilt1234
 
PPT
Lisp, An Introduction.ppt
Luis Soza
 
PPT
intro.ppt
AishwaryaKulal1
 
PPT
intro.ppt
Luis Soza
 
PDF
The Functional Programming Triad of Map, Filter and Fold
Philip Schwarz
 
PPTX
LISP: Introduction To Lisp
LISP Content
 
PPTX
LISP: Introduction to lisp
DataminingTools Inc
 
PPT
Java10 Collections and Information
SoftNutx
 
PPTX
AI Programming language (LISP)
Dr. SURBHI SAROHA
 
PDF
Lec4slides
shawiz
 
DOCX
ECS140A-F16-07 October 27, 2016ASSIGNMENT 5 LISPDue .docx
SALU18
 
PDF
01. haskell introduction
Sebastian Rettig
 
PPTX
Lisp
sonukumar142
 
PPTX
Data structures - unit 1
SaranyaP45
 
PDF
Erlang intro
SSA KPI
 
PPT
Lisp and scheme i
Luis Goldster
 
Functional Programming.pptx
PremBorse1
 
201801 CSE240 Lecture 20
Javier Gonzalez-Sanchez
 
Class 7: Programming with Lists
David Evans
 
INTRODUCTION TO LISP
Nilt1234
 
Lisp, An Introduction.ppt
Luis Soza
 
intro.ppt
AishwaryaKulal1
 
intro.ppt
Luis Soza
 
The Functional Programming Triad of Map, Filter and Fold
Philip Schwarz
 
LISP: Introduction To Lisp
LISP Content
 
LISP: Introduction to lisp
DataminingTools Inc
 
Java10 Collections and Information
SoftNutx
 
AI Programming language (LISP)
Dr. SURBHI SAROHA
 
Lec4slides
shawiz
 
ECS140A-F16-07 October 27, 2016ASSIGNMENT 5 LISPDue .docx
SALU18
 
01. haskell introduction
Sebastian Rettig
 
Data structures - unit 1
SaranyaP45
 
Erlang intro
SSA KPI
 
Lisp and scheme i
Luis Goldster
 
Ad

Recently uploaded (20)

PDF
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
PPTX
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
PDF
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PPTX
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Ad

Ex3 lisp likelist in java

  • 1. 3.Implementation of Lisp_like list in java AIM: To write a java program to implement the lisp_like list in java. ALGORITHM: 1.To implement the necessary packages needed. 2.Implement the lisp_like list in java to perform functions like that car(),cdr() 3.Car() function  The car of a list is, quite simply, the first item in the list.  Thus the car of the list (rose violet daisy buttercup) is rose. Example: (car '(rose violet daisy buttercup)) •After evaluating the expression, rose will appear in the echo area. 4.Cdr() function •The cdr of a list is the rest of the list, that is, the cdr function returns the part of the list that follows the first item. Example: (cdr '(rose violet daisy buttercup)) •When you evaluate this, (violet daisy buttercup) will appear in the echo area. 5.To create a arraylist and add the integer values 6.To perform the car()&cdr() functions in above method ; 7.Print the outputs and terminate the program. PROGRAM: import java.util.*; /**
  • 2. * @version 1.6.0 * @author Annal Sheeba Rani */ //To create a class Lisp using to perfom car()&cdr()functions public class Lisp { //To perform car() function public int car(List l){ Object ob=l.get(0); String st=ob.toString(); System.out.println("Using a L.car() function"); return Integer.parseInt(st); } //To perform cdr() function public List cdr(List l){ Object ob=l.remove(0); Object obj[]=l.toArray(); System.out.println("Using a L.cdr() function"); List list=Arrays.asList(obj); return list; } public static void main(String[] args) { // To add the integer value in the ArrayList List<Integer> l=new ArrayList<Integer>(); l.add(3);
  • 3. l.add(0); l.add(2); l.add(5); //To print the Return values of Car(),Cdr()functions Lisp L=new Lisp(); int val=L.car(l); System.out.println(val); List list=L.cdr(l); System.out.print(list); } } OUTPUT: Using a L.car() function 3 Using a L.cdr() function [0, 2, 5]