SlideShare a Scribd company logo
Functional Programming
                       with

    LISt Processing


   © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>
                  All Rights Reserved.
Introduction




© 2010 Anil Kumar Pugalia <email@sarika-pugs.com>
               All Rights Reserved.
What to Expect?
W's of LISP
Language Specifics
Fun with Recursion




          © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   3
                         All Rights Reserved.
What is LISP?
Functional Programming Language
  Conceived by John McCarthy in 1956
Name comes from its initial powerful List Processing features
Natural computation mechanism: Recursion
Standardization as Common LISP
  ANSI released standards in 1996
Thought of as for Artificial Intelligence
  But could pretty much do anything
Examples range from OS, editors, compilers, games, GUIs, and
you think of it
                 © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   4
                                All Rights Reserved.
Current Available Forms
ANSI Common Lisp: clisp
  Compiler, Interpreter, Debugger
GNU Common Lisp: gcl
  Compiler, Interpreter
CMU Common Lisp: cmucl
  By Carnegie Mellon University
  Default available as .deb packages
  Use “alien –to-rpm" to convert them to rpm
Allegro CL: Commercial Common Lisp implementation
               © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   5
                              All Rights Reserved.
Why LISP?
“The programmable programming language"
What's good for the language's designer
  Is good for the language's users
Wish for new features for easier programming?
  As you can just add the feature yourself
Code the way our brain thinks: Recursive
  Most natural way of programming
50 lines of Code
             © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   6
                            All Rights Reserved.
Language Specifics
Data Structures
Basic Operations
Control Structures
Basic I/O




             © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   7
                            All Rights Reserved.
Data Structures
S-Expression: Atom or List
Atom: String of characters ('Values or Variables)
  Peace, 95432, -rtx, etc
List: Collection of S-Expressions enclosed by ()
  (The 100 times done)
  (Guava (43 (2.718 5) 56) Apple)
What is a Null List: ()?
Common Pitfall: Lists need to start with '
             © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   8
                            All Rights Reserved.
Basic Operations
Lisp Program = Sequence of Functions
  Applied to their Arguments
  Returning Lisp Objects
Function Types
  Predicate
    Tests conditions with its arguments
    Returns Nil (FALSE) or anything else (TRUE)
  Command
    Performs operation with its arguments
    Returns an S-Expression
                © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   9
                               All Rights Reserved.
Basic Operations ...
Format: (function arg1 arg2 … argn)
Let's try
  Commands: car, cdr, cons, quote
  Predicates: atom, null
NB Lisp is case-insensitive
More: first, last, rest, append, consp, ...


             © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   10
                            All Rights Reserved.
Mathematical Operations
Predicates: zerop, plusp, evenp, integerp, floatp
Arithmetic: +, -, *, /, rem, 1+, 1-
Comparisons: =, /=, <, >, <=, >=
Rounding: floor, ceiling, truncate, round
More Functions
  max, min, exp, expt, log, abs, signum, sqrt, isqrt


             © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   11
                            All Rights Reserved.
Control Structures
Constants & Variables: Atoms w/ & w/o quote (')
Assignment: setq, psetq, set, setf
Conditionals: equal, cond, if
Logical: and, or, not
Functions
  (defun func-name (par1 … parn) (commands))
  Unnamed: (lambda (par1 … parn) (commands))

            © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   12
                           All Rights Reserved.
Let's try some functions
Extract the second element from a list
Insert an element at second position in a list
Change nth element in a list
Find length of a list (iteratively)
Find variance of a list of elements




             © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   13
                            All Rights Reserved.
Iteration is Human
     Recursion is God




© 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   14
               All Rights Reserved.
Recursion
 For any recursion, we need 2 things
     Recursive Relation
     Termination Condition
                         Functional                Procedural

Recursive Relation   From Mathematics.       Tricky Extreme
                     Fairly Simple           Conditions

Termination          Needs Thought           Fairly Trivial
Condition



 Let's try some examples to understand
                     © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   15
                                    All Rights Reserved.
Tracing & Analysis
Tracing Recursive Function Calls
  Enable tracing: (trace recursive-func)
  Invoke the function to be traced: (recursive-func …)
Performance Analysis
  (time (func …))
  Samples with our recursive functions



            © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   16
                           All Rights Reserved.
Tail Recursion
Bottom most call's return = Topmost call's return
  Let's observe the trace on list reversal
May not be always possible
But if possible, it is a smart compiler advantage
  Cuts-off processing as soon as lowest level returns




             © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   17
                            All Rights Reserved.
Example: Set Operations
Sets: List of AToms (LATs)
Operations: member, union, intersection, adjoin
Let's write some examples
  which support sets being elements of set




            © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   18
                           All Rights Reserved.
Basic Input / Output
Basic Input
  (read [input-stream] [eof-error] [eof-value]) → s-expr
Basic Output
  (print s-expr [output-stream]) → s-expr
  (format destination control-string [args])




              © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   19
                             All Rights Reserved.
Loading Files
Loading Lisp file for interpretation
  (load "file.lisp")
Compiling a Lisp file
  (compile "file.lisp") or (compile "file")
Loading a compiled Lisp file
  (load (compile "file.lisp"))



              © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   20
                             All Rights Reserved.
References
Common Lisp: http://www.lisp.org
CLISP: http://clisp.cons.org
Practical Common Lisp by Peter Seibel
  Also @ http://www.gigamonkeys.com/book/
LISP Tutorial: http://www.mars.cs.unp.ac.za/lisp/




           © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   21
                          All Rights Reserved.
What all have we learnt?
W's of LISP
Language Specifics Demonstration
  Data Structures
  Basic Operations
  Control Structures
  Basic I/O
Fun with Recursion
  Power, Tail Recursion, Tracing & Analysis
              © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   22
                             All Rights Reserved.
Any Queries?




© 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   23
               All Rights Reserved.
Ad

More Related Content

What's hot (20)

POSIX Threads
POSIX ThreadsPOSIX Threads
POSIX Threads
SysPlay eLearning Academy for You
 
gcc and friends
gcc and friendsgcc and friends
gcc and friends
Anil Kumar Pugalia
 
Bootloaders
BootloadersBootloaders
Bootloaders
Anil Kumar Pugalia
 
Threads
ThreadsThreads
Threads
Anil Kumar Pugalia
 
Introduction to Linux Drivers
Introduction to Linux DriversIntroduction to Linux Drivers
Introduction to Linux Drivers
Anil Kumar Pugalia
 
Toolchain
ToolchainToolchain
Toolchain
Anil Kumar Pugalia
 
Introduction to Linux
Introduction to LinuxIntroduction to Linux
Introduction to Linux
Anil Kumar Pugalia
 
Kernel Programming
Kernel ProgrammingKernel Programming
Kernel Programming
Anil Kumar Pugalia
 
Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & Profiling
Anil Kumar Pugalia
 
RPM Building
RPM BuildingRPM Building
RPM Building
Anil Kumar Pugalia
 
Linux Internals Part - 2
Linux Internals Part - 2Linux Internals Part - 2
Linux Internals Part - 2
SysPlay eLearning Academy for You
 
Linux User Space Debugging & Profiling
Linux User Space Debugging & ProfilingLinux User Space Debugging & Profiling
Linux User Space Debugging & Profiling
Anil Kumar Pugalia
 
Linux Internals Part - 3
Linux Internals Part - 3Linux Internals Part - 3
Linux Internals Part - 3
SysPlay eLearning Academy for You
 
Embedded C
Embedded CEmbedded C
Embedded C
Anil Kumar Pugalia
 
Linux File System
Linux File SystemLinux File System
Linux File System
Anil Kumar Pugalia
 
Synchronization
SynchronizationSynchronization
Synchronization
Anil Kumar Pugalia
 
Embedded Software Design
Embedded Software DesignEmbedded Software Design
Embedded Software Design
Anil Kumar Pugalia
 
Timers
TimersTimers
Timers
Anil Kumar Pugalia
 
Unix system calls
Unix system callsUnix system calls
Unix system calls
stellajoseph
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal Bootloader
Satpal Parmar
 

Viewers also liked (7)

Mobile Hacking using Linux Drivers
Mobile Hacking using Linux DriversMobile Hacking using Linux Drivers
Mobile Hacking using Linux Drivers
Anil Kumar Pugalia
 
Board Bringup
Board BringupBoard Bringup
Board Bringup
Anil Kumar Pugalia
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
Anil Kumar Pugalia
 
Network Drivers
Network DriversNetwork Drivers
Network Drivers
Anil Kumar Pugalia
 
References
ReferencesReferences
References
Anil Kumar Pugalia
 
Interrupts
InterruptsInterrupts
Interrupts
Anil Kumar Pugalia
 
Character Drivers
Character DriversCharacter Drivers
Character Drivers
Anil Kumar Pugalia
 
Ad

Similar to Functional Programming with LISP (20)

Vasiliy Litvinov - Python Profiling
Vasiliy Litvinov - Python ProfilingVasiliy Litvinov - Python Profiling
Vasiliy Litvinov - Python Profiling
Sergey Arkhipov
 
Massively Parallel Processing with Procedural Python by Ronert Obst PyData Be...
Massively Parallel Processing with Procedural Python by Ronert Obst PyData Be...Massively Parallel Processing with Procedural Python by Ronert Obst PyData Be...
Massively Parallel Processing with Procedural Python by Ronert Obst PyData Be...
PyData
 
Lambdas And Streams Hands On Lab
Lambdas And Streams Hands On LabLambdas And Streams Hands On Lab
Lambdas And Streams Hands On Lab
Simon Ritter
 
Government Polytechnic Arvi-1.pptx
Government Polytechnic Arvi-1.pptxGovernment Polytechnic Arvi-1.pptx
Government Polytechnic Arvi-1.pptx
ShivamDenge
 
Shivam PPT.pptx
Shivam PPT.pptxShivam PPT.pptx
Shivam PPT.pptx
ShivamDenge
 
Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)
Ian Huston
 
JDK8 Streams
JDK8 StreamsJDK8 Streams
JDK8 Streams
Bansilal Haudakari
 
Lambdas Hands On Lab
Lambdas Hands On LabLambdas Hands On Lab
Lambdas Hands On Lab
Simon Ritter
 
RSJ2011 OSS Robotics and Tools OpenHRI Intro
RSJ2011 OSS Robotics and Tools OpenHRI IntroRSJ2011 OSS Robotics and Tools OpenHRI Intro
RSJ2011 OSS Robotics and Tools OpenHRI Intro
Yosuke Matsusaka
 
Calcite meetup-2016-04-20
Calcite meetup-2016-04-20Calcite meetup-2016-04-20
Calcite meetup-2016-04-20
Josh Elser
 
Python functional programming
Python functional programmingPython functional programming
Python functional programming
Geison Goes
 
Accelerating the Development of Efficient CP Optimizer Models
Accelerating the Development of Efficient CP Optimizer ModelsAccelerating the Development of Efficient CP Optimizer Models
Accelerating the Development of Efficient CP Optimizer Models
Philippe Laborie
 
Functional Programming - Past, Present and Future
Functional Programming - Past, Present and FutureFunctional Programming - Past, Present and Future
Functional Programming - Past, Present and Future
Pushkar Kulkarni
 
Functional Programming Past Present Future
Functional Programming Past Present FutureFunctional Programming Past Present Future
Functional Programming Past Present Future
IndicThreads
 
Massively Parallel Process with Prodedural Python by Ian Huston
Massively Parallel Process with Prodedural Python by Ian HustonMassively Parallel Process with Prodedural Python by Ian Huston
Massively Parallel Process with Prodedural Python by Ian Huston
PyData
 
Pivotal Data Labs - Technology and Tools in our Data Scientist's Arsenal
Pivotal Data Labs - Technology and Tools in our Data Scientist's Arsenal Pivotal Data Labs - Technology and Tools in our Data Scientist's Arsenal
Pivotal Data Labs - Technology and Tools in our Data Scientist's Arsenal
Srivatsan Ramanujam
 
Arista: DevOps for Network Engineers
Arista: DevOps for Network EngineersArista: DevOps for Network Engineers
Arista: DevOps for Network Engineers
Philip DiLeo
 
Hierarchical free monads and software design in fp
Hierarchical free monads and software design in fpHierarchical free monads and software design in fp
Hierarchical free monads and software design in fp
Alexander Granin
 
PYTHON BY MOHIT PANSURIYA programing.pptx
PYTHON BY MOHIT PANSURIYA programing.pptxPYTHON BY MOHIT PANSURIYA programing.pptx
PYTHON BY MOHIT PANSURIYA programing.pptx
raviofficialmrm06
 
Flink internals web
Flink internals web Flink internals web
Flink internals web
Kostas Tzoumas
 
Vasiliy Litvinov - Python Profiling
Vasiliy Litvinov - Python ProfilingVasiliy Litvinov - Python Profiling
Vasiliy Litvinov - Python Profiling
Sergey Arkhipov
 
Massively Parallel Processing with Procedural Python by Ronert Obst PyData Be...
Massively Parallel Processing with Procedural Python by Ronert Obst PyData Be...Massively Parallel Processing with Procedural Python by Ronert Obst PyData Be...
Massively Parallel Processing with Procedural Python by Ronert Obst PyData Be...
PyData
 
Lambdas And Streams Hands On Lab
Lambdas And Streams Hands On LabLambdas And Streams Hands On Lab
Lambdas And Streams Hands On Lab
Simon Ritter
 
Government Polytechnic Arvi-1.pptx
Government Polytechnic Arvi-1.pptxGovernment Polytechnic Arvi-1.pptx
Government Polytechnic Arvi-1.pptx
ShivamDenge
 
Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)
Ian Huston
 
Lambdas Hands On Lab
Lambdas Hands On LabLambdas Hands On Lab
Lambdas Hands On Lab
Simon Ritter
 
RSJ2011 OSS Robotics and Tools OpenHRI Intro
RSJ2011 OSS Robotics and Tools OpenHRI IntroRSJ2011 OSS Robotics and Tools OpenHRI Intro
RSJ2011 OSS Robotics and Tools OpenHRI Intro
Yosuke Matsusaka
 
Calcite meetup-2016-04-20
Calcite meetup-2016-04-20Calcite meetup-2016-04-20
Calcite meetup-2016-04-20
Josh Elser
 
Python functional programming
Python functional programmingPython functional programming
Python functional programming
Geison Goes
 
Accelerating the Development of Efficient CP Optimizer Models
Accelerating the Development of Efficient CP Optimizer ModelsAccelerating the Development of Efficient CP Optimizer Models
Accelerating the Development of Efficient CP Optimizer Models
Philippe Laborie
 
Functional Programming - Past, Present and Future
Functional Programming - Past, Present and FutureFunctional Programming - Past, Present and Future
Functional Programming - Past, Present and Future
Pushkar Kulkarni
 
Functional Programming Past Present Future
Functional Programming Past Present FutureFunctional Programming Past Present Future
Functional Programming Past Present Future
IndicThreads
 
Massively Parallel Process with Prodedural Python by Ian Huston
Massively Parallel Process with Prodedural Python by Ian HustonMassively Parallel Process with Prodedural Python by Ian Huston
Massively Parallel Process with Prodedural Python by Ian Huston
PyData
 
Pivotal Data Labs - Technology and Tools in our Data Scientist's Arsenal
Pivotal Data Labs - Technology and Tools in our Data Scientist's Arsenal Pivotal Data Labs - Technology and Tools in our Data Scientist's Arsenal
Pivotal Data Labs - Technology and Tools in our Data Scientist's Arsenal
Srivatsan Ramanujam
 
Arista: DevOps for Network Engineers
Arista: DevOps for Network EngineersArista: DevOps for Network Engineers
Arista: DevOps for Network Engineers
Philip DiLeo
 
Hierarchical free monads and software design in fp
Hierarchical free monads and software design in fpHierarchical free monads and software design in fp
Hierarchical free monads and software design in fp
Alexander Granin
 
PYTHON BY MOHIT PANSURIYA programing.pptx
PYTHON BY MOHIT PANSURIYA programing.pptxPYTHON BY MOHIT PANSURIYA programing.pptx
PYTHON BY MOHIT PANSURIYA programing.pptx
raviofficialmrm06
 
Ad

More from Anil Kumar Pugalia (10)

File System Modules
File System ModulesFile System Modules
File System Modules
Anil Kumar Pugalia
 
Processes
ProcessesProcesses
Processes
Anil Kumar Pugalia
 
System Calls
System CallsSystem Calls
System Calls
Anil Kumar Pugalia
 
Playing with R L C Circuits
Playing with R L C CircuitsPlaying with R L C Circuits
Playing with R L C Circuits
Anil Kumar Pugalia
 
Audio Drivers
Audio DriversAudio Drivers
Audio Drivers
Anil Kumar Pugalia
 
Video Drivers
Video DriversVideo Drivers
Video Drivers
Anil Kumar Pugalia
 
Power of vi
Power of viPower of vi
Power of vi
Anil Kumar Pugalia
 
"make" system
"make" system"make" system
"make" system
Anil Kumar Pugalia
 
Hardware Design for Software Hackers
Hardware Design for Software HackersHardware Design for Software Hackers
Hardware Design for Software Hackers
Anil Kumar Pugalia
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
Anil Kumar Pugalia
 

Recently uploaded (20)

UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Vaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without HallucinationsVaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without Hallucinations
john409870
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
Vibe Coding_ Develop a web application using AI (1).pdf
Vibe Coding_ Develop a web application using AI (1).pdfVibe Coding_ Develop a web application using AI (1).pdf
Vibe Coding_ Develop a web application using AI (1).pdf
Baiju Muthukadan
 
The Changing Compliance Landscape in 2025.pdf
The Changing Compliance Landscape in 2025.pdfThe Changing Compliance Landscape in 2025.pdf
The Changing Compliance Landscape in 2025.pdf
Precisely
 
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents SystemsTrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
Trs Labs
 
UiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer OpportunitiesUiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer Opportunities
DianaGray10
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
Connect and Protect: Networks and Network Security
Connect and Protect: Networks and Network SecurityConnect and Protect: Networks and Network Security
Connect and Protect: Networks and Network Security
VICTOR MAESTRE RAMIREZ
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Vaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without HallucinationsVaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without Hallucinations
john409870
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
Vibe Coding_ Develop a web application using AI (1).pdf
Vibe Coding_ Develop a web application using AI (1).pdfVibe Coding_ Develop a web application using AI (1).pdf
Vibe Coding_ Develop a web application using AI (1).pdf
Baiju Muthukadan
 
The Changing Compliance Landscape in 2025.pdf
The Changing Compliance Landscape in 2025.pdfThe Changing Compliance Landscape in 2025.pdf
The Changing Compliance Landscape in 2025.pdf
Precisely
 
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents SystemsTrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
Trs Labs
 
UiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer OpportunitiesUiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer Opportunities
DianaGray10
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
Connect and Protect: Networks and Network Security
Connect and Protect: Networks and Network SecurityConnect and Protect: Networks and Network Security
Connect and Protect: Networks and Network Security
VICTOR MAESTRE RAMIREZ
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 

Functional Programming with LISP

  • 1. Functional Programming with LISt Processing © 2010 Anil Kumar Pugalia <[email protected]> All Rights Reserved.
  • 2. Introduction © 2010 Anil Kumar Pugalia <[email protected]> All Rights Reserved.
  • 3. What to Expect? W's of LISP Language Specifics Fun with Recursion © 2010 Anil Kumar Pugalia <[email protected]> 3 All Rights Reserved.
  • 4. What is LISP? Functional Programming Language Conceived by John McCarthy in 1956 Name comes from its initial powerful List Processing features Natural computation mechanism: Recursion Standardization as Common LISP ANSI released standards in 1996 Thought of as for Artificial Intelligence But could pretty much do anything Examples range from OS, editors, compilers, games, GUIs, and you think of it © 2010 Anil Kumar Pugalia <[email protected]> 4 All Rights Reserved.
  • 5. Current Available Forms ANSI Common Lisp: clisp Compiler, Interpreter, Debugger GNU Common Lisp: gcl Compiler, Interpreter CMU Common Lisp: cmucl By Carnegie Mellon University Default available as .deb packages Use “alien –to-rpm" to convert them to rpm Allegro CL: Commercial Common Lisp implementation © 2010 Anil Kumar Pugalia <[email protected]> 5 All Rights Reserved.
  • 6. Why LISP? “The programmable programming language" What's good for the language's designer Is good for the language's users Wish for new features for easier programming? As you can just add the feature yourself Code the way our brain thinks: Recursive Most natural way of programming 50 lines of Code © 2010 Anil Kumar Pugalia <[email protected]> 6 All Rights Reserved.
  • 7. Language Specifics Data Structures Basic Operations Control Structures Basic I/O © 2010 Anil Kumar Pugalia <[email protected]> 7 All Rights Reserved.
  • 8. Data Structures S-Expression: Atom or List Atom: String of characters ('Values or Variables) Peace, 95432, -rtx, etc List: Collection of S-Expressions enclosed by () (The 100 times done) (Guava (43 (2.718 5) 56) Apple) What is a Null List: ()? Common Pitfall: Lists need to start with ' © 2010 Anil Kumar Pugalia <[email protected]> 8 All Rights Reserved.
  • 9. Basic Operations Lisp Program = Sequence of Functions Applied to their Arguments Returning Lisp Objects Function Types Predicate Tests conditions with its arguments Returns Nil (FALSE) or anything else (TRUE) Command Performs operation with its arguments Returns an S-Expression © 2010 Anil Kumar Pugalia <[email protected]> 9 All Rights Reserved.
  • 10. Basic Operations ... Format: (function arg1 arg2 … argn) Let's try Commands: car, cdr, cons, quote Predicates: atom, null NB Lisp is case-insensitive More: first, last, rest, append, consp, ... © 2010 Anil Kumar Pugalia <[email protected]> 10 All Rights Reserved.
  • 11. Mathematical Operations Predicates: zerop, plusp, evenp, integerp, floatp Arithmetic: +, -, *, /, rem, 1+, 1- Comparisons: =, /=, <, >, <=, >= Rounding: floor, ceiling, truncate, round More Functions max, min, exp, expt, log, abs, signum, sqrt, isqrt © 2010 Anil Kumar Pugalia <[email protected]> 11 All Rights Reserved.
  • 12. Control Structures Constants & Variables: Atoms w/ & w/o quote (') Assignment: setq, psetq, set, setf Conditionals: equal, cond, if Logical: and, or, not Functions (defun func-name (par1 … parn) (commands)) Unnamed: (lambda (par1 … parn) (commands)) © 2010 Anil Kumar Pugalia <[email protected]> 12 All Rights Reserved.
  • 13. Let's try some functions Extract the second element from a list Insert an element at second position in a list Change nth element in a list Find length of a list (iteratively) Find variance of a list of elements © 2010 Anil Kumar Pugalia <[email protected]> 13 All Rights Reserved.
  • 14. Iteration is Human Recursion is God © 2010 Anil Kumar Pugalia <[email protected]> 14 All Rights Reserved.
  • 15. Recursion For any recursion, we need 2 things Recursive Relation Termination Condition Functional Procedural Recursive Relation From Mathematics. Tricky Extreme Fairly Simple Conditions Termination Needs Thought Fairly Trivial Condition Let's try some examples to understand © 2010 Anil Kumar Pugalia <[email protected]> 15 All Rights Reserved.
  • 16. Tracing & Analysis Tracing Recursive Function Calls Enable tracing: (trace recursive-func) Invoke the function to be traced: (recursive-func …) Performance Analysis (time (func …)) Samples with our recursive functions © 2010 Anil Kumar Pugalia <[email protected]> 16 All Rights Reserved.
  • 17. Tail Recursion Bottom most call's return = Topmost call's return Let's observe the trace on list reversal May not be always possible But if possible, it is a smart compiler advantage Cuts-off processing as soon as lowest level returns © 2010 Anil Kumar Pugalia <[email protected]> 17 All Rights Reserved.
  • 18. Example: Set Operations Sets: List of AToms (LATs) Operations: member, union, intersection, adjoin Let's write some examples which support sets being elements of set © 2010 Anil Kumar Pugalia <[email protected]> 18 All Rights Reserved.
  • 19. Basic Input / Output Basic Input (read [input-stream] [eof-error] [eof-value]) → s-expr Basic Output (print s-expr [output-stream]) → s-expr (format destination control-string [args]) © 2010 Anil Kumar Pugalia <[email protected]> 19 All Rights Reserved.
  • 20. Loading Files Loading Lisp file for interpretation (load "file.lisp") Compiling a Lisp file (compile "file.lisp") or (compile "file") Loading a compiled Lisp file (load (compile "file.lisp")) © 2010 Anil Kumar Pugalia <[email protected]> 20 All Rights Reserved.
  • 21. References Common Lisp: http://www.lisp.org CLISP: http://clisp.cons.org Practical Common Lisp by Peter Seibel Also @ http://www.gigamonkeys.com/book/ LISP Tutorial: http://www.mars.cs.unp.ac.za/lisp/ © 2010 Anil Kumar Pugalia <[email protected]> 21 All Rights Reserved.
  • 22. What all have we learnt? W's of LISP Language Specifics Demonstration Data Structures Basic Operations Control Structures Basic I/O Fun with Recursion Power, Tail Recursion, Tracing & Analysis © 2010 Anil Kumar Pugalia <[email protected]> 22 All Rights Reserved.
  • 23. Any Queries? © 2010 Anil Kumar Pugalia <[email protected]> 23 All Rights Reserved.