Multi-Resolution Data Structures for Spherically Mapped Point Data

Total Page:16

File Type:pdf, Size:1020Kb

Multi-Resolution Data Structures for Spherically Mapped Point Data MULTI-RESOLUTION DATA STRUCTURES FOR SPHERICALLY MAPPED POINT DATA by ROBERT WILLIAM YOUNGREN A DISSERTATION Submitted in partial fulfillment of the requirements for the Degree of Doctor of Philosophy in Computer Science to The School of Graduate Studies of The University of Alabama in Huntsville HUNTSVILLE, ALABAMA 2017 ABSTRACT The School of Graduate Studies The University of Alabama in Huntsville Degree Doctor of Philosophy College/Dept Science/Computer Science_ Name of Candidate Robert Youngren__________________________ Title Multi-Resolution Data Structures for Spherically Mapped Point Data_______ Data describing entities or objects whose locations may be treated as points on the surface of a sphere are said to be spherically mapped. A number of data structures specifically designed to store and access spherically mapped data have been developed. One of them, Hierarchical Equal Area iso-Latitude Pixelization (HEALPix), has been successfully used for numerous applications, notably including organizing and analyzing cosmic microwave background data. However, for applications involving relatively sparse spherically mapped point datasets, HEALPix has some drawbacks, including inefficient memory requirements due to fixed resolution, overwriting of data for closely proximate points, and return of spurious points in response to certain queries. A multi-resolution variant of the HEALPix data structure optimized for point data was developed to address these issues. The new data structure is multi-resolution in that different portions of the sphere may be subdivided at different levels of resolution in the same data structure, depending on the data to be stored. It combines the best aspects of iv HEALPix with the advantages of multi-resolution, including reduced memory requirements, improved query efficiency, and flexible handling of proximate points. The new Multi-resolution HEALPix (MRH) data structure uses multiple quadtrees and the Morton cell addressing scheme. An implementation of the MRH data structure was tested using four sets of spherically mapped point data from different scientific applications (warhead fragmentation trajectories, weather station locations, redshifted galaxy locations, and synthetic locations). A large set of randomly generated range queries of four different types (disc, polygon, latitude strip, and neighbor) was applied to each data structure for each dataset. MRH used from two to four orders of magnitude less memory than HEALPix to store the same data, and on average MRH queries executed 72% faster. Additional effort to develop a three dimensional variant of MRH was explored. The new data structure, Multi-MRH, adds an additional degree of freedom (temporal or spatial) into an entirely new data and applications. In Multi-MRH, multiple instances of MRH are utilized to store either temporal, same data point locations at different times, or spatial, data points with spherical coordinates including radius, spherical data. The Multi-MRH data structure consists of a sorted list of MRH maps. An implementation of the Multi-MRH data structure was tested using three sets of spherically mapped point data from different scientific applications (synthetic locations, warhead fragmentation trajectories, and NEXRAD wind velocity data). A large set of randomly generated range queries of four different types (cone, prism, band, and ray) was v ACKNOWLEDGMENTS I owe a huge debt of gratitude to my academic advisor Dr. Mikel D. Petty. His endless enthusiasm, patience, and persistence have helped me keep making steady forward progress towards the dissertation finish line. I would also like to thank Dr. Wesley N. Colley, who first brought our attention to the HEALPix data structure. Special thank you to my mother-in-law Mary Ann who spent many hours editing this dissertation for grammar and provided so many useful suggestions to improve the language and flow. I also must thank my wife Kathy and my dogs, Trails, Cairo, Tracks, and Sparta for putting up with me in this endless seeming endeavor and constantly motivating me to persist to the finish line. Lastly, I want to dedicate this dissertation and all the hard work that came with it and before it to my father, Ronald William Youngren, who sadly passed away just as I started down this long path; he would have really appreciated the effort, sympathized with my struggles and have been proud of the final result. vii Table of Contents Page LIST OF FIGURES ............................................................................................. xvi LIST OF TABLES ...............................................................................................xxx 1 Introduction .......................................................................................................1 2 Survey of Spherical Data Structures .................................................................7 2.1 Introduction ................................................................................................7 2.2 Quadtrees and Octrees ................................................................................8 2.3 Platonic Spherical Data Structures ...........................................................20 2.3.1 Hierarchical Triangular Mesh............................................................21 2.3.2 Quaternary Triangular Mesh .............................................................26 2.3.3 Hierarchical Spatial Data Structure ...................................................36 2.3.4 Semi-Quad Code ATM......................................................................38 2.3.5 Sphere Quadtree ................................................................................39 2.3.6 Truncated Icosahedron ......................................................................44 2.3.7 Quadrilateralized Spherical Cube ......................................................47 2.3.8 Hexagonal Sampling Grids with Icosahedral Symmetry ..................50 2.3.9 Linear Quadtree .................................................................................52 2.3.10 Icosahedral Snyder Equal Area Variants ...........................................56 viii 2.3.11 Diamond Partitioning Platonic Solids ...............................................58 2.3.12 Linear Quadtree QTM .......................................................................61 2.4 Igloo Spherical Data Structures ................................................................64 2.4.1 Igloo Type Constructions ..................................................................64 2.4.2 Gauss-Legendre Sky Pixelization ......................................................74 2.5 Hierarchical Equal Area iso-Latitude Pixelization ...................................77 2.5.1 HEALPix: Applications.....................................................................82 2.5.2 Recent Independent Developments Involving HEALPix..................85 2.5.3 HEALPix Anomalies .........................................................................94 2.5.4 Problems with HEALPix and Point Data ..........................................94 3 Research overview ..........................................................................................99 4 Multi-Resolution HEALPix Data Structure ..................................................101 4.1 Overview ................................................................................................101 4.2 MRH Map Description ...........................................................................103 4.3 Morton Cell Addressing Overview ........................................................104 4.4 Morton Datatype Definition ...................................................................108 4.5 Morton and HEALPix Address Relationship .........................................109 4.6 MLQ Definition ......................................................................................113 ix 4.7 Building the MRH Data Structure ..........................................................116 4.8 Searching the MRH Data Structure ........................................................121 4.8.1 Search MRH Data Structure by (Φ, θ) ............................................122 4.8.2 Search MRH Data Structure by HEALPix (index, level) Pair ........123 4.9 MRH Range Queries ..............................................................................126 4.9.1 Summary of Query Types and Algorithms .....................................127 4.9.2 Query Worst Case Computational Complexity Summary ..............130 4.9.3 Polygon Query Description .............................................................132 4.9.4 Polygon Query Worst Case Analysis ..............................................142 4.9.5 Disc Query Description ...................................................................147 4.9.6 Disc Query Worst Case Analysis ....................................................155 4.9.7 Latitude Strip Query Description ....................................................160 4.9.8 Latitude Strip Query Worst Case Analysis .....................................164 4.9.9 Neighbor Query Description ...........................................................165 4.9.10 Neighbor Query Worst Case Analysis ............................................172 4.10 Archiving the MRH Data Structure .....................................................174 5 Benchmarking Datasets and Methodology ...................................................177 5.1 Warhead Fragmentation Flyout Data .....................................................179
Recommended publications
  • Understanding Map Projections
    Understanding Map Projections GIS by ESRI ™ Melita Kennedy and Steve Kopp Copyright © 19942000 Environmental Systems Research Institute, Inc. All rights reserved. Printed in the United States of America. The information contained in this document is the exclusive property of Environmental Systems Research Institute, Inc. This work is protected under United States copyright law and other international copyright treaties and conventions. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying and recording, or by any information storage or retrieval system, except as expressly permitted in writing by Environmental Systems Research Institute, Inc. All requests should be sent to Attention: Contracts Manager, Environmental Systems Research Institute, Inc., 380 New York Street, Redlands, CA 92373-8100, USA. The information contained in this document is subject to change without notice. U.S. GOVERNMENT RESTRICTED/LIMITED RIGHTS Any software, documentation, and/or data delivered hereunder is subject to the terms of the License Agreement. In no event shall the U.S. Government acquire greater than RESTRICTED/LIMITED RIGHTS. At a minimum, use, duplication, or disclosure by the U.S. Government is subject to restrictions as set forth in FAR §52.227-14 Alternates I, II, and III (JUN 1987); FAR §52.227-19 (JUN 1987) and/or FAR §12.211/12.212 (Commercial Technical Data/Computer Software); and DFARS §252.227-7015 (NOV 1995) (Technical Data) and/or DFARS §227.7202 (Computer Software), as applicable. Contractor/Manufacturer is Environmental Systems Research Institute, Inc., 380 New York Street, Redlands, CA 92373- 8100, USA.
    [Show full text]
  • An Efficient Technique for Creating a Continuum of Equal-Area Map Projections
    Cartography and Geographic Information Science ISSN: 1523-0406 (Print) 1545-0465 (Online) Journal homepage: http://www.tandfonline.com/loi/tcag20 An efficient technique for creating a continuum of equal-area map projections Daniel “daan” Strebe To cite this article: Daniel “daan” Strebe (2017): An efficient technique for creating a continuum of equal-area map projections, Cartography and Geographic Information Science, DOI: 10.1080/15230406.2017.1405285 To link to this article: https://doi.org/10.1080/15230406.2017.1405285 View supplementary material Published online: 05 Dec 2017. Submit your article to this journal View related articles View Crossmark data Full Terms & Conditions of access and use can be found at http://www.tandfonline.com/action/journalInformation?journalCode=tcag20 Download by: [4.14.242.133] Date: 05 December 2017, At: 13:13 CARTOGRAPHY AND GEOGRAPHIC INFORMATION SCIENCE, 2017 https://doi.org/10.1080/15230406.2017.1405285 ARTICLE An efficient technique for creating a continuum of equal-area map projections Daniel “daan” Strebe Mapthematics LLC, Seattle, WA, USA ABSTRACT ARTICLE HISTORY Equivalence (the equal-area property of a map projection) is important to some categories of Received 4 July 2017 maps. However, unlike for conformal projections, completely general techniques have not been Accepted 11 November developed for creating new, computationally reasonable equal-area projections. The literature 2017 describes many specific equal-area projections and a few equal-area projections that are more or KEYWORDS less configurable, but flexibility is still sparse. This work develops a tractable technique for Map projection; dynamic generating a continuum of equal-area projections between two chosen equal-area projections.
    [Show full text]
  • Rcosmo: R Package for Analysis of Spherical, Healpix and Cosmological Data Arxiv:1907.05648V1 [Stat.CO] 12 Jul 2019
    CONTRIBUTED RESEARCH ARTICLE 1 rcosmo: R Package for Analysis of Spherical, HEALPix and Cosmological Data Daniel Fryer, Ming Li, Andriy Olenko Abstract The analysis of spatial observations on a sphere is important in areas such as geosciences, physics and embryo research, just to name a few. The purpose of the package rcosmo is to conduct efficient information processing, visualisation, manipulation and spatial statistical analysis of Cosmic Microwave Background (CMB) radiation and other spherical data. The package was developed for spherical data stored in the Hierarchical Equal Area isoLatitude Pixelation (Healpix) representation. rcosmo has more than 100 different functions. Most of them initially were developed for CMB, but also can be used for other spherical data as rcosmo contains tools for transforming spherical data in cartesian and geographic coordinates into the HEALPix representation. We give a general description of the package and illustrate some important functionalities and benchmarks. Introduction Directional statistics deals with data observed at a set of spatial directions, which are usually positioned on the surface of the unit sphere or star-shaped random particles. Spherical methods are important research tools in geospatial, biological, palaeomagnetic and astrostatistical analysis, just to name a few. The books (Fisher et al., 1987; Mardia and Jupp, 2009) provide comprehensive overviews of classical practical spherical statistical methods. Various stochastic and statistical inference modelling issues are covered in (Yadrenko, 1983; Marinucci and Peccati, 2011). The CRAN Task View Spatial shows several packages for Earth-referenced data mapping and analysis. All currently available R packages for spherical data can be classified in three broad groups. The first group provides various functions for working with geographic and spherical coordinate systems and their visualizations.
    [Show full text]
  • Comparison of Spherical Cube Map Projections Used in Planet-Sized Terrain Rendering
    FACTA UNIVERSITATIS (NIS)ˇ Ser. Math. Inform. Vol. 31, No 2 (2016), 259–297 COMPARISON OF SPHERICAL CUBE MAP PROJECTIONS USED IN PLANET-SIZED TERRAIN RENDERING Aleksandar M. Dimitrijevi´c, Martin Lambers and Dejan D. Ranˇci´c Abstract. A wide variety of projections from a planet surface to a two-dimensional map are known, and the correct choice of a particular projection for a given application area depends on many factors. In the computer graphics domain, in particular in the field of planet rendering systems, the importance of that choice has been neglected so far and inadequate criteria have been used to select a projection. In this paper, we derive evaluation criteria, based on texture distortion, suitable for this application domain, and apply them to a comprehensive list of spherical cube map projections to demonstrate their properties. Keywords: Map projection, spherical cube, distortion, texturing, graphics 1. Introduction Map projections have been used for centuries to represent the curved surface of the Earth with a two-dimensional map. A wide variety of map projections have been proposed, each with different properties. Of particular interest are scale variations and angular distortions introduced by map projections – since the spheroidal surface is not developable, a projection onto a plane cannot be both conformal (angle- preserving) and equal-area (constant-scale) at the same time. These two properties are usually analyzed using Tissot’s indicatrix. An overview of map projections and an introduction to Tissot’s indicatrix are given by Snyder [24]. In computer graphics, a map projection is a central part of systems that render planets or similar celestial bodies: the surface properties (photos, digital elevation models, radar imagery, thermal measurements, etc.) are stored in a map hierarchy in different resolutions.
    [Show full text]
  • The Light Source Metaphor Revisited—Bringing an Old Concept for Teaching Map Projections to the Modern Web
    International Journal of Geo-Information Article The Light Source Metaphor Revisited—Bringing an Old Concept for Teaching Map Projections to the Modern Web Magnus Heitzler 1,* , Hans-Rudolf Bär 1, Roland Schenkel 2 and Lorenz Hurni 1 1 Institute of Cartography and Geoinformation, ETH Zurich, 8049 Zurich, Switzerland; [email protected] (H.-R.B.); [email protected] (L.H.) 2 ESRI Switzerland, 8005 Zurich, Switzerland; [email protected] * Correspondence: [email protected] Received: 28 February 2019; Accepted: 24 March 2019; Published: 28 March 2019 Abstract: Map projections are one of the foundations of geographic information science and cartography. An understanding of the different projection variants and properties is critical when creating maps or carrying out geospatial analyses. The common way of teaching map projections in text books makes use of the light source (or light bulb) metaphor, which draws a comparison between the construction of a map projection and the way light rays travel from the light source to the projection surface. Although conceptually plausible, such explanations were created for the static instructions in textbooks. Modern web technologies may provide a more comprehensive learning experience by allowing the student to interactively explore (in guided or unguided mode) the way map projections can be constructed following the light source metaphor. The implementation of this approach, however, is not trivial as it requires detailed knowledge of map projections and computer graphics. Therefore, this paper describes the underlying computational methods and presents a prototype as an example of how this concept can be applied in practice. The prototype will be integrated into the Geographic Information Technology Training Alliance (GITTA) platform to complement the lesson on map projections.
    [Show full text]
  • Map Projections
    Map Projections Chapter 4 Map Projections What is map projection? Why are map projections drawn? What are the different types of projections? Which projection is most suitably used for which area? In this chapter, we will seek the answers of such essential questions. MAP PROJECTION Map projection is the method of transferring the graticule of latitude and longitude on a plane surface. It can also be defined as the transformation of spherical network of parallels and meridians on a plane surface. As you know that, the earth on which we live in is not flat. It is geoid in shape like a sphere. A globe is the best model of the earth. Due to this property of the globe, the shape and sizes of the continents and oceans are accurately shown on it. It also shows the directions and distances very accurately. The globe is divided into various segments by the lines of latitude and longitude. The horizontal lines represent the parallels of latitude and the vertical lines represent the meridians of the longitude. The network of parallels and meridians is called graticule. This network facilitates drawing of maps. Drawing of the graticule on a flat surface is called projection. But a globe has many limitations. It is expensive. It can neither be carried everywhere easily nor can a minor detail be shown on it. Besides, on the globe the meridians are semi-circles and the parallels 35 are circles. When they are transferred on a plane surface, they become intersecting straight lines or curved lines. 2021-22 Practical Work in Geography NEED FOR MAP PROJECTION The need for a map projection mainly arises to have a detailed study of a 36 region, which is not possible to do from a globe.
    [Show full text]
  • A History of Clojure
    A History of Clojure RICH HICKEY, Cognitect, Inc., USA Shepherd: Mira Mezini, Technische Universität Darmstadt, Germany Clojure was designed to be a general-purpose, practical functional language, suitable for use by professionals wherever its host language, e.g., Java, would be. Initially designed in 2005 and released in 2007, Clojure is a dialect of Lisp, but is not a direct descendant of any prior Lisp. It complements programming with pure functions of immutable data with concurrency-safe state management constructs that support writing correct multithreaded programs without the complexity of mutex locks. Clojure is intentionally hosted, in that it compiles to and runs on the runtime of another language, such as the JVM. This is more than an implementation strategy; numerous features ensure that programs written in Clojure can leverage and interoperate with the libraries of the host language directly and efficiently. In spite of combining two (at the time) rather unpopular ideas, functional programming and Lisp, Clojure has since seen adoption in industries as diverse as finance, climate science, retail, databases, analytics, publishing, healthcare, advertising and genomics, and by consultancies and startups worldwide, much to the career-altering surprise of its author. Most of the ideas in Clojure were not novel, but their combination puts Clojure in a unique spot in language design (functional, hosted, Lisp). This paper recounts the motivation behind the initial development of Clojure and the rationale for various design decisions and language constructs. It then covers its evolution subsequent to release and adoption. CCS Concepts: • Software and its engineering ! General programming languages; • Social and pro- fessional topics ! History of programming languages.
    [Show full text]
  • Lisp and Scheme I
    4/10/2012 Versions of LISP Why Study Lisp? • LISP is an acronym for LISt Processing language • It’s a simple, elegant yet powerful language • Lisp (b. 1958) is an old language with many variants • You will learn a lot about PLs from studying it – Fortran is only older language still in wide use • We’ll look at how to implement a Scheme Lisp and – Lisp is alive and well today interpreter in Scheme and Python • Most modern versions are based on Common Lisp • Scheme is one of the major variants • Many features, once unique to Lisp, are now in – We’ll use Scheme, not Lisp, in this class “mainstream” PLs: python, javascript, perl … Scheme I – Scheme is used for CS 101 in some universities • It will expand your notion of what a PL can be • The essentials haven’t changed much • Lisp is considered hip and esoteric among computer scientists LISP Features • S-expression as the universal data type – either at atom (e.g., number, symbol) or a list of atoms or sublists • Functional Programming Style – computation done by applying functions to arguments, functions are first class objects, minimal use of side-effects • Uniform Representation of Data & Code – (A B C D) can be interpreted as data (i.e., a list of four elements) or code (calling function ‘A’ to the three parameters B, C, and D) • Reliance on Recursion – iteration is provided too, but We lost the documentation on quantum mechanics. You'll have to decode recursion is considered more natural and elegant the regexes yourself. • Garbage Collection – frees programmer’s explicit memory management How Programming Language Fanboys See Each Others’ Languages 1 4/10/2012 What’s Functional Programming? Pure Lisp and Common Lisp Scheme • The FP paradigm: computation is applying • Lisp has a small and elegant conceptual core • Scheme is a dialect of Lisp that is favored by functions to data that has not changed much in almost 50 years.
    [Show full text]
  • Lists in Lisp and Scheme
    Lists in Lisp and Scheme • Lists are Lisp’s fundamental data structures • However, it is not the only data structure Lists in Lisp – There are arrays, characters, strings, etc. – Common Lisp has moved on from being merely a LISt Processor and Scheme • However, to understand Lisp and Scheme you must understand lists – common funcAons on them – how to build other useful data structures with them In the beginning was the cons (or pair) Pairs nil • What cons really does is combines two objects into a a two-part object called a cons in Lisp and a pair in • Lists in Lisp and Scheme are defined as Scheme • Conceptually, a cons is a pair of pointers -- the first is pairs the car, and the second is the cdr • Any non empty list can be considered as a • Conses provide a convenient representaAon for pairs pair of the first element and the rest of of any type • The two halves of a cons can point to any kind of the list object, including conses • We use one half of the cons to point to • This is the mechanism for building lists the first element of the list, and the other • (pair? ‘(1 2) ) => #t to point to the rest of the list (which is a nil either another cons or nil) 1 Box nota:on Z What sort of list is this? null Where null = ‘( ) null a a d A one element list (a) null null b c a b c > (set! z (list ‘a (list ‘b ‘c) ‘d)) (car (cdr z)) A list of 3 elements (a b c) (A (B C) D) ?? Pair? Equality • Each Ame you call cons, Scheme allocates a new memory with room for two pointers • The funcAon pair? returns true if its • If we call cons twice with the
    [Show full text]
  • Healpix Mapping Technique and Cartographical Application Omur Esen , Vahit Tongur , Ismail Bulent Gundogdu Abstract Hierarchical
    HEALPix Mapping Technique and Cartographical Application Omur Esen1, Vahit Tongur2, Ismail Bulent Gundogdu3 1Selcuk University, Construction Offices and Infrastructure Presidency, [email protected] 2Necmettin Erbakan University, Computer Engineering Department of Engineering and Architecture Faculty, [email protected] 3Selcuk University, Geomatics Engineering Department of Engineering Faculty, [email protected] Abstract Hierarchical Equal Area isoLatitude Pixelization (HEALPix) system is defined as a layer which is used in modern astronomy for using pixelised data, which are required by developed detectors, for a fast true and proper scientific comment of calculation algoritms on spherical maps. HEALPix system is developed by experiments which are generally used in astronomy and called as Cosmic Microwave Background (CMB). HEALPix system reminds fragment of a sphere into 12 equal equilateral diamonds. In this study aims to make a litetature study for mapping of the world by mathematical equations of HEALPix celling/tesellation system in cartographical map making method and calculating and examining deformation values by Gauss Fundamental Equations. So, although HEALPix system is known as equal area until now, it is shown that this celling system do not provide equal area cartographically. Keywords: Cartography, Equal Area, HEALPix, Mapping 1. INTRODUCTION Map projection, which is classically defined as portraying of world on a plane, is effected by technological developments. Considering latest technological developments, we can offer definition of map projection as “3d and time varying space, it is the transforming techniques of space’s, earth’s and all or part of other objects photos in a described coordinate system by keeping positions proper and specific features on a plane by using mathematical relation.” Considering today’s technological developments, cartographical projections are developing on multi surfaces (polihedron) and Myriahedral projections which is used by Wijk (2008) for the first time.
    [Show full text]
  • Maps and Cartography: Map Projections a Tutorial Created by the GIS Research & Map Collection
    Maps and Cartography: Map Projections A Tutorial Created by the GIS Research & Map Collection Ball State University Libraries A destination for research, learning, and friends What is a map projection? Map makers attempt to transfer the earth—a round, spherical globe—to flat paper. Map projections are the different techniques used by cartographers for presenting a round globe on a flat surface. Angles, areas, directions, shapes, and distances can become distorted when transformed from a curved surface to a plane. Different projections have been designed where the distortion in one property is minimized, while other properties become more distorted. So map projections are chosen based on the purposes of the map. Keywords •azimuthal: projections with the property that all directions (azimuths) from a central point are accurate •conformal: projections where angles and small areas’ shapes are preserved accurately •equal area: projections where area is accurate •equidistant: projections where distance from a standard point or line is preserved; true to scale in all directions •oblique: slanting, not perpendicular or straight •rhumb lines: lines shown on a map as crossing all meridians at the same angle; paths of constant bearing •tangent: touching at a single point in relation to a curve or surface •transverse: at right angles to the earth’s axis Models of Map Projections There are two models for creating different map projections: projections by presentation of a metric property and projections created from different surfaces. • Projections by presentation of a metric property would include equidistant, conformal, gnomonic, equal area, and compromise projections. These projections account for area, shape, direction, bearing, distance, and scale.
    [Show full text]
  • Pairs and Lists (V1.0) Week 5
    CS61A, Spring 2006, Wei Tu (Based on Chung’s Notes) 1 CS61A Pairs and Lists (v1.0) Week 5 Pair Up! Introducing - the only data structure you’ll ever need in 61A - pairs. A pair is a data structure that contains two things - the ”things” can be atomic values or even another pair. For example, you can represent a point as (x . y), and a date as (July . 1). Note the Scheme representation of a pair; the pair is enclosed in parentheses, and separated by a single period. Note also that there’s an operator called pair? that tests whether something is a pair or not. For example, (pair? (cons 3 4)) is #t, while (pair? 10) is #f. You’ve read about cons, car, and cdr: • cons - takes in two parameters and constructs a pair out of them. So (cons 3 4) returns (3 . 4) • car - takes in a pair and returns the first part of the pair. So (car (cons 3 4)) will return 3. • cdr - takes in a pair and returns the second part of the pair. So (cdr (cons 3 4)) will return 4. These, believe it or not, will be all we’ll ever need to build complex data structures in this course. QUESTIONS: What do the following evaluate to? (define u (cons 2 3)) (define w (cons 5 6)) (define x (cons u w)) (define y (cons w x)) (define z (cons 3 y)) 1. u, w, x, y, z (write out how Scheme would print them and box and pointer diagram). CS61A, Spring 2006, Wei Tu (Based on Chung’s Notes) 2 2.
    [Show full text]