SlideShare una empresa de Scribd logo
1 de 3
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]

Más contenido relacionado

Destacado (8)

Autonomic computer
Autonomic computerAutonomic computer
Autonomic computer
 
Cybercrimes
CybercrimesCybercrimes
Cybercrimes
 
Autonomic computer
Autonomic computerAutonomic computer
Autonomic computer
 
Packet filtering using jpcap
Packet filtering using jpcapPacket filtering using jpcap
Packet filtering using jpcap
 
Image+processing
Image+processingImage+processing
Image+processing
 
Routing security in ad hoc wireless network
Routing security in ad hoc wireless networkRouting security in ad hoc wireless network
Routing security in ad hoc wireless network
 
Ad-HOc presentation
Ad-HOc presentationAd-HOc presentation
Ad-HOc presentation
 
The Outcome Economy
The Outcome EconomyThe Outcome Economy
The Outcome Economy
 

Similar a Ex3 lisp likelist in java

Write Your Own JVM Compiler
Write Your Own JVM CompilerWrite Your Own JVM Compiler
Write Your Own JVM Compiler
Erin Dees
 
I have question in c++ program I need the answer as soon as possible.docx
I have question in c++ program I need the answer as soon as possible.docxI have question in c++ program I need the answer as soon as possible.docx
I have question in c++ program I need the answer as soon as possible.docx
delciegreeks
 
r,rstats,r language,r packages
r,rstats,r language,r packagesr,rstats,r language,r packages
r,rstats,r language,r packages
Ajay Ohri
 

Similar a Ex3 lisp likelist in java (20)

Lisp
LispLisp
Lisp
 
A brief introduction to lisp language
A brief introduction to lisp languageA brief introduction to lisp language
A brief introduction to lisp language
 
DevNation'15 - Using Lambda Expressions to Query a Datastore
DevNation'15 - Using Lambda Expressions to Query a DatastoreDevNation'15 - Using Lambda Expressions to Query a Datastore
DevNation'15 - Using Lambda Expressions to Query a Datastore
 
New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 iti
 
New Features in JDK 8
New Features in JDK 8New Features in JDK 8
New Features in JDK 8
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scala
 
Rails and the Apache SOLR Search Engine
Rails and the Apache SOLR Search EngineRails and the Apache SOLR Search Engine
Rails and the Apache SOLR Search Engine
 
cp05.pptx
cp05.pptxcp05.pptx
cp05.pptx
 
Write Your Own JVM Compiler
Write Your Own JVM CompilerWrite Your Own JVM Compiler
Write Your Own JVM Compiler
 
あなたのScalaを爆速にする7つの方法
あなたのScalaを爆速にする7つの方法あなたのScalaを爆速にする7つの方法
あなたのScalaを爆速にする7つの方法
 
Things about Functional JavaScript
Things about Functional JavaScriptThings about Functional JavaScript
Things about Functional JavaScript
 
Rcpp
RcppRcpp
Rcpp
 
What You Need to Know about Lambdas
What You Need to Know about LambdasWhat You Need to Know about Lambdas
What You Need to Know about Lambdas
 
INTRODUCTION TO LISP
INTRODUCTION TO LISPINTRODUCTION TO LISP
INTRODUCTION TO LISP
 
The Ring programming language version 1.7 book - Part 35 of 196
The Ring programming language version 1.7 book - Part 35 of 196The Ring programming language version 1.7 book - Part 35 of 196
The Ring programming language version 1.7 book - Part 35 of 196
 
I have question in c++ program I need the answer as soon as possible.docx
I have question in c++ program I need the answer as soon as possible.docxI have question in c++ program I need the answer as soon as possible.docx
I have question in c++ program I need the answer as soon as possible.docx
 
r,rstats,r language,r packages
r,rstats,r language,r packagesr,rstats,r language,r packages
r,rstats,r language,r packages
 
20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdas20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdas
 
Apache Spark & Streaming
Apache Spark & StreamingApache Spark & Streaming
Apache Spark & Streaming
 
Practical cats
Practical catsPractical cats
Practical cats
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 

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]