SlideShare uma empresa Scribd logo
1 de 20
PAIP   1        Lisp

           yadokarielectric | yad-EL
•       1.10

•   1

•
•              1
•1       1

•    1       1

•    1
     1

•
•
•
•
    OK

•
•

•
• Lisp
• Lisp
•(               1       2 …)

•

•    (+ 1 (* 2 3 4) 5)
•

•
• (if       then   else )

• if                        then
    elese
•

•
    setf

• (setf abc 3)
•
•
•
•
    2   2
• (setf x (1 2 3))
                        (1 2 3)
     1



•            (setf x (list 1 2 3))
quote
•
     quote

• (setf x (quote (1 2 3)))
•             '

• (setf x '(1 2 3))
(setf p '(JOHN Q PUBLIC))
•   (first p)           •    (cons 'Mr p)

•   (rest p)           •    (cons (first p) (rest p))

•   (second p)         •    (last p)

•   (third p)          •    (first (last p))

•   (fourth p)

•   (length p)
•          defun

• (defun     (     1   2…)

    "                        "

             …)
•

•              mapcar

•
    function             #'

• (mapcar #'last-name names)
1.1

(defparameter *suffix*
 '(MD Jr. |,|))

(defun last-name (name)
 (if (member (first (last name)) *suffix*)
     (last-name (butlast name))
     (first (last name))))
n=28
     1.2
                                              loop-power   27

                                              power
(defun loop-power (x n)
 (let ((r 1))                                 28 2
   (dotimes (i n)                             14 2
     (setf r (* r x)))                        7 x
   r))                                        6   2
                                              3 x
(defun square (x) (* x x))
                                              2   2
(defun power (x n)
                                                     6
 (cond ((= n 0) 1)
     ((evenp n) (square (power x (/ n 2))))
     (t (* x (power x (- n 1))))))
1.3   nil


(defun count-atoms (exp)
 (cond ((null exp) 0)
     ((atom exp) 1)
     (t (+ (count-atoms (first exp))
          (count-atoms (rest exp))))))
1.3   nil

(defun count-all-atoms (exp &optional (if-null 1))
 (cond ((null exp) if-null)
     ((atom exp) 1)
     (t (+ (count-all-atoms (first exp) 1)
          (count-all-atoms (rest exp) 0)))))
1.4

(defun count-anywhere (item tree)
 (cond ((eql item tree) 1)
     ((atom tree) 0)
     (t (+ (count-anywhere item (first tree))
          (count-anywhere item (rest tree))))))
1.5
(defun dot-product (a b)
 (if (or (null a) (null b))
     0
     (+ (* (first a) (first b))
       (dot-product (rest a) (rest b)))))

(defun dot-product (a b)
 (let ((sum 0))
   (dotimes (i (length a))
    (incf sum (* (elt a i) (elt b i))))
   sum))

(defun dot-product (a b)
 (apply #'+ (mapcar #'* a b)))

Mais conteúdo relacionado

Mais procurados

Using R Tool for Probability and Statistics
Using R Tool for Probability and Statistics Using R Tool for Probability and Statistics
Using R Tool for Probability and Statistics nazlitemu
 
The secrets of inverse brogramming
The secrets of inverse brogrammingThe secrets of inverse brogramming
The secrets of inverse brogrammingRichie Cotton
 
Day 5 examples u6w14
Day 5 examples u6w14Day 5 examples u6w14
Day 5 examples u6w14jchartiersjsd
 
119 Powerpoint 2.6
119 Powerpoint 2.6119 Powerpoint 2.6
119 Powerpoint 2.6Jeneva Clark
 
脳の計算論 第3章「リズム活動と位相応答」
脳の計算論 第3章「リズム活動と位相応答」脳の計算論 第3章「リズム活動と位相応答」
脳の計算論 第3章「リズム活動と位相応答」Kohei Ichikawa
 
SPSF04 - Euler and Runge-Kutta Methods
SPSF04 - Euler and Runge-Kutta MethodsSPSF04 - Euler and Runge-Kutta Methods
SPSF04 - Euler and Runge-Kutta MethodsSyeilendra Pramuditya
 
Cheat sheet python3
Cheat sheet python3Cheat sheet python3
Cheat sheet python3sxw2k
 
Python3 cheatsheet
Python3 cheatsheetPython3 cheatsheet
Python3 cheatsheetGil Cohen
 
chap 2 Ex#1.1
chap 2 Ex#1.1chap 2 Ex#1.1
chap 2 Ex#1.1Ans Ali
 
Operations on Functions
Operations on FunctionsOperations on Functions
Operations on Functionsswartzje
 
Addition and Subtraction of Functions
Addition and Subtraction of FunctionsAddition and Subtraction of Functions
Addition and Subtraction of Functionsjordhuffman
 

Mais procurados (20)

Using R Tool for Probability and Statistics
Using R Tool for Probability and Statistics Using R Tool for Probability and Statistics
Using R Tool for Probability and Statistics
 
Day 6 examples
Day 6 examplesDay 6 examples
Day 6 examples
 
04. haskell handling
04. haskell handling04. haskell handling
04. haskell handling
 
The secrets of inverse brogramming
The secrets of inverse brogrammingThe secrets of inverse brogramming
The secrets of inverse brogramming
 
Day 5 examples u6w14
Day 5 examples u6w14Day 5 examples u6w14
Day 5 examples u6w14
 
119 Powerpoint 2.6
119 Powerpoint 2.6119 Powerpoint 2.6
119 Powerpoint 2.6
 
脳の計算論 第3章「リズム活動と位相応答」
脳の計算論 第3章「リズム活動と位相応答」脳の計算論 第3章「リズム活動と位相応答」
脳の計算論 第3章「リズム活動と位相応答」
 
Clojure night
Clojure nightClojure night
Clojure night
 
Families of Triangular Norm Based Kernel Function and Its Application to Kern...
Families of Triangular Norm Based Kernel Function and Its Application to Kern...Families of Triangular Norm Based Kernel Function and Its Application to Kern...
Families of Triangular Norm Based Kernel Function and Its Application to Kern...
 
SPSF04 - Euler and Runge-Kutta Methods
SPSF04 - Euler and Runge-Kutta MethodsSPSF04 - Euler and Runge-Kutta Methods
SPSF04 - Euler and Runge-Kutta Methods
 
Day 4 examples
Day 4 examplesDay 4 examples
Day 4 examples
 
Lesson 51
Lesson 51Lesson 51
Lesson 51
 
Day 3 examples
Day 3 examplesDay 3 examples
Day 3 examples
 
Day 1 examples
Day 1 examplesDay 1 examples
Day 1 examples
 
Cheat sheet python3
Cheat sheet python3Cheat sheet python3
Cheat sheet python3
 
Python3 cheatsheet
Python3 cheatsheetPython3 cheatsheet
Python3 cheatsheet
 
chap 2 Ex#1.1
chap 2 Ex#1.1chap 2 Ex#1.1
chap 2 Ex#1.1
 
Day 5 examples
Day 5 examplesDay 5 examples
Day 5 examples
 
Operations on Functions
Operations on FunctionsOperations on Functions
Operations on Functions
 
Addition and Subtraction of Functions
Addition and Subtraction of FunctionsAddition and Subtraction of Functions
Addition and Subtraction of Functions
 

Destaque

Serverspecを使ってみた話
Serverspecを使ってみた話Serverspecを使ってみた話
Serverspecを使ってみた話Yasufumi Moritake
 
Start Haskell - Exercise 13 1
Start Haskell - Exercise 13 1Start Haskell - Exercise 13 1
Start Haskell - Exercise 13 1ymmtmsys
 
Phoenixを使った案件でリリースまでに起きた問題と対応
Phoenixを使った案件でリリースまでに起きた問題と対応Phoenixを使った案件でリリースまでに起きた問題と対応
Phoenixを使った案件でリリースまでに起きた問題と対応ndruger
 
Erlangご紹介 websocket編
Erlangご紹介 websocket編Erlangご紹介 websocket編
Erlangご紹介 websocket編Masatoshi Itoh
 
機械学習概論 講義テキスト
機械学習概論 講義テキスト機械学習概論 講義テキスト
機械学習概論 講義テキストEtsuji Nakai
 

Destaque (8)

Serverspecを使ってみた話
Serverspecを使ってみた話Serverspecを使ってみた話
Serverspecを使ってみた話
 
Start Haskell - Exercise 13 1
Start Haskell - Exercise 13 1Start Haskell - Exercise 13 1
Start Haskell - Exercise 13 1
 
PAIP 第5章 ELIZA
PAIP 第5章 ELIZAPAIP 第5章 ELIZA
PAIP 第5章 ELIZA
 
Phoenixを使った案件でリリースまでに起きた問題と対応
Phoenixを使った案件でリリースまでに起きた問題と対応Phoenixを使った案件でリリースまでに起きた問題と対応
Phoenixを使った案件でリリースまでに起きた問題と対応
 
running web app on elixir
running web app on elixirrunning web app on elixir
running web app on elixir
 
Elixir lang bootstrap
Elixir lang bootstrapElixir lang bootstrap
Elixir lang bootstrap
 
Erlangご紹介 websocket編
Erlangご紹介 websocket編Erlangご紹介 websocket編
Erlangご紹介 websocket編
 
機械学習概論 講義テキスト
機械学習概論 講義テキスト機械学習概論 講義テキスト
機械学習概論 講義テキスト
 

Semelhante a PAIP 第1章 Lisp入門

ฟังก์ชัน(function)
ฟังก์ชัน(function)ฟังก์ชัน(function)
ฟังก์ชัน(function)Yodhathai Reesrikom
 
ฟังก์ชัน(function)
ฟังก์ชัน(function)ฟังก์ชัน(function)
ฟังก์ชัน(function)Yodhathai Reesrikom
 
Aaron Ellison Keynote: Reaching the 99%
Aaron Ellison Keynote: Reaching the 99%Aaron Ellison Keynote: Reaching the 99%
Aaron Ellison Keynote: Reaching the 99%David LeBauer
 
Zero Theorem and Rational Roots Presentation
Zero Theorem and Rational Roots PresentationZero Theorem and Rational Roots Presentation
Zero Theorem and Rational Roots PresentationDanellaFernandez
 
The Magnificent Seven
The Magnificent SevenThe Magnificent Seven
The Magnificent SevenMike Fogus
 
Lecture4 kenrels functions_rkhs
Lecture4 kenrels functions_rkhsLecture4 kenrels functions_rkhs
Lecture4 kenrels functions_rkhsStéphane Canu
 
1531 fourier series- integrals and trans
1531 fourier series- integrals and trans1531 fourier series- integrals and trans
1531 fourier series- integrals and transDr Fereidoun Dejahang
 
MLP輪読スパース8章 トレースノルム正則化
MLP輪読スパース8章 トレースノルム正則化MLP輪読スパース8章 トレースノルム正則化
MLP輪読スパース8章 トレースノルム正則化Akira Tanimoto
 
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기JangHyuk You
 
Hybrid Atlas Models of Financial Equity Market
Hybrid Atlas Models of Financial Equity MarketHybrid Atlas Models of Financial Equity Market
Hybrid Atlas Models of Financial Equity Markettomoyukiichiba
 
University of manchester mathematical formula tables
University of manchester mathematical formula tablesUniversity of manchester mathematical formula tables
University of manchester mathematical formula tablesGaurav Vasani
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1Ke Wei Louis
 
Predictably
PredictablyPredictably
Predictablyztellman
 
R Cheat Sheet for Data Analysts and Statisticians.pdf
R Cheat Sheet for Data Analysts and Statisticians.pdfR Cheat Sheet for Data Analysts and Statisticians.pdf
R Cheat Sheet for Data Analysts and Statisticians.pdfTimothy McBush Hiele
 
03 truncation errors
03 truncation errors03 truncation errors
03 truncation errorsmaheej
 
Seismic data processing lecture 3
Seismic data processing lecture 3Seismic data processing lecture 3
Seismic data processing lecture 3Amin khalil
 

Semelhante a PAIP 第1章 Lisp入門 (20)

ฟังก์ชัน(function)
ฟังก์ชัน(function)ฟังก์ชัน(function)
ฟังก์ชัน(function)
 
ฟังก์ชัน 1
ฟังก์ชัน 1ฟังก์ชัน 1
ฟังก์ชัน 1
 
ฟังก์ชัน(function)
ฟังก์ชัน(function)ฟังก์ชัน(function)
ฟังก์ชัน(function)
 
Aaron Ellison Keynote: Reaching the 99%
Aaron Ellison Keynote: Reaching the 99%Aaron Ellison Keynote: Reaching the 99%
Aaron Ellison Keynote: Reaching the 99%
 
Zero Theorem and Rational Roots Presentation
Zero Theorem and Rational Roots PresentationZero Theorem and Rational Roots Presentation
Zero Theorem and Rational Roots Presentation
 
The Magnificent Seven
The Magnificent SevenThe Magnificent Seven
The Magnificent Seven
 
Lecture4 kenrels functions_rkhs
Lecture4 kenrels functions_rkhsLecture4 kenrels functions_rkhs
Lecture4 kenrels functions_rkhs
 
1531 fourier series- integrals and trans
1531 fourier series- integrals and trans1531 fourier series- integrals and trans
1531 fourier series- integrals and trans
 
Ecma script 5
Ecma script 5Ecma script 5
Ecma script 5
 
MLP輪読スパース8章 トレースノルム正則化
MLP輪読スパース8章 トレースノルム正則化MLP輪読スパース8章 トレースノルム正則化
MLP輪読スパース8章 トレースノルム正則化
 
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기
 
Hybrid Atlas Models of Financial Equity Market
Hybrid Atlas Models of Financial Equity MarketHybrid Atlas Models of Financial Equity Market
Hybrid Atlas Models of Financial Equity Market
 
University of manchester mathematical formula tables
University of manchester mathematical formula tablesUniversity of manchester mathematical formula tables
University of manchester mathematical formula tables
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1
 
CQL 实现
CQL 实现CQL 实现
CQL 实现
 
Lambda calculus
Lambda calculusLambda calculus
Lambda calculus
 
Predictably
PredictablyPredictably
Predictably
 
R Cheat Sheet for Data Analysts and Statisticians.pdf
R Cheat Sheet for Data Analysts and Statisticians.pdfR Cheat Sheet for Data Analysts and Statisticians.pdf
R Cheat Sheet for Data Analysts and Statisticians.pdf
 
03 truncation errors
03 truncation errors03 truncation errors
03 truncation errors
 
Seismic data processing lecture 3
Seismic data processing lecture 3Seismic data processing lecture 3
Seismic data processing lecture 3
 

Último

2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 

PAIP 第1章 Lisp入門

  • 1. PAIP 1 Lisp yadokarielectric | yad-EL
  • 2. 1.10 • 1 • • 1
  • 3. •1 1 • 1 1 • 1 1 • •
  • 4. • • OK •
  • 6. • Lisp •( 1 2 …) • • (+ 1 (* 2 3 4) 5)
  • 7. • • • (if then else ) • if then elese
  • 8. • • setf • (setf abc 3)
  • 10. • (setf x (1 2 3)) (1 2 3) 1 • (setf x (list 1 2 3))
  • 11. quote • quote • (setf x (quote (1 2 3))) • ' • (setf x '(1 2 3))
  • 12. (setf p '(JOHN Q PUBLIC)) • (first p) • (cons 'Mr p) • (rest p) • (cons (first p) (rest p)) • (second p) • (last p) • (third p) • (first (last p)) • (fourth p) • (length p)
  • 13. defun • (defun ( 1 2…) " " …)
  • 14. • • mapcar • function #' • (mapcar #'last-name names)
  • 15. 1.1 (defparameter *suffix* '(MD Jr. |,|)) (defun last-name (name) (if (member (first (last name)) *suffix*) (last-name (butlast name)) (first (last name))))
  • 16. n=28 1.2 loop-power 27 power (defun loop-power (x n) (let ((r 1)) 28 2 (dotimes (i n) 14 2 (setf r (* r x))) 7 x r)) 6 2 3 x (defun square (x) (* x x)) 2 2 (defun power (x n) 6 (cond ((= n 0) 1) ((evenp n) (square (power x (/ n 2)))) (t (* x (power x (- n 1))))))
  • 17. 1.3 nil (defun count-atoms (exp) (cond ((null exp) 0) ((atom exp) 1) (t (+ (count-atoms (first exp)) (count-atoms (rest exp))))))
  • 18. 1.3 nil (defun count-all-atoms (exp &optional (if-null 1)) (cond ((null exp) if-null) ((atom exp) 1) (t (+ (count-all-atoms (first exp) 1) (count-all-atoms (rest exp) 0)))))
  • 19. 1.4 (defun count-anywhere (item tree) (cond ((eql item tree) 1) ((atom tree) 0) (t (+ (count-anywhere item (first tree)) (count-anywhere item (rest tree))))))
  • 20. 1.5 (defun dot-product (a b) (if (or (null a) (null b)) 0 (+ (* (first a) (first b)) (dot-product (rest a) (rest b))))) (defun dot-product (a b) (let ((sum 0)) (dotimes (i (length a)) (incf sum (* (elt a i) (elt b i)))) sum)) (defun dot-product (a b) (apply #'+ (mapcar #'* a b)))

Notas do Editor