Iteration Vs Recursion in Introduction to Programming Classes: an Empirical Study
Total Page:16
File Type:pdf, Size:1020Kb
Load more
Recommended publications
-
Introduction to Programming in Lisp
Introduction to Programming in Lisp Supplementary handout for 4th Year AI lectures · D W Murray · Hilary 1991 1 Background There are two widely used languages for AI, viz. Lisp and Prolog. The latter is the language for Logic Programming, but much of the remainder of the work is programmed in Lisp. Lisp is the general language for AI because it allows us to manipulate symbols and ideas in a commonsense manner. Lisp is an acronym for List Processing, a reference to the basic syntax of the language and aim of the language. The earliest list processing language was in fact IPL developed in the mid 1950’s by Simon, Newell and Shaw. Lisp itself was conceived by John McCarthy and students in the late 1950’s for use in the newly-named field of artificial intelligence. It caught on quickly in MIT’s AI Project, was implemented on the IBM 704 and by 1962 to spread through other AI groups. AI is still the largest application area for the language, but the removal of many of the flaws of early versions of the language have resulted in its gaining somewhat wider acceptance. One snag with Lisp is that although it started out as a very pure language based on mathematic logic, practical pressures mean that it has grown. There were many dialects which threaten the unity of the language, but recently there was a concerted effort to develop a more standard Lisp, viz. Common Lisp. Other Lisps you may hear of are FranzLisp, MacLisp, InterLisp, Cambridge Lisp, Le Lisp, ... Some good things about Lisp are: • Lisp is an early example of an interpreted language (though it can be compiled). -
COMMON LISP an Interactive Approach PRINCIPLES of COMPUTER SCIENCE SERIES Series Editors Alfred V
COMMON LISP An Interactive Approach PRINCIPLES OF COMPUTER SCIENCE SERIES Series Editors Alfred V. Aho, Bellcore, Morristown, New Jersey Jeffrey D. Ullman, Stanford University, Stanford, California Egon B¨orger, Editor Trends in Theoretical Computer Science Ruth E. Davis Truth, Deduction, and Computation: Logic and Semantics for Computer Science Nicholas J. DeLillo A First Course in Computer Science with ADA A. K. Dewdney The Turing Omnibus: 61 Excursions in Computer Science Vladimir Drobot Formal Languages and Automata Theory Eitan M. Gurari An Introduction to the Theory of Computation Martti M¨antyl¨a An Introduction to Solid Modeling Bertrand Meyer Software Engineering: Principles and Practices Shamim Naqvi and Shalom Tsur A Logical Language for Data and Knowledge Bases Christos Papadimitriou The Theory of Database Concurrency Control Richard Snodgrass The Interface Description Language: Definition and Use Steven Tanimoto Elements of Artificial Intelligence Using COMMON LISP Jeffrey D. Ullman Computational Aspects of VLSI Jeffrey D. Ullman Principles of Database and Knowledge-Base Systems, Volume I: Classical Database Systems Jeffrey D. Ullman Principles of Database and Knowledge-Base Systems, Volume II: The New Tech- nologies Jeffrey D. Ullman Theory of Relational Databases COMMON LISP An Interactive Approach STUART C. SHAPIRO State University of New York at Buffalo COMPUTER SCIENCE PRESS AN IMPRINT OF W. H. FREEMAN AND COMPANY • NEW YORK Library of Congress Cataloging-in-Publication Data Shapiro, Stuart Charles Common LISP: an interactive approach / by Stuart C. Shapiro. p. cm. Includes index. ISBN 0-7167-8218-9 1. LISP (Computer program) I. Title. II. Title: LISP. QA76.73.L23S53 1991 005. 13’3—dc20 91-12377 CIP Copyright c 1992 by Stuart C. -
How to Think Like a Computer Scientist
How to Think Like a Computer Scientist Logo Version ii How to Think Like a Computer Scientist Logo Version Allen B. Downey Guido Gay Version 1.0 October 30, 2003 Copyright °c 2003 Allen B. Downey, Guido Gay. History: March 6, 2003: Allen B. Downey, How to Think Like a Computer Scientist. Java Version, fourth edition. October 30, 2003: Allen B. Downey, Guido Gay, How to Think Like a Com- puter Scientist. Logo Version, first edition. Permission is granted to copy, distribute, and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later ver- sion published by the Free Software Foundation; with Invariant Sections being “Preface”, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the appendix entitled “GNU Free Documentation License.” The GNU Free Documentation License is available from www.gnu.org or by writing to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. The original form of this book is LATEX source code. Compiling this LATEX source has the effect of generating a device-independent representation of the book, which can be converted to other formats and printed. The LATEX source for this book is available from http://ibiblio.org/obp/thinkCS/ Prefazione Logo is a programming language mostly used as a teaching tool in primary education. If you know about its turtle graphics commands — such as repeat 10 [repeat 5 [fd 30 lt 72] lt 36] — you may be curious about its other capabilities. -
COMMON LISP: a Gentle Introduction to Symbolic Computation COMMON LISP: a Gentle Introduction to Symbolic Computation
COMMON LISP: A Gentle Introduction to Symbolic Computation COMMON LISP: A Gentle Introduction to Symbolic Computation David S. Touretzky Carnegie Mellon University The Benjamin/Cummings Publishing Company,Inc. Redwood City, California • Fort Collins, Colorado • Menlo Park, California Reading, Massachusetts• New York • Don Mill, Ontario • Workingham, U.K. Amsterdam • Bonn • Sydney • Singapore • Tokyo • Madrid • San Juan Sponsoring Editor: Alan Apt Developmental Editor: Mark McCormick Production Coordinator: John Walker Copy Editor: Steven Sorenson Text and Cover Designer: Michael Rogondino Cover image selected by David S. Touretzky Cover: La Grande Vitesse, sculpture by Alexander Calder Copyright (c) 1990 by Symbolic Technology, Ltd. Published by The Benjamin/Cummings Publishing Company, Inc. This document may be redistributed in hardcopy form only, and only for educational purposes at no charge to the recipient. Redistribution in electronic form, such as on a web page or CD-ROM disk, is prohibited. All other rights are reserved. Any other use of this material is prohibited without the written permission of the copyright holder. The programs presented in this book have been included for their instructional value. They have been tested with care but are not guaranteed for any particular purpose. The publisher does not offer any warranties or representations, nor does it accept any liabilities with respect to the programs. Library of Congress Cataloging-in-Publication Data Touretzky, David S. Common LISP : a gentle introduction to symbolic computation / David S. Touretzky p. cm. Includes index. ISBN 0-8053-0492-4 1. COMMON LISP (Computer program language) I. Title. QA76.73.C28T68 1989 005.13'3±dc20 89-15180 CIP ISBN 0-8053-0492-4 ABCDEFGHIJK - DO - 8932109 The Benjamin/Cummings Publishing Company, Inc. -
Jamie Samdal Ricardo Carlos What Is Logo?
Logo Jamie Samdal Ricardo Carlos What is Logo? Educational Language Beyond Programming Mathematics, Language, Music, Robotics, Science Novice Programmers Interactive Interpreter One Laptop Per Child Best Known For Turtle Graphics List and Language Processing History First Version Created in 1967 Seymour Papert and Wallace Feurzeig LISP Introduce Children to Words and Sentences First Turtle Robot at MIT in 1969 Over 170 Implementations in 2007 UCBLogo (Berkeley Logo) Lego Logo Turtle Graphics to drawDashedTriangle repeat 3 ~ [repeat 10 ~ [forward 10 ~ penup ~ forward 10 ~ pendown] ~ right 120] end Types Word Sequence of letters, numbers and punctuation word is evaluated (variable or procedure) "word is treated as a string Numbers special case of word List Contains words and lists, cannot modify after creation [one [2 3] four [five!]] Array Allows modification of a single element with setitem make "ar {one [2 3] four [[five]]} setitem 4 :ar [five] Logo Instruction Evaluation Operation 1 4 2 2 sum 3 4 Command print 20 sum product Instruction print product product sum 1 4 product 2 2 Errors print “Not enough inputs to print” “You didn’t say what to do with 2” Example Logo Program to switch :input :word1 :word2 if equalp input [] [output []] if equalp :word1 first :input ~ [output sentence :word2 ~ switch butfirst :input] if equalp :word2 first :input ~ [output sentence :word1 ~ switch butfirst :input] output sentence first :input ~ switch butfirst :input end Variables to demonstrate Variable: var Quoted -
The Order in Chaos
The Order in Chaos Jeremy Batterson May 13, 2013 \Fractal geometry will make you see everything differently. There is a danger in reading further. You risk the loss of your childhood vision of clouds, forests, flowers, galax- ies, leaves, feathers, rocks, mountains, torrents of water, carpet, bricks, and much else besides. Never again will your interpretation of these things be quite the same." -Michael Barnsley 2000 1 Introduction As the title of Barnsley's book [1] indicates, fractals are everywhere around us, although most do not recognize them as such. From the leaves on the trees in your backyard to the coastline you walk in the summer and even those mountains you explore while playing Skyrim; they are all fractals. We can even use them to compress digital images, as patented by Michael Barnsley, whose book we reference throughout the paper. Fractals will be more formally described later in the paper, but for now, we will say that fractals are self-similar structures, meaning that they look essentially the same no matter what scale we look at them. For example, take a look at the fern I found in Olympic National Park, depicted in Figure 1. As we look closer at it and move down the stem, it appears very similar to where we were looking just a moment before. Of course this isn't a mathematical fractal since it tapers off to a finite point, and this distinction will be become important later, but you get the picture. Figure 1: A fern exhibiting self-similarity 2 The question then is, how would we model such a phenomenon? The answer is what brings us to Iterated Function Systems (IFS) theory. -
Download PDF Version
Appendices A Running Berkeley Logo One of my reasons for writing a second edition of these books was that all of the Logo interpreters described in the ®rst edition are now obsolete. Current commercial Logo implementations are quite different in their user interface from those traditional versions. Those differences make newer Logo implementations more immediately accessible to children who want to produce animated graphics, but in many cases the changes have made the kind of programming I do in these books harder. My solution has been to produce, along with some of my students, a Logo interpreter that is available free of charge for most popular computers. The design goal of Berkeley Logo has been that a program written for one kind of computer should run entirely unchanged on any other kind. Still, there are slight differences in the user interface and in the installation process, and this appendix discusses those differences. Since Berkeley Logo is distributed with source ®les, I hope that as new computers and operating systems come along, some enthusiast will make Berkeley Logo available for them even if I don't catch them all. Still, people who are using some other version of Logo for other purposes might well want to use these books to help them learn more advanced Logo ideas. The programs in this ®rst volume can be adapted to current commercial Logo dialects with some effort. In the later volumes I rely more heavily on features that are available only in Berkeley Logo. Getting Berkeley Logo Berkeley Logo is available over the Internet, or on diskette from the MIT Press. -
Oct. 14, 2017 Coding for the Love of Mathematics Richard A
Session Outline: Oct. 14, 2017 Coding for the Love of Mathematics Richard A. Clausi **cartoon IMAGES are courtesy of New Vision Technologies Task Force ClipArt © 1995 (wannapik.com) Other images are acknowledged in the Resource list and in context. 17/10/2017 Slides (c) 2017 Richard A. Clausi 1 • Session 3 • Title: Coding, For the Love of Mathematics Presenter: Richard Clausi, OCT – Elmira District S.S. (retired 2012) • Currently: Instructor, EU420D, Faculty of Education, Wilfrid Laurier University • : Owner, RC Software and Data (registered 1981) • Slides will be available at: http://www.kw.igs.net/~raclausi/coding.pdf Session Description: Coding, a new player in the elementary school curriculum, offers teachers and students a new way to explore mathematics. This session is a light overview of entry‐level programming (code.org, scratch and LOGO) as a way to engage and nurture mathematical thinking. This new tool for problem solving allows us to use simple programming to understand and apply “tough” concepts such as recursion, modularity and multi‐tasking to ARDUINO programming and Mouse Mazes, calculating TT, Newton’s Method for Square Roots, Fractals and Mandelbrot Set. • I hope that you will leave with inspiration and ideas that you can use to explore your own personal mathematical adventures. • ** This slide will be the last slide in my presentation so you can copy down the web address, later, if you wish. 17/10/2017 Slides (c) 2017 Richard A. Clausi 2 Warnings… • An intelligent, silicon‐based life‐form….. • And of Websites that evaporate… 17/10/2017 Slides (c) 2017 Richard A. Clausi 3 A code…. -
Teaching Recursion Before Loops in Cs1
1 Appears in the Journal of Computing in Small Colleges, Volume 14, Numer 4, May 1999, pp 86-101 TEACHING RECURSION BEFORE LOOPS IN CS1 Franklyn Turbak, Constance Royden, Jennifer Stephan, and Jean Herbst Computer Science Department Wellesley College Wellesley MA, 02481 {fturbak,croyden,jstephan,jherbst}@wellesley.edu (781) 283-{3049, 2743, 3152, 3162} ABSTRACT Traditionally, loops are a central topic in a CS1 course but recursion is viewed as an advanced topic that is either taught near the end of the course or not taught at all. Taking a cue from the function-oriented programming community, we argue that there are strong pedagogical reasons for teaching recursion before loops in a CS1 course, regardless of what programming paradigm is taught. In our approach, recursion is presented as an instance of the classic "divide, conquer, and glue" problem solving strategy. Iteration is then presented as a particular pattern of recursion. Finally, loop constructs are presented as concise idioms for iterative patterns. We describe our positive experience in adopting this approach in a CS1 course and highlight the aspects of the course that we think contribute to its success. 1. INTRODUCTION Discussions of CS1 pedagogy are enlivened by perennial debates on the choice of programming language and the choice and order of topics. The area of topic order is marked by various early/late debates: Should procedures be taught early or late? Should objects be taught early or late (if at all)? In this context, it is surprising that there has been relatively little debate on where (or whether) recursion belongs in CS1. -
History of Logo
UC Berkeley UC Berkeley Previously Published Works Title History of Logo Permalink https://escholarship.org/uc/item/1623m1p3 Journal Proceedings of the ACM on Programming Languages, 4(HOPL) ISSN 2475-1421 Authors Solomon, C Harvey, B Kahn, K et al. Publication Date 2020-06-12 DOI 10.1145/3386329 License https://creativecommons.org/licenses/by-nc-sa/4.0/ 4.0 Peer reviewed eScholarship.org Powered by the California Digital Library University of California History of Logo CYNTHIA SOLOMON, Cynthia Solomon Consulting, USA BRIAN HARVEY, University of California, Berkeley, USA KEN KAHN, University of Oxford, UK HENRY LIEBERMAN, MIT Computer Science and Artificial Intelligence Lab (CSAIL), USA MARK L. MILLER, Learningtech.org, USA MARGARET MINSKY, New York University-Shanghai, China ARTEMIS PAPERT, Independent artist, Canada BRIAN SILVERMAN, Playful Invention Co., Canada Shepherd: Tomas Petricek, University of Kent, UK Logo is more than a programming language. It is a learning environment where children explore mathematical ideas and create projects of their own design. Logo, the first programming language explicitly designed for children, was invented by Seymour Papert, Wallace Feurzeig, Daniel Bobrow, and Cynthia Solomon in 1966 at Bolt, Beranek and Newman, Inc. (BBN). Logo’s design drew upon two theoretical frameworks: Jean Piaget’s constructivism and Marvin Minsky’s artificial intelligence research at MIT. One of Logo’s foundational ideas was that children shouldhavea powerful programming environment. Early Lisp served as a model with its symbolic computation, recursive functions, operations on linked lists, and dynamic scoping of variables. Logo became a symbol for change in elementary mathematics education and in the nature of school itself. -
2 Iteration, Induction, and Recursion
CHAPTER 2 Iteration, Induction, ✦ ✦ ✦ ✦ and Recursion The power of computers comes from their ability to execute the same task, or different versions of the same task, repeatedly. In computing, the theme of iteration is met in a number of guises. Many concepts in data models, such as lists, are forms of repetition, as “A list either is empty or is one element followed by another, then another, and so on.” Programs and algorithms use iteration to perform repetitive jobs without requiring a large number of similar steps to be specified individually, as “Do the next step 1000 times.” Programming languages use looping constructs, like the while- and for-statements of C, to implement iterative algorithms. Closely related to repetition is recursion, a technique in which a concept is defined, directly or indirectly, in terms of itself. For example, we could have defined a list by saying “A list either is empty or is an element followed by a list.” Recursion is supported by many programming languages. In C, a function F can call itself, either directly from within the body of F itself, or indirectly by calling some other function, which calls another, and another, and so on, until finally some function in the sequence calls F . Another important idea, induction, is closely related to “recursion” and is used in many mathematical proofs. Iteration, induction, and recursion are fundamental concepts that appear in many forms in data models, data structures, and algorithms. The following list gives some examples of uses of these concepts; each will be covered in some detail in this book.