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

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 

Último (20)

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 

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