GithubHelp home page GithubHelp logo

afarnham / swiftfpexercises Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dtchepak/swiftfpexercises

0.0 2.0 0.0 169 KB

Collection of FPish exercises in Swift

License: MIT License

Swift 100.00%

swiftfpexercises's Introduction

This is a collection of ad hoc exercises written to illustrate some FP concepts using Swift, which I've tried to assemble into something relatively cohesive.

Note that the aim here is not idiomatic or even good Swift code! Instead we're focusing on language-independent concepts like map and flatMap. Hopefully this will help us with our real Swift code by showing us some common patterns for using lists, options, observables and other types that have flatMap.

The original exercises were designed to be done with guidance from an instructor, so if you get stuck it is not your fault! Any time you run into an exercise that doesn't make sense from the context/comments alone or seems like too big a leap then please leave feedback via Github Issues.

Requires Swift 4+/Xcode 9.

Instructions

The SwiftFpExercisesTests folder in the project contains a number of exercises, starting with Ex01_Map.swift. The aim is to fill in all the TODO comments and calls with valid implementations. Each time a TODO is completed one or more of the tests should start passing. Once all the TODOs are gone and the tests are passing then move on to the next exercise.

NOTE: Some tests in Ex03_Result.swift are commented out to prevent them interfering with earlier tests, so make sure you uncomment them to complete that exercise when you get up to it.

Some of the exercises also contain one or more EXTENSION comments. These are additional tasks thrown in for funโ•, usually quite abruptly and with very little guidance, for those who'd like to try something a bit different. While the main exercises are intended to be completed in order, the extensions can safely be skipped.

โ• YMMV :)

Swift Parser Exercises

The Parser combinators exercise in this repository is a port of an exercise by Tony Morris/NICTA written in Haskell. Please direct all credit to that original project, and attribute any mistakes to me.

The licence/copyright information for the original exercises is included below.

Licence for original Parser exercises

Licence source

Copyright 2010-2013 Tony Morris
Copyright 2012-2015 National ICT Australia Limited 2012-2014
Copyright 2012      James Earl Douglas
Copyright 2012      Ben Sinclair

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. Neither the name of the author nor the names of his contributors
   may be used to endorse or promote products derived from this software
   without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

swiftfpexercises's People

Contributors

dtchepak avatar anthonyegerton avatar mdubs avatar xerxesb avatar

Watchers

Aaron Farnham avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.