├── Forth ├── 1.1-TheElementsOfProgramming.fth └── 1.2-ProceduresAndTheProcessesTheyGenerate.fth ├── README.md ├── Racket ├── .gitignore ├── 1.1 The Elements Of Programming.rkt ├── 1.2 Procedures and the Processes they Generate.rkt ├── 1.3 Formulating Abstractions with Higher-Order Procedures.rkt ├── 2.1 Building Abstractions with Data.rkt ├── 2.2 Hierarchical Data and the Closure Property.rkt ├── 2.2.4 A Picture Language Example.rkt ├── 2.2.4 Painter.rkt ├── 2.3 Symbolic Data.rkt ├── 2.3.2 Symbolic Differentiation Example.rkt ├── 2.3.3 Representing Sets Example.rkt ├── 2.3.4 Huffman Encoding Trees Example.rkt ├── 2.4 Multiple Representations for Abstract Data.rkt ├── 2.5 Systems with Generic Operations.rkt ├── 3 Modularity, Objects, and State.rkt ├── 3.1 Assignment and Local State.rkt ├── Ex 1.29 Simpsons Rule.rkt ├── Ex 1.30 Iteration Sum.rkt ├── Ex 1.31 Product.rkt ├── Ex 1.32 Accumulator.rkt ├── Ex 1.33 Filtered Accumulator.rkt ├── Ex 1.35 Golden Ratio.rkt ├── Ex 1.36 X to the Power X.rkt ├── Ex 1.37 Infinite Continued Fraction.rkt ├── Ex 1.38 Euler e.rkt ├── Ex 1.39 Tan Continuous Fraction.rkt ├── Ex 1.40 Solving cubic.rkt ├── Ex 1.41 Double.rkt ├── Ex 1.42 Compose.rkt ├── Ex 1.43 Repeated.rkt ├── Ex 1.44 Smoothing.rkt ├── Ex 1.45 Finding Roots.rkt ├── Ex 1.46 Iterative Improve.rkt ├── Ex 2.1 make-rat.rkt ├── Ex 2.10 Divisions Spanning Zero.rkt ├── Ex 2.11 Rewrite multiplication.rkt ├── Ex 2.12 make center percent.rkt ├── Ex 2.13 Product Tolerances.rkt ├── Ex 2.14 Parallel Resistor Calculations.rkt ├── Ex 2.15 Parallel Resistor.rkt ├── Ex 2.17 Last pair.rkt ├── Ex 2.18 Reverse.rkt ├── Ex 2.19 Currency Converter.rkt ├── Ex 2.2 Line segment.rkt ├── Ex 2.20 Variadic Parameters.rkt ├── Ex 2.21 Square List.rkt ├── Ex 2.22 Iterative Square List.rkt ├── Ex 2.23 For Each.rkt ├── Ex 2.24 Diagrams.pdf ├── Ex 2.24 Diagrams.sketch ├── Ex 2.24 Tree Diagrams.rkt ├── Ex 2.25 Moving Through Trees.rkt ├── Ex 2.26 Append cons List.rkt ├── Ex 2.27 Deep Reverse.rkt ├── Ex 2.28 Fringe.rkt ├── Ex 2.29 Balanced mobiles.rkt ├── Ex 2.3 Rectangle twice.rkt ├── Ex 2.30 Square tree.rkt ├── Ex 2.31 Abstract Square tree.rkt ├── Ex 2.32 Subsets of Set.rkt ├── Ex 2.33 Sequence Puzzles.rkt ├── Ex 2.34 Horners Rule for Polynomials.rkt ├── Ex 2.35 Count Leaves Accumulation.rkt ├── Ex 2.36 accumulate-n.rkt ├── Ex 2.37 Vectors and Matrices.rkt ├── Ex 2.38 Fold-L Fold-R.rkt ├── Ex 2.39 Reverse with fold.rkt ├── Ex 2.4 Procedural Pairs.rkt ├── Ex 2.40 Unique pairs.rkt ├── Ex 2.41 Triple Sum.rkt ├── Ex 2.42 Queens Puzzle.rkt ├── Ex 2.43 Queens Puzzle Longtime.rkt ├── Ex 2.44 Up Split.rkt ├── Ex 2.45 Split.rkt ├── Ex 2.46 Vectors.rkt ├── Ex 2.47 Frames.rkt ├── Ex 2.48 Segments.rkt ├── Ex 2.49 Segments->Painters.rkt ├── Ex 2.5 Numeric Pair Implementation.rkt ├── Ex 2.50 flip-horiz.rkt ├── Ex 2.51 below.rkt ├── Ex 2.52 Levels of Change.rkt ├── Ex 2.53 Symbols.rkt ├── Ex 2.54 Equal?.rkt ├── Ex 2.55 abracadabra.rkt ├── Ex 2.56 Exponentiation.rkt ├── Ex 2.57 Arbitrary Sum Product.rkt ├── Ex 2.58a Infix Easy.rkt ├── Ex 2.58b Infix Hard.rkt ├── Ex 2.59 union set.rkt ├── Ex 2.6 Church Numerals.rkt ├── Ex 2.60 Duplicates in sets.rkt ├── Ex 2.61 Adjoin ordered set.rkt ├── Ex 2.62 union ordered set.rkt ├── Ex 2.63 tree->list.rkt ├── Ex 2.64 list->tree.rkt ├── Ex 2.65 On union and intersection set.rkt ├── Ex 2.66 lookup.rkt ├── Ex 2.67 Huffman Sample.rkt ├── Ex 2.68 encode symbol.rkt ├── Ex 2.69 Generate Huffman tree.rkt ├── Ex 2.7 Interval Abstraction.rkt ├── Ex 2.70 50s lyrics.rkt ├── Ex 2.71 General Huffman.rkt ├── Ex 2.72 Huffman Analysis.rkt ├── Ex 2.73 Data-directed Deriv Part-d.rkt ├── Ex 2.73 Data-directed Deriv.rkt ├── Ex 2.74 Insatiable.rkt ├── Ex 2.75 Message Passing Magnitude Angle.rkt ├── Ex 2.76 Comparison of Generic Approaches.rkt ├── Ex 2.77 Complex type error.rkt ├── Ex 2.78 Native Scheme Numbers.rkt ├── Ex 2.79 Generic Equals.rkt ├── Ex 2.8 Interval Subtraction.rkt ├── Ex 2.80 Generic Equals Zero.rkt ├── Ex 2.81 Coercion.rkt ├── Ex 2.82 Generalized apply-generic.rkt ├── Ex 2.83 Generic Raise.rkt ├── Ex 2.84 Using Raise.rkt ├── Ex 2.85 Simplify.rkt └── Ex 2.9 Interval Widths.rkt ├── SICP.pdf └── Swift ├── 1.1-TheElementsOfProgramming.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── 1.2-Procedures&theProcessesTheyGenerate.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── 1.3-FormulatingAbstractionsWithHigher-Order-Procedures.playground ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate ├── section-1.swift └── timeline.xctimeline ├── 2.1-IntroductionToDataAbstraction.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── 2.2-HierarchicalDataAndTheClosureProperty.playground ├── Sources │ └── SupportCode.swift ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ └── 2.2-HierarchicalDataAndTheClosureProperty.xccheckout │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── 2.2.4 Example- A Picture Language.playground ├── Contents.swift ├── Sources │ ├── Painter.swift │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── 2.3-Symbolic-Data.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── 2.3.2-Example-Symbolic-Differentiation.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── 2.3.3-Example-Representing-Sets.playground ├── Contents.swift ├── Resources │ ├── figure2-16.png │ └── figure2-17.png ├── Sources │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── 2.3.4-Example-Huffman-Encoding-Trees.playground ├── Contents.swift ├── Resources │ └── figure218-huffman.png ├── Sources │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── 2.4-Multiple-Representations-for-Abstract-Data.playground ├── Contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── 2.5-SystemsWithGenericOperations-Swiftly.playground ├── Contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── 2.5-SystemsWithGenericOperations.playground ├── Contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── 2.5.3-ExampleSymbolicAlgebra.playground ├── Contents.swift └── contents.xcplayground ├── Ex1.22-SearchForPrimes.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex1.23-SearchForPrimes.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex1.24-SearchForPrimes-Fermat.playground ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── section-1.swift ├── Ex1.25-expMod-Modified.playground ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── section-1.swift ├── Ex1.26-expMod-Modified.playground ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── section-1.swift ├── Ex1.27-Carmichael-Numbers.playground ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── section-1.swift ├── Ex1.28-Miller-Rabin-Test.playground ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── section-1.swift ├── Ex1.29-SimpsonsIntegration.playground ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── section-1.swift ├── Ex1.30-SumIterative.playground ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── section-1.swift ├── Ex1.31-Product.playground ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── section-1.swift ├── Ex1.32-Accumulate.playground ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── section-1.swift ├── Ex1.33-Filtered-Accumulate.playground ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── section-1.swift ├── Ex1.34-FunctionsCallingFunctions.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex1.35-Golden-Ratio.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex1.36-X-Power-X.playground ├── contents.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex1.37-Infinite-continued-fraction.playground ├── contents.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex1.38-Euler-e.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex1.39-Tan-Continuous-Function.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex1.40-Solve-Cubic.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex1.41-double.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex1.42-compose.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex1.43-repeated.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex1.44-Smoothing.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex1.45-Finding-Roots.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex1.46-Iterative-Improve.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.1-MakeRational.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.10-Division-Spanning-Zero.playground ├── Sources │ └── SupportCode.swift ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.11-Optimised-Interval-Division.playground ├── Sources │ └── SupportCode.swift ├── contents.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.12-Center-Percent-Interval.playground ├── Sources │ └── SupportCode.swift ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.13-Interval-small-tolerances.playground ├── Sources │ └── SupportCode.swift ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.14-Parallel-Resistor-Calculator.playground ├── Sources │ └── SupportCode.swift ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.15-Parallel-Calculator.playground ├── Sources │ └── SupportCode.swift ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.16-Improved-Interval.playground ├── Sources │ └── SupportCode.swift ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.17-Last-Pair.playground ├── Contents.swift ├── Sources │ ├── List.swift │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── danielpi.xcuserdatad │ └── xcdebugger │ └── Breakpoints_v2.xcbkptlist ├── Ex2.18-Reverse.playground ├── Contents.swift ├── Sources │ ├── List.swift │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.19-Change-Counting-Revisited.playground ├── Contents.swift ├── Sources │ ├── List.swift │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.2-LinesAndPoints.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.20-Variadic-Parameters.playground ├── Contents.swift ├── Sources │ ├── List.swift │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.21-Square-List.playground ├── Contents.swift ├── Sources │ ├── List.swift │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.22-Iterative-Square-List.playground ├── Contents.swift ├── Sources │ ├── List.swift │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.23-For-Each.playground ├── Contents.swift ├── Sources │ ├── List.swift │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.24-Tree-Diagrams.playground ├── Contents.swift ├── Sources │ ├── List.swift │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.25-Moving-Through-Trees.playground ├── Contents.swift ├── Sources │ ├── List.swift │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.26-Append-Cons-List.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.27-Deep-Reverse.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.28-Fringe.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.29-Binary-Mobile.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.3-Rectangles.playground ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.30-Square-Tree.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.31-Abstract-Square-Tree.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.32-Subset.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.33-Sequence-Puzzles.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.34-Horners-Rule-For-Polynomials.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.35-Count-Leaves-Accumulation.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.36-Accumulate-n.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.37-Matrix-and-Vector.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.38-foldl-foldr.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.39-Reverse-with-fold.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.4-Pairs.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.40-Unique-Pairs.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.41-Triple-Sum.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.42-Queens-Puzzle-SICP.playground ├── Contents.swift ├── Sources │ ├── Queen.swift │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.42-Queens-Puzzle.playground ├── Contents.swift ├── Sources │ ├── Queen.swift │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate ├── timeline.xctimeline └── xcuserdata │ └── danielpi.xcuserdatad │ └── xcdebugger │ └── Breakpoints_v2.xcbkptlist ├── Ex2.43-Queens-Puzzle-Slow.playground ├── Contents.swift ├── Sources │ ├── Queen.swift │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.44-Up-Split.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.45-General-Splitting.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.46-Vectors.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.47-Frame.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.48-Segment.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.49-Segments-To-Painters.playground ├── Contents.swift ├── Sources │ ├── PainterPartial.swift │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.5-SingleIntBasedPairs.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.50-Flip-Horiz.playground ├── Contents.swift ├── Sources │ ├── PainterPartial.swift │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.51-Below.playground ├── Contents.swift ├── Sources │ ├── PainterPartial.swift │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.52-Making-Changes.playground ├── Contents.swift ├── Sources │ ├── PainterPartial.swift │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.56-Exponential-Differentiation.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.57-Variadic-Parameters.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.58-Infix-Notation.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.59-Union-Set.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.6-ChurchNumerals.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.60-Set-With-Duplicates.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.61-adjoinSet-ordered.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.62-unionSet-ordered.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.63-tree->list.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.64-list->tree.playground ├── Contents.swift ├── Sources │ ├── SupportCode.swift │ └── TreeSet.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.65-union-intersection-set.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.66-Tree-Lookup.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.67-encoding-tree.playground ├── Contents.swift ├── Sources │ ├── Huffman.swift │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.68-encode.playground ├── Contents.swift ├── Sources │ ├── Huffman.swift │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.69-generate-Huffman-tree.playground ├── Contents.swift ├── Sources │ ├── Huffman.swift │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.7-Make-Interval.playground ├── Sources │ └── SupportCode.swift ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.70-50s-lyrics.playground ├── Contents.swift ├── Sources │ ├── Huffman.swift │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.71-General-Huffman.playground ├── Contents.swift ├── Sources │ ├── Huffman.swift │ └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.72-Huffman-Analysis.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.73-Data-directed-Deriv.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.74-Insatiable-Enterprises.playground ├── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.75-Message-Passing-Magnitude-Angle.playground ├── Contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.76-Comparison-Of-Generic-Approaches.playground ├── Contents.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.77-Complex-Error-Type.playground ├── Contents.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.78-Native-Scheme-Numbers.playground ├── Contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.79-Generic-Equals.playground ├── Contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.8-Interval-Subtraction.playground ├── Sources │ └── SupportCode.swift ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── Ex2.81-Coercion.playground ├── Contents.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline ├── Ex2.9-Interval-Width.playground ├── Sources │ └── SupportCode.swift ├── contents.swift ├── contents.xcplayground └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── MyPlayground.playground ├── Sources │ └── SupportCode.swift ├── contents.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── danielpi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline └── SymbolicDifferentiation.playground ├── Contents.swift ├── Sources └── SupportCode.swift ├── contents.xcplayground ├── playground.xcworkspace ├── contents.xcworkspacedata └── xcuserdata │ └── danielpi.xcuserdatad │ └── UserInterfaceState.xcuserstate └── timeline.xctimeline /Forth/1.2-ProceduresAndTheProcessesTheyGenerate.fth: -------------------------------------------------------------------------------- 1 | \ 1.2 Procedures and the Processes they Generate 2 | \ 1.2.1 Linear Recursion and Iteration 3 | \ Factorial n! 4 | \ Factorial can be thought of by noticing that n! == n * (n - 1)! . This is a 5 | \ recursive process 6 | 7 | \ 3 FACTORIAL 8 | \ 2 FACTORIAL 3 * 9 | \ 1 Factorial 2 * 3 * 10 | \ 1 2 * 3 * 11 | \ 2 3 * 12 | \ 6 13 | 14 | \ We don't appear to have compiler support for recursive function calls 15 | 16 | : FACTORIAL ( n -- n! ) 17 | 1 SWAP ( 1 n ) 18 | 1 MAX ( 1 n ) 19 | 1+ 2 ( 1 n+1 2 ) 20 | DO 21 | I * ( 1 n * n-1 * n-2 * ... 2 * ) 22 | LOOP 23 | ; 24 | 3 FACTORIAL . -------------------------------------------------------------------------------- /Racket/.gitignore: -------------------------------------------------------------------------------- 1 | # DrRacket autosave files 2 | *~ 3 | \#* 4 | .\#* 5 | 6 | # OS X specific directory information 7 | .DS_Store 8 | 9 | # Compiled racket bytecode 10 | compiled -------------------------------------------------------------------------------- /Racket/Ex 1.35 Golden Ratio.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 1.35 4 | ; Show that the golden ration is a fixed point of the transformation x -> 1 + 1/x and 5 | ; use this fact to compute the golden ration by means of the fixed-point procedure. 6 | 7 | (define tolerance 0.00001) 8 | (define (fixed-point f first-guess) 9 | (define (close-enough? v1 v2) 10 | (< (abs (- v1 v2)) tolerance)) 11 | (define (try guess) 12 | (let ((next (f guess))) 13 | (if (close-enough? guess next) 14 | next 15 | (try next)))) 16 | (try first-guess)) 17 | 18 | (define (golden-ratio) 19 | (fixed-point (lambda (x) (+ 1 (/ 1 x))) 1.0)) 20 | (golden-ratio) 21 | -------------------------------------------------------------------------------- /Racket/Ex 1.38 Euler e.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 1.38 4 | ; In 1737 the Swiss mathematician Leonhard Euler published a continued fraction expansion 5 | ; for e - 2, where e is the base of the natural logarithms. In this fraction Ni are all 1 6 | ; and the Di are successively 1 2 1 1 4 1 1 6 1 1 8 etc. Write a program that uses cont-frac 7 | ; to approximate e 8 | 9 | 10 | ; 1 2 3 4 5 6 7 8 9 10 11 11 | ; 1 2 0 1 2 0 1 2 0 12 | ; 0 0 1 1 1 2 2 2 3 3 13 | ; 1 2 1 1 4 1 1 6 1 1 8 14 | 15 | (define (cont-frac Ni Di k) 16 | (define (recur i) 17 | (if (> i k) 18 | 0 19 | (/ (Ni i) (+ (Di i) (recur (+ i 1)))))) 20 | (recur 1)) 21 | 22 | (define (euler) 23 | (define (euler-next i) 24 | (if (= 0 (remainder (+ i 1) 3)) 25 | (* 2 (quotient (+ i 1) 3)) 26 | 1)) 27 | (+ 2 (cont-frac (lambda (i) 1.0) 28 | euler-next 29 | 100))) 30 | 31 | (euler) 32 | -------------------------------------------------------------------------------- /Racket/Ex 1.39 Tan Continuous Fraction.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 1.39 4 | ; A continued fraction representation of the tangent function was published in 1770 by 5 | ; the German mathematician J.H. Lambert. 6 | ; 7 | ; x 8 | ; tan x = --------------- 9 | ; 1 - x^2 10 | ; ----------- 11 | ; 3 - x^2 12 | ; ------- 13 | ; 5 - ... 14 | ; 15 | ; where x is in radians. Define a procedure (tan-cf x k) that computes an approximation to the 16 | ; tangent function based on Lambert's formula. 17 | 18 | (define (cont-frac Ni Di k) 19 | (define (recur i) 20 | (if (> i k) 21 | 0 22 | (/ (Ni i) (+ (Di i) (recur (+ i 1)))))) 23 | (recur 1)) 24 | 25 | (define (tan-cf x k) 26 | (define (n i) 27 | (if (= i 1) 28 | (* -1 x) 29 | (* -1 x x))) 30 | (define (d i) 31 | (- (* i 2) 1)) 32 | (* -1 (cont-frac n d k))) 33 | 34 | (tan-cf 1.0 10) -------------------------------------------------------------------------------- /Racket/Ex 1.41 Double.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 1.41 4 | ; Define a procedure double that takes a procedure of one argument as argument and 5 | ; returns a procedure that applies the original procedure twice. For example, if 6 | ; inc is a procedure that adds 1 to its argument, then (double inc) should be a 7 | ; procedure that adds 2. 8 | 9 | (define (double f) 10 | (lambda (x) (f (f x)))) 11 | 12 | (define (inc x) 13 | (+ x 1)) 14 | (inc 5) 15 | ((double inc) 5) 16 | 17 | ; What value is returned by 18 | 19 | (((double (double double)) inc) 5) 20 | (((double double) inc) 5) 21 | ((double (double (double inc))) 5) -------------------------------------------------------------------------------- /Racket/Ex 1.42 Compose.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 1.42 4 | ; Let f and g be two one-argument functions. The composition f after g is defined to 5 | ; be the function x -> f(g(x)). Define a procedure compose that implements composition. 6 | ; for example, if inc is a procedure that adds 1 to its argument then 7 | ; ((compose square inc) 6) = 49 8 | 9 | (define (inc x) (+ x 1)) 10 | (define (square x) (* x x)) 11 | 12 | (define (compose f g) 13 | (lambda (x) (f (g x)))) 14 | 15 | ((compose square inc) 6) -------------------------------------------------------------------------------- /Racket/Ex 2.17 Last pair.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 2.17 4 | ; Define a procedure last-pair that returns the list that contains only the 5 | ; last element of a given (nonempty) list: 6 | 7 | (define (last-pair list) 8 | (if (null? (cdr list)) 9 | (car list) 10 | (last-pair (cdr list)))) 11 | 12 | (last-pair (list 23 72 149 34)) -------------------------------------------------------------------------------- /Racket/Ex 2.18 Reverse.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 2.18 4 | ; Define a procedure reverse that takes a list as argument and returns a list 5 | ; of the same elements in reverse order: 6 | 7 | (define (reverse list) 8 | (define (reverse-iter list reverse-list) 9 | (if (null? list) 10 | reverse-list 11 | (reverse-iter (cdr list) (cons (car list) reverse-list)))) 12 | (reverse-iter list '())) 13 | 14 | 15 | (reverse (list 1 4 9 16 25)) -------------------------------------------------------------------------------- /Racket/Ex 2.21 Square List.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 2.21 4 | ; The procedure square-list takes a list of numbers as argument and returns a list of the 5 | ; square of those numbers. 6 | 7 | ; (square-list (list 1 2 3 4)) 8 | ; (1 4 9 16) 9 | 10 | ; Here are two different definitions of square-list. Complete both of them by filling in the 11 | ; missing expressions: 12 | 13 | (define (map proc items) 14 | (if (null? items) 15 | '() 16 | (cons (proc (car items)) 17 | (map proc (cdr items))))) 18 | 19 | (define (square x) (* x x)) 20 | 21 | (define (square-list1 items) 22 | (if (null? items) 23 | '() 24 | (cons (square (car items)) 25 | (square-list1 (cdr items))))) 26 | 27 | (square-list1 (list 1 2 3 4)) 28 | 29 | 30 | (define (square-list2 items) 31 | (map square items)) 32 | 33 | (square-list2 (list 1 2 3 4)) -------------------------------------------------------------------------------- /Racket/Ex 2.23 For Each.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 2.23 4 | ; The procedure for-each is similar to map. It takes as arguments a procedure and a list of 5 | ; elements. However, rather than forming a list of the results, for-each just applies the 6 | ; procedure to each of the elements in turn, from left to right. The values returned by applying 7 | ; the procedure to the elements are not used at all -- for-each is used with procedures that 8 | ; perform an action, such as printing. For example, 9 | 10 | (for-each (lambda (x) (newline) (display x)) 11 | (list 57 321 88)) 12 | 13 | ; The value returned by the call to for-each (not illustrated above) can be something, such 14 | ; as true. Give an implmemtation of for-each 15 | 16 | (define (for-each2 proc items) 17 | (cond ((null? items) #t) 18 | (else (proc (car items)) 19 | (for-each2 proc (cdr items))))) 20 | 21 | (for-each2 (lambda (x) (newline) (display x)) 22 | (list 57 321 88)) -------------------------------------------------------------------------------- /Racket/Ex 2.24 Diagrams.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Racket/Ex 2.24 Diagrams.pdf -------------------------------------------------------------------------------- /Racket/Ex 2.24 Diagrams.sketch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Racket/Ex 2.24 Diagrams.sketch -------------------------------------------------------------------------------- /Racket/Ex 2.24 Tree Diagrams.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 2.24 4 | ; Suppose we evaluate the expression (list 1 (list 2 (list 3 4))). Give the result printed by the 5 | ; interpreter, the corresponding box-and-pointer structure, and the interpretation of this as a tree. 6 | 7 | (list 1 (list 2 (list 3 4))) 8 | ; '(1 (2 (3 4))) 9 | 10 | ; (1 (2 (3 4))) 11 | ; ^ 12 | ; / \ 13 | ; 1 ^ (2 (3 4)) 14 | ; / \ 15 | ; 2 ^ (3 4) 16 | ; / \ 17 | ; 3 4 -------------------------------------------------------------------------------- /Racket/Ex 2.26 Append cons List.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 2.26 4 | ; Suppose we define x and y to be two lists: 5 | 6 | (define x (list 1 2 3)) 7 | (define y (list 4 5 6)) 8 | 9 | ; What result is printed by the interpreter in response to evaluating each of the following 10 | ; expressions 11 | 12 | (append x y) ; '(1 2 3 4 5 6) 13 | (cons x y) ; '((1 2 3) 4 5 6) 14 | (list x y) ; '((1 2 3)(4 5 6)) -------------------------------------------------------------------------------- /Racket/Ex 2.27 Deep Reverse.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 2.27 4 | ; Modify your reverse procedure of Exercise 2.18 to produce a deep-reverse procedure that takes a list 5 | ; as argument and returns as its value the list with its elements reversed and with all sublists 6 | ; deep-reversed as well. 7 | 8 | ; For example, 9 | (define x (list (list 1 2) (list 3 4))) 10 | x 11 | ; '((1 2) (3 4)) 12 | 13 | (reverse x) 14 | ; '((3 4) (1 2)) 15 | 16 | ; (deep-reverse x) 17 | ; '((4 3) (2 1)) 18 | 19 | (define (deep-reverse list) 20 | (define (reverse-iter list reverse-list) 21 | (if (null? list) 22 | reverse-list 23 | (reverse-iter (cdr list) (cons 24 | (if (pair? (car list)) 25 | (deep-reverse (car list)) 26 | (car list)) 27 | reverse-list)))) 28 | (reverse-iter list '())) 29 | 30 | (deep-reverse x) -------------------------------------------------------------------------------- /Racket/Ex 2.28 Fringe.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 2.28 4 | ; Write a procedure fringe that taeks as argument a tree (represented as a list) and returns a list 5 | ; whose elements are all the leaves of the tree arranged in left-to-right order. For example, 6 | 7 | (define x (list (list 1 2) (list 3 4))) 8 | x ; '((1 2) (3 4)) 9 | ; (fringe x) 10 | ; (1 2 3 4) 11 | ; (fringe (list x x)) 12 | ; (1 2 3 4 1 2 3 4) 13 | 14 | (define (fringe tree) 15 | (if (null? tree) 16 | '() 17 | (if (pair? (car tree)) 18 | (append (fringe (car tree)) (fringe (cdr tree))) 19 | (cons (car tree) (fringe (cdr tree)))))) 20 | 21 | (fringe x) 22 | 23 | ; For our example this is what the above code reduces to. 24 | (append (cons 1 (cons 2 '())) (cons 3 (cons 4 '()))) -------------------------------------------------------------------------------- /Racket/Ex 2.31 Abstract Square tree.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 2.31 4 | ; Abstract your answer to Exercise 2.30 to produce a procedure tree-map with the property 5 | ; that square-tree could be defined as 6 | 7 | (define (square x) (* x x)) 8 | 9 | (define (tree-map func tree) 10 | (map (lambda (subtree) 11 | (if (pair? subtree) 12 | (tree-map func subtree) 13 | (func subtree))) 14 | tree)) 15 | 16 | (define (square-tree tree) (tree-map square tree)) 17 | 18 | (square-tree 19 | (list 1 20 | (list 2 (list 3 4) 5) 21 | (list 6 7))) -------------------------------------------------------------------------------- /Racket/Ex 2.33 Sequence Puzzles.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 2.33 4 | ; Fill in the missing expressions to complete the following definitions of some basic list-manipulation 5 | ; operations as accumulations 6 | 7 | (define (accumulate op initial sequence) 8 | (if (null? sequence) 9 | initial 10 | (op (car sequence) 11 | (accumulate op initial (cdr sequence))))) 12 | 13 | 14 | (define (map p sequence) 15 | (accumulate (lambda (x y) (cons (p x) y)) '() sequence)) 16 | (define (square x) (* x x)) 17 | (map square (list 1 2 3 4 5)) 18 | 19 | (define (append seq1 seq2) 20 | (accumulate cons seq2 seq1)) 21 | (append (list 1 2 3) (list 4 5 6)) 22 | 23 | (define (length sequence) 24 | (accumulate (lambda (x y) (+ 1 y)) 0 sequence)) 25 | (length (list 1 2 3 4 5)) -------------------------------------------------------------------------------- /Racket/Ex 2.35 Count Leaves Accumulation.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 2.35 4 | ; Redefine count-leaves from section 2.2.2 as an accumulation 5 | 6 | (define (accumulate op initial sequence) 7 | (if (null? sequence) 8 | initial 9 | (op (car sequence) 10 | (accumulate op initial (cdr sequence))))) 11 | 12 | (define (count-leaves t) 13 | (accumulate + 0 (map (lambda (node) 14 | (if (pair? node) 15 | (count-leaves node) 16 | 1)) 17 | t))) 18 | 19 | (define x (cons (list 1 2) (list 3 4))) 20 | (length x) ; 3 21 | (count-leaves x) ; 4 22 | 23 | (list x x) ; (((1 2) 3 4) ((1 2) 3 4)) 24 | (length (list x x)) ; 2 25 | (count-leaves (list x x)) ; 8 -------------------------------------------------------------------------------- /Racket/Ex 2.39 Reverse with fold.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 2.39 4 | ; Complete the following definitions of reverse in terms of fold-right and fold-left 5 | 6 | (define (fold-right op initial sequence) 7 | (if (null? sequence) 8 | initial 9 | (op (car sequence) 10 | (fold-right op initial (cdr sequence))))) 11 | 12 | (define (reverse1 sequence) 13 | (fold-right (lambda (x y) (append y (list x))) '() sequence)) 14 | 15 | (reverse1 (list 1 2 3)) 16 | 17 | (define (fold-left op initial sequence) 18 | (define (iter result rest) 19 | (if (null? rest) 20 | result 21 | (iter (op result (car rest)) 22 | (cdr rest)))) 23 | (iter initial sequence)) 24 | 25 | (define (reverse2 sequence) 26 | (fold-left (lambda (x y) (append (list y) x)) '() sequence)) 27 | 28 | (reverse2 (list 1 2 3)) -------------------------------------------------------------------------------- /Racket/Ex 2.5 Numeric Pair Implementation.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 2.5 4 | ; Show that we can represent pairs of nonnegative integers using only numbers and arithmetic operations 5 | ; if we represent the pair a and b as the integer that is the product 2^a * 3^b. Give the corresponding 6 | ; definitions fo the procedures cons, car and cdr. 7 | 8 | (define (cons a b) 9 | (* (expt 2 a) (expt 3 b))) 10 | 11 | (cons 1 1) 12 | 13 | (define (car z) 14 | (define (iter total count) 15 | (if (= 1 (remainder total 2)) 16 | count 17 | (iter (/ total 2) (+ count 1)))) 18 | (iter z 0)) 19 | (car (cons 10 5)) 20 | 21 | (define (cdr z) 22 | (define (iter total count) 23 | (if (not (= 0 (remainder total 3))) 24 | count 25 | (iter (/ total 3) (+ count 1)))) 26 | (iter z 0)) 27 | (cdr (cons 10 12)) -------------------------------------------------------------------------------- /Racket/Ex 2.53 Symbols.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 2.53 4 | ; What would the interpreter print in response to evaluating each of the following 5 | ; expressions? 6 | 7 | (list 'a 'b 'c) ; '(a b c) 8 | (list (list 'george)) ; '((george)) 9 | (cdr '((x1 x2) (y1 y2))) ; '((y1 y2)) 10 | (cadr '((x1 x2) (y1 y2))) ; '(y1 y2) 11 | (pair? (car '(a short list))) ; #f 12 | (memq 'red '((red shoes) (blue socks))) ; #f 13 | (memq 'red '(red shoes blue socks)) ; '(red shoes blue socks) -------------------------------------------------------------------------------- /Racket/Ex 2.55 abracadabra.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Eercise 2.55 4 | ; Eva Lu Ator types to the interpreter the expression 5 | 6 | (car ''abracadabra) 7 | 8 | ; To her surprise, the interpreter prints back quote. Explain 9 | 10 | ''abracadabra ; is really 11 | (quote (quote abracadabra)) 12 | 13 | ; which can also be written as 14 | 15 | (list 'quote (quote abracadabra)) 16 | 17 | ; So car will take the first item from a list which in this case is the symbol 'quote 18 | 19 | -------------------------------------------------------------------------------- /Racket/Ex 2.59 union set.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 2.59 4 | ; Implement the union-set operation for the unordered-list representation of sets. 5 | (define (element-of-set?1 x set) 6 | (cond ((null? set) false) 7 | ((equal? x (car set)) true) 8 | (else (element-of-set?1 x (cdr set))))) 9 | 10 | (define (adjoin-set1 x set) 11 | (if (element-of-set?1 x set) 12 | set 13 | (cons x set))) 14 | 15 | (define (intersection-set1 set1 set2) 16 | (cond ((or (null? set1) (null? set2)) '()) 17 | ((element-of-set?1 (car set1) set2) 18 | (cons (car set1) (intersection-set1 (cdr set1) set2))) 19 | (else (intersection-set1 (cdr set1) set2)))) 20 | 21 | (define (union-set1 set1 set2) 22 | (if (null? set1) 23 | set2 24 | (union-set1 (cdr set1) (adjoin-set1 (car set1) set2)))) 25 | 26 | (display "union-set1")(newline) 27 | (union-set1 (list 1 2 6 7 8 9 0) (list 2 3 4 5 6 7)) 28 | 29 | -------------------------------------------------------------------------------- /Racket/Ex 2.7 Interval Abstraction.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 2.7 4 | ; Implement the interval abstraction. 5 | 6 | (define (make-interval lower upper) 7 | (cons lower upper)) 8 | (define (lower-bound interval) 9 | (car interval)) 10 | (define (upper-bound interval) 11 | (cdr interval)) 12 | 13 | (define a (make-interval 9 1.1)) 14 | (lower-bound a) 15 | (upper-bound a) 16 | -------------------------------------------------------------------------------- /Racket/Ex 2.8 Interval Subtraction.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Exercise 2.8 4 | ; Describe how the difference of two intervals may be computed. Define a corresponding subtraction 5 | ; procedure, called sub-interval 6 | 7 | ; Subtract the two lower bounds and subtract the two upper bounds. 8 | 9 | (define (make-interval lower upper) 10 | (cons lower upper)) 11 | (define (lower-bound interval) 12 | (min (car interval) (cdr interval))) 13 | (define (upper-bound interval) 14 | (max (car interval) (cdr interval))) 15 | 16 | (define (sub-interval x y) 17 | (make-interval (- (lower-bound x) (lower-bound y)) 18 | (- (upper-bound x) (upper-bound y)))) 19 | 20 | (define a (make-interval 9 11.1)) 21 | (define b (make-interval 4.5 5.5)) 22 | 23 | (define c (sub-interval a b)) 24 | (lower-bound c) 25 | (upper-bound c) 26 | -------------------------------------------------------------------------------- /SICP.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/SICP.pdf -------------------------------------------------------------------------------- /Swift/1.1-TheElementsOfProgramming.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/1.1-TheElementsOfProgramming.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/1.1-TheElementsOfProgramming.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/1.1-TheElementsOfProgramming.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/1.2-Procedures&theProcessesTheyGenerate.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/1.2-Procedures&theProcessesTheyGenerate.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/1.2-Procedures&theProcessesTheyGenerate.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/1.2-Procedures&theProcessesTheyGenerate.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/1.3-FormulatingAbstractionsWithHigher-Order-Procedures.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/1.3-FormulatingAbstractionsWithHigher-Order-Procedures.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/1.3-FormulatingAbstractionsWithHigher-Order-Procedures.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/1.3-FormulatingAbstractionsWithHigher-Order-Procedures.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/2.1-IntroductionToDataAbstraction.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/2.1-IntroductionToDataAbstraction.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/2.1-IntroductionToDataAbstraction.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/2.1-IntroductionToDataAbstraction.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/2.2-HierarchicalDataAndTheClosureProperty.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to 2.2-HierarchicalDataAndTheClosureProperty.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/2.2-HierarchicalDataAndTheClosureProperty.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/2.2-HierarchicalDataAndTheClosureProperty.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/2.2-HierarchicalDataAndTheClosureProperty.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/2.2-HierarchicalDataAndTheClosureProperty.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/2.2.4 Example- A Picture Language.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to 2.2.4 Example- A Picture Language.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/2.2.4 Example- A Picture Language.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/2.2.4 Example- A Picture Language.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/2.2.4 Example- A Picture Language.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/2.2.4 Example- A Picture Language.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/2.3-Symbolic-Data.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to 2.3-Symbolic-Data.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/2.3-Symbolic-Data.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/2.3-Symbolic-Data.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/2.3-Symbolic-Data.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/2.3-Symbolic-Data.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/2.3.2-Example-Symbolic-Differentiation.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to 2.3.2-Example-Symbolic-Differentiation.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/2.3.2-Example-Symbolic-Differentiation.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/2.3.2-Example-Symbolic-Differentiation.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/2.3.2-Example-Symbolic-Differentiation.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/2.3.2-Example-Symbolic-Differentiation.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/2.3.3-Example-Representing-Sets.playground/Resources/figure2-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/2.3.3-Example-Representing-Sets.playground/Resources/figure2-16.png -------------------------------------------------------------------------------- /Swift/2.3.3-Example-Representing-Sets.playground/Resources/figure2-17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/2.3.3-Example-Representing-Sets.playground/Resources/figure2-17.png -------------------------------------------------------------------------------- /Swift/2.3.3-Example-Representing-Sets.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to 2.3.3-Example-Representing-Sets.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/2.3.3-Example-Representing-Sets.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/2.3.3-Example-Representing-Sets.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/2.3.3-Example-Representing-Sets.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/2.3.3-Example-Representing-Sets.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/2.3.3-Example-Representing-Sets.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Swift/2.3.4-Example-Huffman-Encoding-Trees.playground/Resources/figure218-huffman.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/2.3.4-Example-Huffman-Encoding-Trees.playground/Resources/figure218-huffman.png -------------------------------------------------------------------------------- /Swift/2.3.4-Example-Huffman-Encoding-Trees.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to 2.3.4-Example-Huffman-Encoding-Trees.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/2.3.4-Example-Huffman-Encoding-Trees.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/2.3.4-Example-Huffman-Encoding-Trees.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/2.3.4-Example-Huffman-Encoding-Trees.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/2.3.4-Example-Huffman-Encoding-Trees.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/2.3.4-Example-Huffman-Encoding-Trees.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Swift/2.4-Multiple-Representations-for-Abstract-Data.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/2.4-Multiple-Representations-for-Abstract-Data.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/2.4-Multiple-Representations-for-Abstract-Data.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/2.4-Multiple-Representations-for-Abstract-Data.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/2.5-SystemsWithGenericOperations-Swiftly.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/2.5-SystemsWithGenericOperations-Swiftly.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/2.5-SystemsWithGenericOperations-Swiftly.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/2.5-SystemsWithGenericOperations-Swiftly.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/2.5-SystemsWithGenericOperations.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/2.5-SystemsWithGenericOperations.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/2.5-SystemsWithGenericOperations.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/2.5-SystemsWithGenericOperations.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/2.5.3-ExampleSymbolicAlgebra.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex1.22-SearchForPrimes.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex1.22-SearchForPrimes.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.22-SearchForPrimes.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.22-SearchForPrimes.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.23-SearchForPrimes.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex1.23-SearchForPrimes.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.23-SearchForPrimes.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.23-SearchForPrimes.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.24-SearchForPrimes-Fermat.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex1.24-SearchForPrimes-Fermat.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.24-SearchForPrimes-Fermat.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.24-SearchForPrimes-Fermat.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.25-expMod-Modified.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex1.25-expMod-Modified.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.25-expMod-Modified.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.25-expMod-Modified.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.26-expMod-Modified.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex1.26-expMod-Modified.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.26-expMod-Modified.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.26-expMod-Modified.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.27-Carmichael-Numbers.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex1.27-Carmichael-Numbers.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.27-Carmichael-Numbers.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.27-Carmichael-Numbers.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.28-Miller-Rabin-Test.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex1.28-Miller-Rabin-Test.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.28-Miller-Rabin-Test.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.28-Miller-Rabin-Test.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.29-SimpsonsIntegration.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex1.29-SimpsonsIntegration.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.29-SimpsonsIntegration.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.29-SimpsonsIntegration.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.30-SumIterative.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex1.30-SumIterative.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.30-SumIterative.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.30-SumIterative.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.31-Product.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex1.31-Product.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.31-Product.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.31-Product.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.32-Accumulate.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex1.32-Accumulate.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.32-Accumulate.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.32-Accumulate.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.33-Filtered-Accumulate.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex1.33-Filtered-Accumulate.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.33-Filtered-Accumulate.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.33-Filtered-Accumulate.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.34-FunctionsCallingFunctions.playground/contents.swift: -------------------------------------------------------------------------------- 1 | // Playground - noun: a place where people can play 2 | 3 | import Cocoa 4 | 5 | func f(_ g: (Int) -> Int) -> Int { 6 | return g(2) 7 | } 8 | 9 | func square(_ x: Int) -> Int { return x * x } 10 | f(square) 11 | 12 | f({ (z:Int) -> Int in return z * (z + 1) }) 13 | 14 | // f(f) 15 | // Swifts type system catches this one. 16 | 17 | -------------------------------------------------------------------------------- /Swift/Ex1.34-FunctionsCallingFunctions.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex1.34-FunctionsCallingFunctions.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.34-FunctionsCallingFunctions.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.34-FunctionsCallingFunctions.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.35-Golden-Ratio.playground/contents.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | 3 | // Exercise 1.35 4 | // Show that the golden ration is a fixed point of the transformation x -> 1 + 1/x and use this fact to compute the golden ratio by means of the fixed-point procedure 5 | 6 | func isCloseEnough(_ a: Double, _ b: Double, _ tolerance: Double) -> Bool { 7 | return abs(a - b) < tolerance 8 | } 9 | 10 | func fixedPoint(_ f: (Double) -> Double, _ guess: Double) -> Double { 11 | let next = f(guess) 12 | if isCloseEnough(guess, next, 0.00001) { 13 | return next 14 | } else { 15 | return fixedPoint(f, next) 16 | } 17 | } 18 | 19 | let goldenRatio = fixedPoint({ (x:Double) -> Double in return 1 + (1/x)}, 1.0) 20 | goldenRatio 21 | let algebraicGoldenRatio = (1.0 + pow(5.0, 0.5)) / 2.0 22 | goldenRatio - algebraicGoldenRatio 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Swift/Ex1.35-Golden-Ratio.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex1.35-Golden-Ratio.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.35-Golden-Ratio.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.35-Golden-Ratio.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.36-X-Power-X.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex1.36-X-Power-X.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.36-X-Power-X.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.36-X-Power-X.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.36-X-Power-X.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Swift/Ex1.37-Infinite-continued-fraction.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex1.37-Infinite-continued-fraction.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.37-Infinite-continued-fraction.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.37-Infinite-continued-fraction.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.37-Infinite-continued-fraction.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Swift/Ex1.38-Euler-e.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex1.38-Euler-e.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.38-Euler-e.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.38-Euler-e.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.39-Tan-Continuous-Function.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex1.39-Tan-Continuous-Function.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.39-Tan-Continuous-Function.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.39-Tan-Continuous-Function.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.40-Solve-Cubic.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex1.40-Solve-Cubic.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.40-Solve-Cubic.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.40-Solve-Cubic.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.41-double.playground/contents.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | 3 | // Exercise 1.41 4 | // Define a procedure double that takes a procedure of one argument as argument and returns a procedure that applies the original procedure twice. For example, if inc is a procedure that adds 1 to its argument, then double(inc) should be a procedure that adds 2. 5 | 6 | typealias Calc = (Int) -> Int 7 | 8 | func inc(_ x: Int) -> Int { 9 | return x + 1 10 | } 11 | 12 | func double(_ f: @escaping Calc) -> Calc { 13 | return { (x: Int) -> Int in return f(f(x)) } 14 | } 15 | 16 | inc(5) 17 | double(inc)(5) 18 | 19 | // What value is returned by double(double(double))(inc)(5) 20 | 21 | //double(double) 22 | 23 | // Can't seem to work out how to do this one. 24 | 25 | 26 | -------------------------------------------------------------------------------- /Swift/Ex1.41-double.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex1.41-double.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.41-double.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.41-double.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.42-compose.playground/contents.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | 3 | // Exercise 1.42 4 | // Let f and g be two one-argument functions. The composition f after g is defined to be the function x -> f(g(x)). Define a procedure compose that implements composition. For example, if inc is a procedure that adds 1 to its argument, compose(square, inc)(6) == 49. 5 | 6 | func square(_ x: Double) -> Double { return x * x } 7 | func inc(_ x: Double) -> Double { return x + 1 } 8 | 9 | func compose(_ f: @escaping (T) -> T, _ g: @escaping (T) -> T) -> (T) -> T { 10 | return { (x: T) -> T in return f(g(x)) } 11 | } 12 | 13 | compose(square, inc)(6) 14 | square(inc(6)) 15 | -------------------------------------------------------------------------------- /Swift/Ex1.42-compose.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex1.42-compose.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.42-compose.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.42-compose.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.43-repeated.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex1.43-repeated.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.43-repeated.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.43-repeated.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.44-Smoothing.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex1.44-Smoothing.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.44-Smoothing.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.44-Smoothing.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.45-Finding-Roots.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex1.45-Finding-Roots.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.45-Finding-Roots.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.45-Finding-Roots.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex1.46-Iterative-Improve.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex1.46-Iterative-Improve.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex1.46-Iterative-Improve.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex1.46-Iterative-Improve.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.1-MakeRational.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.1-MakeRational.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.1-MakeRational.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.1-MakeRational.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.10-Division-Spanning-Zero.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.10-Division-Spanning-Zero.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.10-Division-Spanning-Zero.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.10-Division-Spanning-Zero.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.10-Division-Spanning-Zero.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.10-Division-Spanning-Zero.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.11-Optimised-Interval-Division.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.11-Optimised-Interval-Division.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.11-Optimised-Interval-Division.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.11-Optimised-Interval-Division.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.11-Optimised-Interval-Division.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.11-Optimised-Interval-Division.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.11-Optimised-Interval-Division.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Swift/Ex2.12-Center-Percent-Interval.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.12-Center-Percent-Interval.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.12-Center-Percent-Interval.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.12-Center-Percent-Interval.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.12-Center-Percent-Interval.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.12-Center-Percent-Interval.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.13-Interval-small-tolerances.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.13-Interval-small-tolerances.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.13-Interval-small-tolerances.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Swift/Ex2.13-Interval-small-tolerances.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.13-Interval-small-tolerances.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.13-Interval-small-tolerances.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.14-Parallel-Resistor-Calculator.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.14-Parallel-Resistor-Calculator.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.14-Parallel-Resistor-Calculator.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.14-Parallel-Resistor-Calculator.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.14-Parallel-Resistor-Calculator.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.14-Parallel-Resistor-Calculator.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.15-Parallel-Calculator.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.15-Parallel-Calculator.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.15-Parallel-Calculator.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.15-Parallel-Calculator.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.15-Parallel-Calculator.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.15-Parallel-Calculator.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.16-Improved-Interval.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.16-Improved-Interval.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.16-Improved-Interval.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.16-Improved-Interval.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.16-Improved-Interval.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.16-Improved-Interval.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.17-Last-Pair.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | 3 | // Exercise 2.17 4 | // Define a procedure lastPair() that returns the list that contains only the last element of a given (nonempty) list: 5 | 6 | func lastPair(_ list: List) -> A { 7 | if cdr(list)!.isEmpty() { 8 | return car(list)! 9 | } else { 10 | return lastPair(cdr(list)!) 11 | } 12 | } 13 | 14 | lastPair([23, 72, 149, 34]) 15 | 16 | -------------------------------------------------------------------------------- /Swift/Ex2.17-Last-Pair.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.17-Last-Pair.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.17-Last-Pair.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.17-Last-Pair.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.17-Last-Pair.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.17-Last-Pair.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.17-Last-Pair.playground/xcuserdata/danielpi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Swift/Ex2.18-Reverse.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | 3 | // Exercise 2.18 4 | // Define a procedure reverse that takes a list as argument and returns a list of the same elements in revers order 5 | 6 | func reverse(list: List) -> List { 7 | var reverseIter: (List, List) -> List = { _, _ in return List() } 8 | reverseIter = { input, output in 9 | if input.isEmpty() { 10 | return output 11 | } else { 12 | return reverseIter(cdr(input)!, cons(car(input)!, output)) 13 | } 14 | } 15 | return reverseIter(list, []) 16 | } 17 | 18 | reverse([1, 4, 9, 16, 25]) 19 | -------------------------------------------------------------------------------- /Swift/Ex2.18-Reverse.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.18-Reverse.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.18-Reverse.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.18-Reverse.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.18-Reverse.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.18-Reverse.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.18-Reverse.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex2.19-Change-Counting-Revisited.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.19-Change-Counting-Revisited.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.19-Change-Counting-Revisited.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.19-Change-Counting-Revisited.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.19-Change-Counting-Revisited.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.19-Change-Counting-Revisited.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.19-Change-Counting-Revisited.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex2.2-LinesAndPoints.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.2-LinesAndPoints.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.2-LinesAndPoints.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.2-LinesAndPoints.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.20-Variadic-Parameters.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.20-Variadic-Parameters.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.20-Variadic-Parameters.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.20-Variadic-Parameters.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.20-Variadic-Parameters.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.20-Variadic-Parameters.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.20-Variadic-Parameters.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex2.21-Square-List.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | 3 | // Exercise 2.21 4 | // The procedure square-list takes a list of numbers as argument and returns a lis of the squares of those numbers. Here are two different deffinitions of square-list. Complete both of them by filling in the missing expressions: 5 | 6 | func square(x: Int) -> Int { 7 | return x * x 8 | } 9 | 10 | func squareList(items: List) -> List { 11 | if items.isEmpty() { 12 | return [] 13 | } else { 14 | return cons(square(car(items)!), squareList(cdr(items)!)) 15 | } 16 | } 17 | print("\(squareList([1, 2, 3, 4]))") 18 | 19 | 20 | func squareList2(items: List) -> List { 21 | return items.map(square) 22 | } 23 | print("\(squareList2([1, 2, 3, 4]))") 24 | 25 | 26 | -------------------------------------------------------------------------------- /Swift/Ex2.21-Square-List.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.21-Square-List.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.21-Square-List.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.21-Square-List.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.21-Square-List.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.21-Square-List.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.21-Square-List.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex2.22-Iterative-Square-List.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.22-Iterative-Square-List.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.22-Iterative-Square-List.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.22-Iterative-Square-List.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.22-Iterative-Square-List.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.22-Iterative-Square-List.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.22-Iterative-Square-List.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex2.23-For-Each.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.23-For-Each.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.23-For-Each.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.23-For-Each.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.23-For-Each.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.23-For-Each.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.23-For-Each.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex2.24-Tree-Diagrams.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | 3 | // Exercise 2.24 4 | // Suppose we evaluate the expression (list 1 (list 2 (list 3 4))). Give the result printed by the interpreter, the corresponding box-and-pointer structure, and the interpretation of this as a tree 5 | 6 | //List(1, List(2), List(arrayLiteral: 3,4)) 7 | List(1) 8 | List(2) 9 | List(3,4) 10 | 11 | -------------------------------------------------------------------------------- /Swift/Ex2.24-Tree-Diagrams.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.24-Tree-Diagrams.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.24-Tree-Diagrams.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.24-Tree-Diagrams.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.24-Tree-Diagrams.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.24-Tree-Diagrams.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.24-Tree-Diagrams.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex2.25-Moving-Through-Trees.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | 3 | // Exercise 2.25 4 | // Give combinations of cars of cdrs that will pick 7 from each of the following lists: 5 | 6 | //let a: List = cons2(1,2) 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.25-Moving-Through-Trees.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.25-Moving-Through-Trees.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.25-Moving-Through-Trees.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.25-Moving-Through-Trees.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.25-Moving-Through-Trees.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.25-Moving-Through-Trees.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.25-Moving-Through-Trees.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex2.26-Append-Cons-List.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | 3 | // Exercise 2.26 4 | // Suppose we define x and y to be two lists: 5 | 6 | let x = [1, 2, 3] 7 | let y = [4, 5, 6] 8 | 9 | // What result is printed by the interpreter in response to evaluating each of the following expressiong 10 | 11 | // (append x y) ; (1 2 3 4 5 6) 12 | // (cons x y) ; ((1 2 3) 4 5 6) 13 | // (list x y) ; ((1 2 3) (4 5 6)) 14 | 15 | let append = x + y 16 | // let cons = // Can't do this one as Swift arrays must contain elements of the same type 17 | let list: [[Int]] = [x,y] 18 | 19 | -------------------------------------------------------------------------------- /Swift/Ex2.26-Append-Cons-List.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.26-Append-Cons-List.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.26-Append-Cons-List.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Swift/Ex2.26-Append-Cons-List.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.26-Append-Cons-List.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.26-Append-Cons-List.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.27-Deep-Reverse.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.27-Deep-Reverse.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.27-Deep-Reverse.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.27-Deep-Reverse.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.27-Deep-Reverse.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.27-Deep-Reverse.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.28-Fringe.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | 3 | // Exercise 2.28 4 | // Write a procedure fringe that takes as argument a tree (represented as a list) and returns a list whose elements are all the leaves of the tree arranged in left-to-right order. 5 | 6 | let x = [[1,2],[3,4]] 7 | let xx = [[[1,2],[3,4]],[[1,2],[3,4]]] 8 | 9 | 10 | func fringe(_ input: [[Int]]) -> [Int] { 11 | return input.flatMap{ $0 } 12 | } 13 | fringe(x) 14 | 15 | 16 | func fringe(_ input: [[[Int]]]) -> [Int] { 17 | return input.flatMap{ $0 }.flatMap{ $0 } 18 | } 19 | fringe(xx) 20 | 21 | // Again I don't see how to create a generic version of the finge function. 22 | 23 | func fringely(_ input: [[A]]) -> [A] { 24 | return input.flatMap{ $0 } 25 | } 26 | 27 | fringely(x) 28 | fringely(xx) 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Swift/Ex2.28-Fringe.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.28-Fringe.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.28-Fringe.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.28-Fringe.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.28-Fringe.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.28-Fringe.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.29-Binary-Mobile.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.29-Binary-Mobile.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.29-Binary-Mobile.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.29-Binary-Mobile.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.29-Binary-Mobile.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.29-Binary-Mobile.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.3-Rectangles.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.3-Rectangles.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.3-Rectangles.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.3-Rectangles.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.30-Square-Tree.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to 2.30-Square-Tree.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.30-Square-Tree.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.30-Square-Tree.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.30-Square-Tree.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.30-Square-Tree.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.31-Abstract-Square-Tree.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.31-Abstract-Square-Tree.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.31-Abstract-Square-Tree.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.31-Abstract-Square-Tree.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.31-Abstract-Square-Tree.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.31-Abstract-Square-Tree.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.32-Subset.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.32-Subset.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.32-Subset.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.32-Subset.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.32-Subset.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.32-Subset.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.33-Sequence-Puzzles.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.33-Sequence-Puzzles.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.33-Sequence-Puzzles.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.33-Sequence-Puzzles.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.33-Sequence-Puzzles.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.33-Sequence-Puzzles.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.34-Horners-Rule-For-Polynomials.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.34-Horners-Rule-For-Polynomials.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.34-Horners-Rule-For-Polynomials.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.34-Horners-Rule-For-Polynomials.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.34-Horners-Rule-For-Polynomials.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.34-Horners-Rule-For-Polynomials.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.35-Count-Leaves-Accumulation.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.35-Count-Leaves-Accumulation.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.35-Count-Leaves-Accumulation.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.35-Count-Leaves-Accumulation.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.35-Count-Leaves-Accumulation.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.35-Count-Leaves-Accumulation.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.36-Accumulate-n.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.36-Accumulate-n.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.36-Accumulate-n.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.36-Accumulate-n.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.36-Accumulate-n.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.36-Accumulate-n.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.37-Matrix-and-Vector.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex-2.37-Matrix-and-Vector.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.37-Matrix-and-Vector.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.37-Matrix-and-Vector.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.37-Matrix-and-Vector.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.37-Matrix-and-Vector.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.38-foldl-foldr.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.38-foldl-foldr.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.38-foldl-foldr.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.38-foldl-foldr.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.38-foldl-foldr.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.38-foldl-foldr.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.39-Reverse-with-fold.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex-2.39-Reverse-with-fold.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.39-Reverse-with-fold.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.39-Reverse-with-fold.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.39-Reverse-with-fold.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.39-Reverse-with-fold.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.4-Pairs.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | 3 | // Exercise 2.4 4 | // Here is an alternative procedural representation of pairs. For this representation, verify that car(cons(x, y)) yields x for any objects x and y. 5 | 6 | typealias DRPFunction = (Int, Int) -> Int 7 | typealias Pair = (DRPFunction) -> Int 8 | 9 | func cons2(_ x: Int, _ y: Int) -> Pair { 10 | return { (m:DRPFunction) -> Int in 11 | return m(x, y) 12 | } 13 | } 14 | 15 | func car2(_ z:Pair) -> Int { 16 | return z({ (p:Int, q:Int) -> Int in return p }) 17 | } 18 | 19 | let a = cons2(2, 3) 20 | car2(a) 21 | 22 | func cdr2(_ z:Pair) -> Int { 23 | return z({ (p:Int, q:Int) -> Int in return q }) 24 | } 25 | cdr2(a) 26 | 27 | print("\(a)") 28 | 29 | -------------------------------------------------------------------------------- /Swift/Ex2.4-Pairs.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex24Pairs.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.4-Pairs.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.4-Pairs.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.4-Pairs.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.4-Pairs.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.40-Unique-Pairs.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.40-Unique-Pairs.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.40-Unique-Pairs.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.40-Unique-Pairs.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.40-Unique-Pairs.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.40-Unique-Pairs.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.41-Triple-Sum.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.41-Triple-Sum.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.41-Triple-Sum.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.41-Triple-Sum.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.41-Triple-Sum.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.41-Triple-Sum.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.42-Queens-Puzzle-SICP.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.42-Queens-Puzzle-SICP.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.42-Queens-Puzzle-SICP.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.42-Queens-Puzzle-SICP.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.42-Queens-Puzzle-SICP.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.42-Queens-Puzzle-SICP.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.42-Queens-Puzzle.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.42-Queens-Puzzle.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.42-Queens-Puzzle.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.42-Queens-Puzzle.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.42-Queens-Puzzle.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.42-Queens-Puzzle.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.42-Queens-Puzzle.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex2.42-Queens-Puzzle.playground/xcuserdata/danielpi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Swift/Ex2.43-Queens-Puzzle-Slow.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.42-Queens-Puzzle-SICP.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.43-Queens-Puzzle-Slow.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.43-Queens-Puzzle-Slow.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.43-Queens-Puzzle-Slow.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.43-Queens-Puzzle-Slow.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.44-Up-Split.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.44-Up-Split.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.44-Up-Split.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.44-Up-Split.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.44-Up-Split.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.44-Up-Split.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.44-Up-Split.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Swift/Ex2.45-General-Splitting.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.45-General-Splitting.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.45-General-Splitting.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.45-General-Splitting.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.45-General-Splitting.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.45-General-Splitting.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.45-General-Splitting.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Swift/Ex2.46-Vectors.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.46-Vectors.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.46-Vectors.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.46-Vectors.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.46-Vectors.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.46-Vectors.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.47-Frame.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.46-Frame.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.47-Frame.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.47-Frame.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.47-Frame.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.47-Frame.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.48-Segment.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.48-Segment.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.48-Segment.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Swift/Ex2.48-Segment.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.48-Segment.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.48-Segment.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.49-Segments-To-Painters.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.49-Segments-To-Painters.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.49-Segments-To-Painters.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.49-Segments-To-Painters.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.49-Segments-To-Painters.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.49-Segments-To-Painters.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.5-SingleIntBasedPairs.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.5-SingleInt-based-Pairs.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.5-SingleIntBasedPairs.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.5-SingleIntBasedPairs.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.5-SingleIntBasedPairs.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.5-SingleIntBasedPairs.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.50-Flip-Horiz.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.50-Flip-Horiz.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.50-Flip-Horiz.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.50-Flip-Horiz.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.50-Flip-Horiz.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.50-Flip-Horiz.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.51-Below.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.51-Below.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.51-Below.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.51-Below.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.51-Below.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.51-Below.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.51-Below.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Swift/Ex2.52-Making-Changes.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.52-Making-Changes.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.52-Making-Changes.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.52-Making-Changes.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.52-Making-Changes.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.52-Making-Changes.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.56-Exponential-Differentiation.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.56-Exponential-Differentiation.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.56-Exponential-Differentiation.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.56-Exponential-Differentiation.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.56-Exponential-Differentiation.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.56-Exponential-Differentiation.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.57-Variadic-Parameters.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | 3 | //: # Exercise 2.57 4 | // Extend the differentiation program to handle sums and products of arbitrary numbers of (two or more) terms. Then the last example above could be expressed as 5 | // 6 | // deriv(* "x" "y" (+ "x" 3), "x") 7 | // 8 | // Hmmm, I had already jumped to infix notation so I don't know what to do for this problem. WIll jump straight to 2.58 as it implies that my existing solution doesn't really take care of operator precedence at the moment. 9 | 10 | 11 | -------------------------------------------------------------------------------- /Swift/Ex2.57-Variadic-Parameters.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.57-Variadic-Parameters.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.57-Variadic-Parameters.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.57-Variadic-Parameters.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.57-Variadic-Parameters.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.57-Variadic-Parameters.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.57-Variadic-Parameters.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex2.58-Infix-Notation.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.58-Infix-Notation.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.58-Infix-Notation.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.58-Infix-Notation.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.58-Infix-Notation.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.58-Infix-Notation.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.59-Union-Set.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.59-Union-Set.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.59-Union-Set.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.59-Union-Set.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.59-Union-Set.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.59-Union-Set.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.6-ChurchNumerals.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex26ChurchNumerals.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.6-ChurchNumerals.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.6-ChurchNumerals.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.6-ChurchNumerals.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.6-ChurchNumerals.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.60-Set-With-Duplicates.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.60-Set-With-Duplicates.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.60-Set-With-Duplicates.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.60-Set-With-Duplicates.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.60-Set-With-Duplicates.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.60-Set-With-Duplicates.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.61-adjoinSet-ordered.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.61-adjoinSet-ordered.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.61-adjoinSet-ordered.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.61-adjoinSet-ordered.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.61-adjoinSet-ordered.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.61-adjoinSet-ordered.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.62-unionSet-ordered.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.62-unionSet-ordered.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.62-unionSet-ordered.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.62-unionSet-ordered.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.62-unionSet-ordered.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.62-unionSet-ordered.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.63-tree->list.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.63-tree->list.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.63-tree->list.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.63-tree->list.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.63-tree->list.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.63-tree->list.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.64-list->tree.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.64-list->tree.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.64-list->tree.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.64-list->tree.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.64-list->tree.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.64-list->tree.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.64-list->tree.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex2.65-union-intersection-set.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.65-union-intersection-set.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.65-union-intersection-set.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.65-union-intersection-set.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.65-union-intersection-set.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.65-union-intersection-set.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.66-Tree-Lookup.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.66-Tree-Lookup.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.66-Tree-Lookup.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.66-Tree-Lookup.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.66-Tree-Lookup.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.66-Tree-Lookup.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.67-encoding-tree.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.67-encoding-tree.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.67-encoding-tree.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.67-encoding-tree.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.67-encoding-tree.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.67-encoding-tree.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.68-encode.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.68-encode.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.68-encode.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.68-encode.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.68-encode.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.68-encode.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.69-generate-Huffman-tree.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.69-generate-Huffman-tree.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.69-generate-Huffman-tree.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.69-generate-Huffman-tree.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.69-generate-Huffman-tree.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.69-generate-Huffman-tree.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.7-Make-Interval.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.7-Make-Interval.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.7-Make-Interval.playground/contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import Cocoa 4 | 5 | // Exercise 2.7 6 | // Alyssa's program is incomplete because she has not specified the implementation of the interval abstraction. Define an interval constructor as well as the upper-bound and lower-bound access functions. 7 | 8 | struct Interval { 9 | var lower: Double 10 | var upper: Double 11 | init(_ l: Double, _ u: Double) { 12 | self.lower = min(l,u) 13 | self.upper = max(l,u) 14 | } 15 | } 16 | 17 | let a = Interval(6.7, 6.9) 18 | let b = Interval(2.1, 2.3) 19 | 20 | a.lower 21 | a.upper 22 | b.lower 23 | b.upper 24 | 25 | -------------------------------------------------------------------------------- /Swift/Ex2.7-Make-Interval.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Swift/Ex2.7-Make-Interval.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.7-Make-Interval.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.7-Make-Interval.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.70-50s-lyrics.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.70-50s-lyrics.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.70-50s-lyrics.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.70-50s-lyrics.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.70-50s-lyrics.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.70-50s-lyrics.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.71-General-Huffman.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.71-General-Huffman.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.71-General-Huffman.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.71-General-Huffman.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.71-General-Huffman.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.71-General-Huffman.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.71-General-Huffman.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex2.72-Huffman-Analysis.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.72-Huffman-Analysis.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.72-Huffman-Analysis.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Swift/Ex2.72-Huffman-Analysis.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.72-Huffman-Analysis.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.72-Huffman-Analysis.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.73-Data-directed-Deriv.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.73-Data-directed-Deriv.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.73-Data-directed-Deriv.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.73-Data-directed-Deriv.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.73-Data-directed-Deriv.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.73-Data-directed-Deriv.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.74-Insatiable-Enterprises.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.74-Insatiable-Enterprises.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.74-Insatiable-Enterprises.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.74-Insatiable-Enterprises.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.74-Insatiable-Enterprises.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.74-Insatiable-Enterprises.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.75-Message-Passing-Magnitude-Angle.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.75-Message-Passing-Magnitude-Angle.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.75-Message-Passing-Magnitude-Angle.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.75-Message-Passing-Magnitude-Angle.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.76-Comparison-Of-Generic-Approaches.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.76-Comparison-Of-Generic-Approaches.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.76-Comparison-Of-Generic-Approaches.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.76-Comparison-Of-Generic-Approaches.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.76-Comparison-Of-Generic-Approaches.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex2.77-Complex-Error-Type.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.77-Complex-Error-Type.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.77-Complex-Error-Type.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.77-Complex-Error-Type.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.78-Native-Scheme-Numbers.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.78-Native-Scheme-Numbers.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.78-Native-Scheme-Numbers.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.78-Native-Scheme-Numbers.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.79-Generic-Equals.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.79-Generic-Equals.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.79-Generic-Equals.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.79-Generic-Equals.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.8-Interval-Subtraction.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.8-Interval-Subtraction.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.8-Interval-Subtraction.playground/contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import Cocoa 4 | 5 | // Exercise 2.8 6 | // Using reasoning analogous to Alyssa's, describe how the difference of two intervals may be computed. Define a corresponding subtraction procedure, called sub-interval. 7 | 8 | struct Interval { 9 | var lower: Double 10 | var upper: Double 11 | init(_ l: Double, _ u: Double) { 12 | self.lower = min(l,u) 13 | self.upper = max(l,u) 14 | } 15 | } 16 | 17 | // The interval created when you subtract the lower bound of a from the lower bound of b and the upper bound of a from the upper bound of b should give a reasonable subtraction function. 18 | 19 | let a = Interval(1.9, 2.1) 20 | let b = Interval(0.9, 1.1) 21 | 22 | func -(lhs: Interval, rhs: Interval) -> Interval { 23 | return Interval(lhs.lower - rhs.lower, lhs.upper - rhs.upper) 24 | } 25 | 26 | a - b 27 | 28 | -------------------------------------------------------------------------------- /Swift/Ex2.8-Interval-Subtraction.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Swift/Ex2.8-Interval-Subtraction.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.8-Interval-Subtraction.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.8-Interval-Subtraction.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.81-Coercion.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/Ex2.81-Coercion.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.81-Coercion.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.81-Coercion.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/Ex2.81-Coercion.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/Ex2.9-Interval-Width.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Ex2.9-Interval-Width.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/Ex2.9-Interval-Width.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Swift/Ex2.9-Interval-Width.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/Ex2.9-Interval-Width.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/Ex2.9-Interval-Width.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/MyPlayground.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to MyPlayground.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/MyPlayground.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/MyPlayground.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/MyPlayground.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/MyPlayground.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/MyPlayground.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Swift/SymbolicDifferentiation.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to SymbolicDifferentiation.playground. 3 | // 4 | -------------------------------------------------------------------------------- /Swift/SymbolicDifferentiation.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Swift/SymbolicDifferentiation.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/SymbolicDifferentiation.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/SICP-Exercises/46a6b38fd83faae21db239f40d913ff24062d2e6/Swift/SymbolicDifferentiation.playground/playground.xcworkspace/xcuserdata/danielpi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift/SymbolicDifferentiation.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | --------------------------------------------------------------------------------