Assignment 3: Higher-Order Functions, Algebraic Data Types, and Pattern Matching in SwiftDue Wednesday, August 25 at 11:59 PMGoals for This AssignmentBy the time you have completed this work, you should be able to:Work with the basics of the syntax of SwiftDefine a list with an algebraic data type (enumin Swift)Deconstruct algebraic data types with pattern matching (switchin Swift)Define methods which take higher-order functionsProvided files:main.swift
Due Wednesday, August 25 at 11:59 PM
By the time you have completed this work, you should be able to:
enum
switch
main.swift
Step-by-Step InstructionsStep 1: Get Swift WorkingFor this assignment, you'll be using Swift. You can either install Swift fromthis link, or run it in the browserhere. Binaries are available for Ubuntu Linux and Mac OS X. Exactly which method you use doesn't matter; it will work the same either way.Step 2: Implement a Singly-Linked ListA significant of code has been provided inmain.swift, including a test suite of significant size. As with assignment 1, you are tasked with writing a singly-linked list. However, this time around, you'll be doing this in Swift. Instead of using dynamic dispatch to select betweenconsandnilbehavior, you'll be using pattern matching viaswitch. Additionally, you'll also be defining key list-based operations which work with higher-order functions, namelyfilterandmap. The comments in the file provide further details. Note that the tests themselves are a rich source of information, both in terms of defining what you need to implement (i.e., they serve as a specification), and how Swift works.step 3: send main.swift file
For this assignment, you'll be using Swift. You can either install Swift fromthis link, or run it in the browserhere. Binaries are available for Ubuntu Linux and Mac OS X. Exactly which method you use doesn't matter; it will work the same either way.
A significant of code has been provided inmain.swift, including a test suite of significant size. As with assignment 1, you are tasked with writing a singly-linked list. However, this time around, you'll be doing this in Swift. Instead of using dynamic dispatch to select betweenconsandnilbehavior, you'll be using pattern matching viaswitch. Additionally, you'll also be defining key list-based operations which work with higher-order functions, namelyfilterandmap. The comments in the file provide further details. Note that the tests themselves are a rich source of information, both in terms of defining what you need to implement (i.e., they serve as a specification), and how Swift works.
cons
nil
filter
map
step 3: send main.swift file
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here