SlideShare una empresa de Scribd logo
1 de 60
Descargar para leer sin conexión
Lisp’style code with JS
                  Lisp’



                          by Aleksandr Motsjonov
вторник, 5 июля 2011 г.
Lisp’style code with JS
                  Lisp’
                          Or «The Little JavaScripter»




                             by Aleksandr Motsjonov
вторник, 5 июля 2011 г.
Lisp’style code with JS
                  Lisp’
                          Or how to make JavaScript ugly ...




                             by Aleksandr Motsjonov
вторник, 5 июля 2011 г.
Scheme’
    Lisp’style code with JS
                          Or how to make JavaScript ugly ...




                             by Aleksandr Motsjonov
вторник, 5 июля 2011 г.
Douglas Crockford




вторник, 5 июля 2011 г.
Douglas Crockford




вторник, 5 июля 2011 г.
Douglas Crockford




вторник, 5 июля 2011 г.
Douglas Crockford

                          • Everytime Douglas Crockford blinks his
                           eyes, another IE6 instance is killed.




вторник, 5 июля 2011 г.
Douglas Crockford

                          • Everytime Douglas Crockford blinks his
                              eyes, another IE6 instance is killed.
                          •   Every time you declare a variable in the
                              global scope, Douglas Crockford kills a
                              kitten.




вторник, 5 июля 2011 г.
Douglas Crockford

                          • Everytime Douglas Crockford blinks his
                        eyes, another IE6 instance is killed.
                      • Every time you declare a variable in the
                        global scope, Douglas Crockford kills a
                        kitten.
 •   There is only one necessary global, and that is Douglas
     Crockford




вторник, 5 июля 2011 г.
Douglas Crockford

                          • Everytime Douglas Crockford blinks his
                        eyes, another IE6 instance is killed.
                      • Every time you declare a variable in the
                        global scope, Douglas Crockford kills a
                        kitten.
 •   There is only one necessary global, and that is Douglas
     Crockford
 •   JohnResig == awesome, but DouglasCrockford === awesome




вторник, 5 июля 2011 г.
Douglas Crockford

                          • Everytime Douglas Crockford blinks his
                          eyes, another IE6 instance is killed.
                        • Every time you declare a variable in the
                          global scope, Douglas Crockford kills a
                          kitten.
 •   There is only one necessary global, and that is Douglas
     Crockford
 •   JohnResig == awesome, but DouglasCrockford === awesome
 •   “I’m your father, John”



вторник, 5 июля 2011 г.
Douglas Crockford

                          • Everytime Douglas Crockford blinks his
                          eyes, another IE6 instance is killed.
                        • Every time you declare a variable in the
                          global scope, Douglas Crockford kills a
                          kitten.
 •   There is only one necessary global, and that is Douglas
     Crockford
 •   JohnResig == awesome, but DouglasCrockford === awesome
 •   “I’m your father, John”
 •   In truth there exists no anonymous functions in JavaScript
     because Douglas Crockford loves and names all of his
     children.
вторник, 5 июля 2011 г.
Douglas Crockford

                          • Everytime Douglas Crockford blinks his
                          eyes, another IE6 instance is killed.
                        • Every time you declare a variable in the
                          global scope, Douglas Crockford kills a
                          JavaScript Guru!
                          kitten.
 •   There is only one necessary global, and that is Douglas
     Crockford
 •   JohnResig == awesome, but DouglasCrockford === awesome
 •   “I’m your father, John”
 •   In truth there exists no anonymous functions in JavaScript
     because Douglas Crockford loves and names all of his
     children.
вторник, 5 июля 2011 г.
вторник, 5 июля 2011 г.
вторник, 5 июля 2011 г.
« ... it did a remarkable
                          thing: It could teach you
                          to think recursively »




вторник, 5 июля 2011 г.
« ... it did a remarkable
                          thing: It could teach you
                          to think recursively »


                          « ... all of the functions
                          in The Little Schemer
                          can be written in
                          JavaScript. »




вторник, 5 июля 2011 г.
« ... it did a remarkable
                          thing: It could teach you
                          to think recursively »


                          « ... all of the functions
                          in The Little Schemer
                          can be written in
                          JavaScript. »


                          «So get a copy of The
                          Little Schemer and
                          start recursing ... »

вторник, 5 июля 2011 г.
« ... it did a remarkable
                                       thing: It could teach you
                                       to think recursively »


                                      « ... all of the functions
                                      in The Little Schemer
                          And so I   didn...b e w r i t t e n i n
                                      ca
                                      JavaScript. »


                                      «So get a copy of The
                                      Little Schemer and
                                      start recursing ... »

вторник, 5 июля 2011 г.
Primitives
            car, cdr, cons, null?, eq?, zero?




вторник, 5 июля 2011 г.
Primitives
            car, cdr, cons, isNull, eq?, zero?
                            null?, isEq, isZero




вторник, 5 июля 2011 г.
Primitives
            car, cdr, cons, isNull, eq?, zero?
                            null?, isEq, isZero

  car = function(list) {               isZero = function(number){
     return list[0];                      return number === 0;
  };                                   };
  cdr = function(list) {               isNull = function(list) {
     return list.slice(1);                return list.length === 0;
  };                                   };
  cons = function(atom, list) {        isEq = function(o1, o2) {
     var tmp = utils.copy_arr(list);      return o1 === o2;
     tmp.splice(0, 0, atom);           };
     return tmp;
  };



вторник, 5 июля 2011 г.
Primitives
            car, cdr, cons, isNull, eq?, zero?
                            null?, isEq, isZero

  car = function(list) {               isZero = function(number){
     return list[0];                      return number === 0;
  };                                   };
  cdr = function(list) {
     return list.slice(1);
                             cond ?    isNull = function(list) {
                                          return list.length === 0;
  };                                   };
  cons = function(atom, list) {        isEq = function(o1, o2) {
     var tmp = utils.copy_arr(list);      return o1 === o2;
     tmp.splice(0, 0, atom);           };
     return tmp;
  };



вторник, 5 июля 2011 г.
Cond
                          (cond (question1 answer1)
                                (question2 answer2)
                                ...
                                (else else_answer))




вторник, 5 июля 2011 г.
Cond
                          (cond (question1 answer1)
                                (question2 answer2)
                                ...
                                (else else_answer))


                     (define member?
                       (lambda (a lat)
                         (cond
                           ((null? lat) #f)
                           (else (or (eq? (car lat) a)
                                     (member? a cdr(lat)))))))



вторник, 5 июля 2011 г.
Cond
                          (cond (question1 answer1)
                                (question2 answer2)
                                ...
                                (else else_answer))


                     (define member?
                       (lambda (a lat)
                         (cond
                           ((null? lat) #f)
                           (else (or (eq? (car lat) a)
                                     (member? a cdr(lat)))))))



вторник, 5 июля 2011 г.
Cond
                          (cond (question1 answer1)
                                (question2 answer2)
                                ...
                                (else else_answer))


                     (define member?
                       (lambda (a lat)
                         (cond
                           ((null? lat) #f)
                           (else (or (eq? (car lat) a)
                                     (member? a cdr(lat)))))))



вторник, 5 июля 2011 г.
Cond
                          (cond (question1 answer1)
                                (question2 answer2)
                                ...
                                (else else_answer))


                     (define member?
                       (lambda (a lat)
                         (cond
                           ((null? lat) #f)
                           (else (or (eq? (car lat) a)
                                     (member? a cdr(lat)))))))



вторник, 5 июля 2011 г.
Cond
                          (cond (question1 answer1)
                                (question2 answer2)
                                ...
                                (else else_answer))


                     (define member?
                       (lambda (a lat)
                         (cond
                           ((null? lat) #f)
                           (else (or (eq? (car lat) a)
                                     (member? a cdr(lat)))))))



вторник, 5 июля 2011 г.
Cond
                          (cond (question1 answer1)
                                (question2 answer2)
                                ...
                                (else else_answer))


                     (define member?
                       (lambda (a lat)
                         (cond
                           ((null? lat) #f)
                           (else (or (eq? (car lat) a)
                                     (member? a cdr(lat)))))))



вторник, 5 июля 2011 г.
Cond
                          (cond (question1 answer1)
                                (question2 answer2)
                                ...
                                (else else_answer))


                     (define member?
                       (lambda (a lat)
                         (cond
                           ((null? lat) #f)
                           (else (or (eq? (car lat) a)
                                     (member? a cdr(lat)))))))



вторник, 5 июля 2011 г.
Cond
                          (cond (question1 answer1)
                                (question2 answer2)
                                ...
                                (else else_answer))


                     (define member?
                       (lambda (a lat)
                         (cond
                           ((null? lat) #f)
                           (else (or (eq? (car lat) a)
                                     (member? a cdr(lat)))))))



вторник, 5 июля 2011 г.
Cond
                          (cond (question1 answer1)
                                (question2 answer2)
                                ...
                                (else else_answer))


                     (define member?
                       (lambda (a lat)
                         (cond
                           ((null? lat) #f)
                           (else (or (eq? (car lat) a)
                                     (member? a cdr(lat)))))))



вторник, 5 июля 2011 г.
Cond
                          (cond (question1 answer1)
                                (question2 answer2)
                                ...
                                (else else_answer))


                     (define member?
                       (lambda (a lat)
                         (cond
                           ((null? lat) #f)
                           (else (or (eq? (car lat) a)
                                     (member? a cdr(lat)))))))



вторник, 5 июля 2011 г.
Cond
                  if (question1){return answer1;}
             else if (question2){return answer2;}
                  ...
                  else {return else_answer;}




вторник, 5 июля 2011 г.
Cond
                  if (question1){return answer1;}
             else if (question2){return answer2;}
                  ...
                  else {return else_answer;}

                          function isMember(a, lat){
                            if (isNull(lat)){
                              return false;
                            }else{
                              return isEq(car(lat), a) ||
                                     isMember(a, cdr(lat));
                            }
                          }

вторник, 5 июля 2011 г.
Cond
                  if (question1){return answer1;}
             else if (question2){return answer2;}
                  ...
                  else {return else_answer;}

                          function isMember(a, lat){
                            if (isNull(lat)){
                              return false;
                            }else{
                              return isEq(car(lat), a) ||
                                     isMember(a, cdr(lat));
                            }
                          }

вторник, 5 июля 2011 г.
Cond




вторник, 5 июля 2011 г.
Cond
                          (cond (question1 answer1)
                                (question2 answer2)
                                ...
                                (else else_answer))




вторник, 5 июля 2011 г.
Cond
                          (cond (question1 answer1)
                           cond((question1
                                (question2 answer2)
                                ...
                                (else else_answer))




вторник, 5 июля 2011 г.
Cond
                          (cond (question1 answer1)
                           cond([question1
                           cond((question1 answer1]
                                [question2 answer2]
                                (question2 answer2)
                                ...
                                [else else_answer])
                                (else else_answer))




вторник, 5 июля 2011 г.
Cond
                          (cond (question1 answer1)
                           cond([question1
                           cond((question1 answer1]
                           cond([question1,answer1],
                                [question2 answer2]
                                (question2 answer2)
                                [question2,answer2],
                                ...
                                [else else_answer])
                                (else else_answer))
                                [else,




вторник, 5 июля 2011 г.
Cond
                          (cond (question1 answer1)
                           cond([question1
                           cond((question1 answer1]
                           cond([question1,answer1],
                                [question2 answer2]
                                (question2 answer2)
                                [question2,answer2],
                                ...
                                [else else_answer])
                                (else else_answer))
                                [else,
                                [else_answer])




вторник, 5 июля 2011 г.
Cond
                          (cond (question1 answer1)
                           cond([question1
                           cond((question1 answer1]
                           cond([question1,answer1],
                                [question2 answer2]
                                (question2 answer2)
                                [question2,answer2],
                                ...
                                [else else_answer])
                                (else else_answer))
                                [else,
                                [else_answer])
                                else_answer)




вторник, 5 июля 2011 г.
Cond
                           (cond (question1 answer1)
                            cond([question1
                            cond((question1 answer1]
                            cond([question1,answer1],
                                 [question2 answer2]
                                 (question2 answer2)
                                 [question2,answer2],
                                 ...
                                 [else else_answer])
                                 (else else_answer))
                                 [else,
                                 [else_answer])
                                 else_answer)

                          function isMember(a, lat) {
                            return cond(
                               [isNull(lat), false],
                               or(
                                 isEq(a, car(lat)),
                                 isMember(a, cdr(lat))
                               )
                            );

вторник, 5 июля 2011 г.
Cond
                   function isMember(a, lat) {
                      return cond(
                         [isNull(lat), false],
                         function() {
                           return or(isEq(a, car(lat)),
                                      isMember(a, cdr(lat))
                           );
                         }
                      );
                   };



вторник, 5 июля 2011 г.
Cond
                   function isMember(a, lat) {
                      return cond(
                         [isNull(lat), false],
                         function() {
                           return or(isEq(a, car(lat)),
                                      isMember(a, cdr(lat))
                           );
                         }
                      );
                   };



вторник, 5 июля 2011 г.
Cond
                          function cond() {
                             var args = utils.copy_arr(arguments), i = 0;
                             for (; i < args.length; i++) {
                               if(utils.is_array(args[i])){
                                 if (args[i].length == 1) {
                                   return de(args[i][0]);
                                 } else if (args[i].length == 2) {
                                   if (de(args[i][0])) {
                                      return de(args[i][1]);
                                   }
                                 } else {
                                   //throw exception;
                                 }
                               }else{
                                 return de(args[i]);
                               }
                             }
                          };

                          function de(obj) {
                            return utils.is_function(obj) ? obj() : obj;
                          }

вторник, 5 июля 2011 г.
Example
                     function occur(a, lat){
                        return cond(
                           [isNull(lat), 0],
                           [isEqan(a, car(lat)), function(){
                             return add1(occur(a, cdr(lat)));
                           }],
                           function(){
                             return occur(a, cdr(lat));
                           }
                        );
                     };


вторник, 5 июля 2011 г.
Example
                     function occur(a, lat){
                        return cond(
                           [isNull(lat), 0],
                           [isEqan(a, car(lat)), function(){
                             return add1(occur(a, cdr(lat)));
                           }],
                           function(){
                             return occur(a, cdr(lat));
                           }
                        );
                     };


вторник, 5 июля 2011 г.
Example
                     function occur(a, lat){
                        return cond(
                           [isNull(lat), 0],
                           [isEqan(a, car(lat)), function(){
                             return add1(occur(a, cdr(lat)));
                           }],
                           function(){
                             return occur(a, cdr(lat));
                           }
                        );
                     };


вторник, 5 июля 2011 г.
Example
   function insertR(n, o, lat){
      return cond(
         [is_null(lat), quote()],
         [function(){
            return cond (
               [or(
                    is_number(car(lat)),
                    is_atom(car(lat))
                  ), cond(
                      [is_eqan(car(lat), o), function(){
                        return cons(insertR(n, o, cdr(lat)), n);
                      }],
                      function(){
                        return cons(car(lat), insertR(n, o, cdr(lat)));
                      }
                    )
               ],
               function(){
                  return cons(insertR(n, o, car(lat)), insertR(n, o, cdr(lat)));
               }
            );
         }]
      );
   };
вторник, 5 июля 2011 г.
Example
   function insertR(n, o, lat){
      return cond(
         [is_null(lat), quote()],
         [function(){
            return cond((
                      cond
               [or(
                    is_number(car(lat)),
                    is_atom(car(lat))
                  ), cond(
                       [is_eqan(car(lat), o), function(){
                         return cons(insertR(n, o, cdr(lat)), n);
                       }],
                       function(){
                         return cons(car(lat), insertR(n, o, cdr(lat)));
                       }
                    )
               ],
               function(){
                  return cons(insertR(n, o, car(lat)), insertR(n, o, cdr(lat)));
               }
            );
         }]
      );
   };
вторник, 5 июля 2011 г.
Example
   function insertR(n, o, lat){
      return cond(
         [is_null(lat), quote()],
         [function(){
            return cond((
                      cond
               [or(
                    is_number(car(lat)),
                    is_atom(car(lat))
                  ), cond(
                       [is_eqan(car(lat), o), function(){
                         return cons(insertR(n, o, cdr(lat)), n);
                       }],
                       function(){
                         return cons(car(lat), insertR(n, o, cdr(lat)));
                       }
                    )
               ],
               function(){
                  return cons(insertR(n, o, car(lat)), insertR(n, o, cdr(lat)));
               }
            );
         }]
      );
   };
вторник, 5 июля 2011 г.
Example
   function insertR(n, o, lat){
      return cond(
         [is_null(lat), quote()],
         [function(){
            return cond((
                      cond
               [or(
                    is_number(car(lat)),
                    is_atom(car(lat))
                  ), cond(
                       [is_eqan(car(lat), o), function(){
                         return cons(insertR(n, o, cdr(lat)), n);
                       }],
                       function(){
                         return cons(car(lat), insertR(n, o, cdr(lat)));
                       }
                    )
               ],
               function(){
                  return cons(insertR(n, o, car(lat)), insertR(n, o, cdr(lat)));
               }
            );
         }]
      );
   };
вторник, 5 июля 2011 г.
What if ...
                          function occur(a, lat){
                             return cond(
                                [isNull(lat), 0],
                                [isEqan(a, car(lat)), function(){
                                  return add1(occur(a, cdr(lat)));
                                }],
                                function(){
                                  return occur(a, cdr(lat));
                                }
                             );
                          };



вторник, 5 июля 2011 г.
What if ...
                          function occur(a, lat){
                             return cond(
                                [isNull(lat), 0],
                                [isEqan(a, car(lat)), function(){
                                  return add1(occur(a, cdr(lat)));
                                }],
                                function(){
                                  return occur(a, cdr(lat));
                                }
                             );
                          };



вторник, 5 июля 2011 г.
What if ...
                          # occur(a, lat){
                          function occur(a, lat){
                             return cond(
                             cond(
                                [isNull(lat), 0],
                                [isEqan(a, car(lat)), function(){
                                                       #{
                                   return add1(occur(a, cdr(lat)));
                                   add1(occur(a, cdr(lat)));
                                }],
                                #{
                                function(){
                                   occur(a, cdr(lat));
                                   return occur(a, cdr(lat));
                                }
                             );
                          };



вторник, 5 июля 2011 г.
I am done. Thx!
                          # occur(a, lat){
                             cond(
                                [isNull(lat), 0],
                                [isEqan(a, car(lat)), #{
                                   add1(occur(a, cdr(lat)));
                                }],
                                #{
                                   occur(a, cdr(lat));
                                }
                             );
                          };



вторник, 5 июля 2011 г.

Más contenido relacionado

Último (9)

CVE. The Fortra's GoAnywhere MFT [RU].pdf
CVE. The Fortra's GoAnywhere MFT [RU].pdfCVE. The Fortra's GoAnywhere MFT [RU].pdf
CVE. The Fortra's GoAnywhere MFT [RU].pdf
 
2023 Q4. The Ransomware report. [RU].pdf
2023 Q4. The Ransomware report. [RU].pdf2023 Q4. The Ransomware report. [RU].pdf
2023 Q4. The Ransomware report. [RU].pdf
 
MS Navigating Incident Response [RU].pdf
MS Navigating Incident Response [RU].pdfMS Navigating Incident Response [RU].pdf
MS Navigating Incident Response [RU].pdf
 
Cyberprint. Dark Pink Apt Group [RU].pdf
Cyberprint. Dark Pink Apt Group [RU].pdfCyberprint. Dark Pink Apt Group [RU].pdf
Cyberprint. Dark Pink Apt Group [RU].pdf
 
Cyber Defense Doctrine Managing the Risk Full Applied Guide to Organizational...
Cyber Defense Doctrine Managing the Risk Full Applied Guide to Organizational...Cyber Defense Doctrine Managing the Risk Full Applied Guide to Organizational...
Cyber Defense Doctrine Managing the Risk Full Applied Guide to Organizational...
 
ИСТОЧНИКИ ИННОВАЦИОННОСТИ КИТАЯ (ПО ВЕРСИИ DGAP) | The Sources of China’s Inn...
ИСТОЧНИКИ ИННОВАЦИОННОСТИ КИТАЯ (ПО ВЕРСИИ DGAP) | The Sources of China’s Inn...ИСТОЧНИКИ ИННОВАЦИОННОСТИ КИТАЯ (ПО ВЕРСИИ DGAP) | The Sources of China’s Inn...
ИСТОЧНИКИ ИННОВАЦИОННОСТИ КИТАЯ (ПО ВЕРСИИ DGAP) | The Sources of China’s Inn...
 
Ransomware_Q3 2023. The report [RU].pdf
Ransomware_Q3 2023.  The report [RU].pdfRansomware_Q3 2023.  The report [RU].pdf
Ransomware_Q3 2023. The report [RU].pdf
 
Malware. DCRAT (DARK CRYSTAL RAT) [RU].pdf
Malware. DCRAT (DARK CRYSTAL RAT) [RU].pdfMalware. DCRAT (DARK CRYSTAL RAT) [RU].pdf
Malware. DCRAT (DARK CRYSTAL RAT) [RU].pdf
 
СИСТЕМА ОЦЕНКИ УЯЗВИМОСТЕЙ CVSS 4.0 / CVSS v4.0 [RU].pdf
СИСТЕМА ОЦЕНКИ УЯЗВИМОСТЕЙ CVSS 4.0 / CVSS v4.0 [RU].pdfСИСТЕМА ОЦЕНКИ УЯЗВИМОСТЕЙ CVSS 4.0 / CVSS v4.0 [RU].pdf
СИСТЕМА ОЦЕНКИ УЯЗВИМОСТЕЙ CVSS 4.0 / CVSS v4.0 [RU].pdf
 

Destacado

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destacado (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

Lisp'styled JavaScript

  • 1. Lisp’style code with JS Lisp’ by Aleksandr Motsjonov вторник, 5 июля 2011 г.
  • 2. Lisp’style code with JS Lisp’ Or «The Little JavaScripter» by Aleksandr Motsjonov вторник, 5 июля 2011 г.
  • 3. Lisp’style code with JS Lisp’ Or how to make JavaScript ugly ... by Aleksandr Motsjonov вторник, 5 июля 2011 г.
  • 4. Scheme’ Lisp’style code with JS Or how to make JavaScript ugly ... by Aleksandr Motsjonov вторник, 5 июля 2011 г.
  • 8. Douglas Crockford • Everytime Douglas Crockford blinks his eyes, another IE6 instance is killed. вторник, 5 июля 2011 г.
  • 9. Douglas Crockford • Everytime Douglas Crockford blinks his eyes, another IE6 instance is killed. • Every time you declare a variable in the global scope, Douglas Crockford kills a kitten. вторник, 5 июля 2011 г.
  • 10. Douglas Crockford • Everytime Douglas Crockford blinks his eyes, another IE6 instance is killed. • Every time you declare a variable in the global scope, Douglas Crockford kills a kitten. • There is only one necessary global, and that is Douglas Crockford вторник, 5 июля 2011 г.
  • 11. Douglas Crockford • Everytime Douglas Crockford blinks his eyes, another IE6 instance is killed. • Every time you declare a variable in the global scope, Douglas Crockford kills a kitten. • There is only one necessary global, and that is Douglas Crockford • JohnResig == awesome, but DouglasCrockford === awesome вторник, 5 июля 2011 г.
  • 12. Douglas Crockford • Everytime Douglas Crockford blinks his eyes, another IE6 instance is killed. • Every time you declare a variable in the global scope, Douglas Crockford kills a kitten. • There is only one necessary global, and that is Douglas Crockford • JohnResig == awesome, but DouglasCrockford === awesome • “I’m your father, John” вторник, 5 июля 2011 г.
  • 13. Douglas Crockford • Everytime Douglas Crockford blinks his eyes, another IE6 instance is killed. • Every time you declare a variable in the global scope, Douglas Crockford kills a kitten. • There is only one necessary global, and that is Douglas Crockford • JohnResig == awesome, but DouglasCrockford === awesome • “I’m your father, John” • In truth there exists no anonymous functions in JavaScript because Douglas Crockford loves and names all of his children. вторник, 5 июля 2011 г.
  • 14. Douglas Crockford • Everytime Douglas Crockford blinks his eyes, another IE6 instance is killed. • Every time you declare a variable in the global scope, Douglas Crockford kills a JavaScript Guru! kitten. • There is only one necessary global, and that is Douglas Crockford • JohnResig == awesome, but DouglasCrockford === awesome • “I’m your father, John” • In truth there exists no anonymous functions in JavaScript because Douglas Crockford loves and names all of his children. вторник, 5 июля 2011 г.
  • 17. « ... it did a remarkable thing: It could teach you to think recursively » вторник, 5 июля 2011 г.
  • 18. « ... it did a remarkable thing: It could teach you to think recursively » « ... all of the functions in The Little Schemer can be written in JavaScript. » вторник, 5 июля 2011 г.
  • 19. « ... it did a remarkable thing: It could teach you to think recursively » « ... all of the functions in The Little Schemer can be written in JavaScript. » «So get a copy of The Little Schemer and start recursing ... » вторник, 5 июля 2011 г.
  • 20. « ... it did a remarkable thing: It could teach you to think recursively » « ... all of the functions in The Little Schemer And so I didn...b e w r i t t e n i n ca JavaScript. » «So get a copy of The Little Schemer and start recursing ... » вторник, 5 июля 2011 г.
  • 21. Primitives car, cdr, cons, null?, eq?, zero? вторник, 5 июля 2011 г.
  • 22. Primitives car, cdr, cons, isNull, eq?, zero? null?, isEq, isZero вторник, 5 июля 2011 г.
  • 23. Primitives car, cdr, cons, isNull, eq?, zero? null?, isEq, isZero car = function(list) { isZero = function(number){ return list[0]; return number === 0; }; }; cdr = function(list) { isNull = function(list) { return list.slice(1); return list.length === 0; }; }; cons = function(atom, list) { isEq = function(o1, o2) { var tmp = utils.copy_arr(list); return o1 === o2; tmp.splice(0, 0, atom); }; return tmp; }; вторник, 5 июля 2011 г.
  • 24. Primitives car, cdr, cons, isNull, eq?, zero? null?, isEq, isZero car = function(list) { isZero = function(number){ return list[0]; return number === 0; }; }; cdr = function(list) { return list.slice(1); cond ? isNull = function(list) { return list.length === 0; }; }; cons = function(atom, list) { isEq = function(o1, o2) { var tmp = utils.copy_arr(list); return o1 === o2; tmp.splice(0, 0, atom); }; return tmp; }; вторник, 5 июля 2011 г.
  • 25. Cond (cond (question1 answer1) (question2 answer2) ... (else else_answer)) вторник, 5 июля 2011 г.
  • 26. Cond (cond (question1 answer1) (question2 answer2) ... (else else_answer)) (define member? (lambda (a lat) (cond ((null? lat) #f) (else (or (eq? (car lat) a) (member? a cdr(lat))))))) вторник, 5 июля 2011 г.
  • 27. Cond (cond (question1 answer1) (question2 answer2) ... (else else_answer)) (define member? (lambda (a lat) (cond ((null? lat) #f) (else (or (eq? (car lat) a) (member? a cdr(lat))))))) вторник, 5 июля 2011 г.
  • 28. Cond (cond (question1 answer1) (question2 answer2) ... (else else_answer)) (define member? (lambda (a lat) (cond ((null? lat) #f) (else (or (eq? (car lat) a) (member? a cdr(lat))))))) вторник, 5 июля 2011 г.
  • 29. Cond (cond (question1 answer1) (question2 answer2) ... (else else_answer)) (define member? (lambda (a lat) (cond ((null? lat) #f) (else (or (eq? (car lat) a) (member? a cdr(lat))))))) вторник, 5 июля 2011 г.
  • 30. Cond (cond (question1 answer1) (question2 answer2) ... (else else_answer)) (define member? (lambda (a lat) (cond ((null? lat) #f) (else (or (eq? (car lat) a) (member? a cdr(lat))))))) вторник, 5 июля 2011 г.
  • 31. Cond (cond (question1 answer1) (question2 answer2) ... (else else_answer)) (define member? (lambda (a lat) (cond ((null? lat) #f) (else (or (eq? (car lat) a) (member? a cdr(lat))))))) вторник, 5 июля 2011 г.
  • 32. Cond (cond (question1 answer1) (question2 answer2) ... (else else_answer)) (define member? (lambda (a lat) (cond ((null? lat) #f) (else (or (eq? (car lat) a) (member? a cdr(lat))))))) вторник, 5 июля 2011 г.
  • 33. Cond (cond (question1 answer1) (question2 answer2) ... (else else_answer)) (define member? (lambda (a lat) (cond ((null? lat) #f) (else (or (eq? (car lat) a) (member? a cdr(lat))))))) вторник, 5 июля 2011 г.
  • 34. Cond (cond (question1 answer1) (question2 answer2) ... (else else_answer)) (define member? (lambda (a lat) (cond ((null? lat) #f) (else (or (eq? (car lat) a) (member? a cdr(lat))))))) вторник, 5 июля 2011 г.
  • 35. Cond (cond (question1 answer1) (question2 answer2) ... (else else_answer)) (define member? (lambda (a lat) (cond ((null? lat) #f) (else (or (eq? (car lat) a) (member? a cdr(lat))))))) вторник, 5 июля 2011 г.
  • 36. Cond if (question1){return answer1;} else if (question2){return answer2;} ... else {return else_answer;} вторник, 5 июля 2011 г.
  • 37. Cond if (question1){return answer1;} else if (question2){return answer2;} ... else {return else_answer;} function isMember(a, lat){ if (isNull(lat)){ return false; }else{ return isEq(car(lat), a) || isMember(a, cdr(lat)); } } вторник, 5 июля 2011 г.
  • 38. Cond if (question1){return answer1;} else if (question2){return answer2;} ... else {return else_answer;} function isMember(a, lat){ if (isNull(lat)){ return false; }else{ return isEq(car(lat), a) || isMember(a, cdr(lat)); } } вторник, 5 июля 2011 г.
  • 40. Cond (cond (question1 answer1) (question2 answer2) ... (else else_answer)) вторник, 5 июля 2011 г.
  • 41. Cond (cond (question1 answer1) cond((question1 (question2 answer2) ... (else else_answer)) вторник, 5 июля 2011 г.
  • 42. Cond (cond (question1 answer1) cond([question1 cond((question1 answer1] [question2 answer2] (question2 answer2) ... [else else_answer]) (else else_answer)) вторник, 5 июля 2011 г.
  • 43. Cond (cond (question1 answer1) cond([question1 cond((question1 answer1] cond([question1,answer1], [question2 answer2] (question2 answer2) [question2,answer2], ... [else else_answer]) (else else_answer)) [else, вторник, 5 июля 2011 г.
  • 44. Cond (cond (question1 answer1) cond([question1 cond((question1 answer1] cond([question1,answer1], [question2 answer2] (question2 answer2) [question2,answer2], ... [else else_answer]) (else else_answer)) [else, [else_answer]) вторник, 5 июля 2011 г.
  • 45. Cond (cond (question1 answer1) cond([question1 cond((question1 answer1] cond([question1,answer1], [question2 answer2] (question2 answer2) [question2,answer2], ... [else else_answer]) (else else_answer)) [else, [else_answer]) else_answer) вторник, 5 июля 2011 г.
  • 46. Cond (cond (question1 answer1) cond([question1 cond((question1 answer1] cond([question1,answer1], [question2 answer2] (question2 answer2) [question2,answer2], ... [else else_answer]) (else else_answer)) [else, [else_answer]) else_answer) function isMember(a, lat) { return cond( [isNull(lat), false], or( isEq(a, car(lat)), isMember(a, cdr(lat)) ) ); вторник, 5 июля 2011 г.
  • 47. Cond function isMember(a, lat) { return cond( [isNull(lat), false], function() { return or(isEq(a, car(lat)), isMember(a, cdr(lat)) ); } ); }; вторник, 5 июля 2011 г.
  • 48. Cond function isMember(a, lat) { return cond( [isNull(lat), false], function() { return or(isEq(a, car(lat)), isMember(a, cdr(lat)) ); } ); }; вторник, 5 июля 2011 г.
  • 49. Cond function cond() { var args = utils.copy_arr(arguments), i = 0; for (; i < args.length; i++) { if(utils.is_array(args[i])){ if (args[i].length == 1) { return de(args[i][0]); } else if (args[i].length == 2) { if (de(args[i][0])) { return de(args[i][1]); } } else { //throw exception; } }else{ return de(args[i]); } } }; function de(obj) { return utils.is_function(obj) ? obj() : obj; } вторник, 5 июля 2011 г.
  • 50. Example function occur(a, lat){ return cond( [isNull(lat), 0], [isEqan(a, car(lat)), function(){ return add1(occur(a, cdr(lat))); }], function(){ return occur(a, cdr(lat)); } ); }; вторник, 5 июля 2011 г.
  • 51. Example function occur(a, lat){ return cond( [isNull(lat), 0], [isEqan(a, car(lat)), function(){ return add1(occur(a, cdr(lat))); }], function(){ return occur(a, cdr(lat)); } ); }; вторник, 5 июля 2011 г.
  • 52. Example function occur(a, lat){ return cond( [isNull(lat), 0], [isEqan(a, car(lat)), function(){ return add1(occur(a, cdr(lat))); }], function(){ return occur(a, cdr(lat)); } ); }; вторник, 5 июля 2011 г.
  • 53. Example function insertR(n, o, lat){ return cond( [is_null(lat), quote()], [function(){ return cond ( [or( is_number(car(lat)), is_atom(car(lat)) ), cond( [is_eqan(car(lat), o), function(){ return cons(insertR(n, o, cdr(lat)), n); }], function(){ return cons(car(lat), insertR(n, o, cdr(lat))); } ) ], function(){ return cons(insertR(n, o, car(lat)), insertR(n, o, cdr(lat))); } ); }] ); }; вторник, 5 июля 2011 г.
  • 54. Example function insertR(n, o, lat){ return cond( [is_null(lat), quote()], [function(){ return cond(( cond [or( is_number(car(lat)), is_atom(car(lat)) ), cond( [is_eqan(car(lat), o), function(){ return cons(insertR(n, o, cdr(lat)), n); }], function(){ return cons(car(lat), insertR(n, o, cdr(lat))); } ) ], function(){ return cons(insertR(n, o, car(lat)), insertR(n, o, cdr(lat))); } ); }] ); }; вторник, 5 июля 2011 г.
  • 55. Example function insertR(n, o, lat){ return cond( [is_null(lat), quote()], [function(){ return cond(( cond [or( is_number(car(lat)), is_atom(car(lat)) ), cond( [is_eqan(car(lat), o), function(){ return cons(insertR(n, o, cdr(lat)), n); }], function(){ return cons(car(lat), insertR(n, o, cdr(lat))); } ) ], function(){ return cons(insertR(n, o, car(lat)), insertR(n, o, cdr(lat))); } ); }] ); }; вторник, 5 июля 2011 г.
  • 56. Example function insertR(n, o, lat){ return cond( [is_null(lat), quote()], [function(){ return cond(( cond [or( is_number(car(lat)), is_atom(car(lat)) ), cond( [is_eqan(car(lat), o), function(){ return cons(insertR(n, o, cdr(lat)), n); }], function(){ return cons(car(lat), insertR(n, o, cdr(lat))); } ) ], function(){ return cons(insertR(n, o, car(lat)), insertR(n, o, cdr(lat))); } ); }] ); }; вторник, 5 июля 2011 г.
  • 57. What if ... function occur(a, lat){ return cond( [isNull(lat), 0], [isEqan(a, car(lat)), function(){ return add1(occur(a, cdr(lat))); }], function(){ return occur(a, cdr(lat)); } ); }; вторник, 5 июля 2011 г.
  • 58. What if ... function occur(a, lat){ return cond( [isNull(lat), 0], [isEqan(a, car(lat)), function(){ return add1(occur(a, cdr(lat))); }], function(){ return occur(a, cdr(lat)); } ); }; вторник, 5 июля 2011 г.
  • 59. What if ... # occur(a, lat){ function occur(a, lat){ return cond( cond( [isNull(lat), 0], [isEqan(a, car(lat)), function(){ #{ return add1(occur(a, cdr(lat))); add1(occur(a, cdr(lat))); }], #{ function(){ occur(a, cdr(lat)); return occur(a, cdr(lat)); } ); }; вторник, 5 июля 2011 г.
  • 60. I am done. Thx! # occur(a, lat){ cond( [isNull(lat), 0], [isEqan(a, car(lat)), #{ add1(occur(a, cdr(lat))); }], #{ occur(a, cdr(lat)); } ); }; вторник, 5 июля 2011 г.