In PureScript, the expression:
lift2 f (pure a) (pure b)is equivalent to:
| /* | |
| * q1.js | |
| * Script used to complete COMP 3711H Fall 2019-20 Written Assignemtn #4 Question 1 | |
| * If you used this script in your assignment then you MUST make attribution to it! | |
| * Author: @DonaldKellett (LEUNG, Donald Sebastian) | |
| */ | |
| // Original weight matrix W | |
| let wMatrix = [ | |
| [0, 8, 10, Infinity, 3, Infinity], |
| (* | |
| * A formal proof that @Blind4Basics is getting smarter every day | |
| * Special thanks to @AwelEshetu for raising this question and | |
| * @Steffan153 for challenging me into making this compile ;-) | |
| *) | |
| Definition Blind4Basics (_ _ _ _ _ : unit) := True. | |
| Definition is := tt. | |
| Definition getting := tt. |
| module Hashable | |
| ( HashCode | |
| , hashCode | |
| , class Hashable | |
| , hash | |
| , hashEqual | |
| , combineHashes | |
| ) where | |
| -- Supplementary module for MoreHashables.purs |
| module Superclasses where | |
| import Prelude | |
| import Data.Array | |
| import Data.Foldable | |
| import Data.Maybe | |
| -- Exercise 1 | |
| maxOf :: Partial => Array Int -> Int | |
| maxOf = fromJust <<< maximum |
| module InstanceDependencies where | |
| import Prelude | |
| import Data.Array | |
| import Data.Foldable | |
| -- Boilerplate for Exercises 1-3, 5 | |
| data NonEmpty a = NonEmpty a (Array a) | |
| -- For easier debugging |
| module CommonTypeClasses where | |
| import Prelude | |
| -- Boilerplate code | |
| newtype Complex = Complex | |
| { real :: Number | |
| , imaginary :: Number | |
| } |
| module ShowMe where | |
| import Prelude | |
| -- Utilities from https://github.com/paf31/purescript-book/blob/master/exercises/chapter5/src/Data/Picture.purs | |
| -- required to complete this exercise | |
| data Point = Point | |
| { x :: Number | |
| , y :: Number |
| module PictureExtended where | |
| -- Based on and extended from the project setup of 5. Pattern Matching | |
| -- of PureScript by Example: | |
| -- https://github.com/paf31/purescript-book/blob/master/exercises/chapter5/src/Data/Picture.purs | |
| import Prelude | |
| import Data.Foldable (foldl) | |
| import Global as Global |
| module RecordPuns where | |
| import Prelude | |
| import Data.Maybe | |
| -- Utilities provided in 5.12 Algebraic Data Types of PureScript by Example | |
| data Shape | |
| = Circle Point Number | |
| | Rectangle Point Number Number | |
| | Line Point Point |