Skip to content

Commit

Permalink
ChrisMarinos#77 Ensure that all existing changes to base koans were r…
Browse files Browse the repository at this point in the history
…emoved
  • Loading branch information
normanhh3 committed Mar 20, 2019
1 parent 4201b50 commit c2a8eb1
Show file tree
Hide file tree
Showing 21 changed files with 148 additions and 181 deletions.
15 changes: 7 additions & 8 deletions FSharpKoans/AboutArrays.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace FSharpKoans
open FSharpKoans.Core
open System.Collections.Generic

//---------------------------------------------------------------
// About Arrays
Expand All @@ -13,9 +12,9 @@ module ``about arrays`` =
let CreatingArrays() =
let fruits = [| "apple"; "pear"; "peach"|]

AssertEquality fruits.[0] "apple"
AssertEquality fruits.[1] "pear"
AssertEquality fruits.[2] "peach"
AssertEquality fruits.[0] __
AssertEquality fruits.[1] __
AssertEquality fruits.[2] __

[<Koan>]
let ArraysAreDotNetArrays() =
Expand All @@ -33,15 +32,15 @@ module ``about arrays`` =
let fruits = [| "apple"; "pear" |]
fruits.[1] <- "peach"

AssertEquality fruits [| "apple"; "peach" |]
AssertEquality fruits __

[<Koan>]
let YouCanCreateArraysWithComprehensions() =
let numbers =
[| for i in 0..10 do
if i % 2 = 0 then yield i |]

AssertEquality numbers [| 0; 2; 4; 6; 8; 10 |]
AssertEquality numbers __

[<Koan>]
let ThereAreAlsoSomeOperationsYouCanPerformOnArrays() =
Expand All @@ -51,5 +50,5 @@ module ``about arrays`` =
let original = [| 0..5 |]
let result = Array.map cube original

AssertEquality original [| 0..5 |]
AssertEquality result [| 0; 1; 8; 27; 64; 125 |]
AssertEquality original __
AssertEquality result __
4 changes: 2 additions & 2 deletions FSharpKoans/AboutAsserts.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ module ``about asserts`` =
[<Koan>]
let AssertExpectation() =
let expected_value = 1 + 1
let actual_value = 2 //start by changing this line
let actual_value = __ //start by changing this line

AssertEquality expected_value actual_value

//Easy, right? Now try one more

[<Koan>]
let FillInValues() =
AssertEquality (1 + 1) 2
AssertEquality (1 + 1) __
16 changes: 8 additions & 8 deletions FSharpKoans/AboutBranching.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module ``about branching`` =
"it's odd!"

let result = isEven 2
AssertEquality result "it's even!"
AssertEquality result __

[<Koan>]
let IfStatementsReturnValues() =
Expand All @@ -34,7 +34,7 @@ module ``about branching`` =
else
"no problem here"

AssertEquality result "no problem here"
AssertEquality result __

[<Koan>]
let BranchingWithAPatternMatch() =
Expand All @@ -46,8 +46,8 @@ module ``about branching`` =
let result1 = isApple "apple"
let result2 = isApple ""

AssertEquality result1 true
AssertEquality result2 false
AssertEquality result1 __
AssertEquality result2 __

[<Koan>]
let UsingTuplesWithIfStatementsQuicklyBecomesClumsy() =
Expand All @@ -64,8 +64,8 @@ module ``about branching`` =
let person1 = ("Chris", "steak")
let person2 = ("Dave", "veggies")

AssertEquality (getDinner person1) "Chris wants 'em some steak"
AssertEquality (getDinner person2) "Dave doesn't want red meat"
AssertEquality (getDinner person1) __
AssertEquality (getDinner person2) __

[<Koan>]
let PatternMatchingIsNicer() =
Expand All @@ -80,5 +80,5 @@ module ``about branching`` =
let person1 = ("Bob", "fish")
let person2 = ("Sally", "Burger")

AssertEquality (getDinner person1) "Bob doesn't want red meat"
AssertEquality (getDinner person2) "Sally wants 'em some Burger"
AssertEquality (getDinner person1) __
AssertEquality (getDinner person2) __
12 changes: 6 additions & 6 deletions FSharpKoans/AboutClasses.fs
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,29 @@ module ``about classes`` =
let ClassesCanHaveProperties() =
let zombie = new Zombie()

AssertEquality zombie.FavoriteFood "brains"
AssertEquality zombie.FavoriteFood __

[<Koan>]
let ClassesCanHaveMethods() =
let zombie = new Zombie()

let result = zombie.Eat "brains"
AssertEquality result "mmmmmmmmmmmmmmm"
AssertEquality result __

[<Koan>]
let ClassesCanHaveConstructors() =

let person = new Person("Shaun")

let result = person.Speak()
AssertEquality result "Hi my name is Shaun"
AssertEquality result __

[<Koan>]
let ClassesCanHaveLetBindingsInsideThem() =
let zombie = new Zombie2()

let result = zombie.Eat "chicken"
AssertEquality result "grrrrrrrr"
AssertEquality result __

(* TRY IT: Can you access the let bound value Zombie2.favoriteFood
outside of the class definition? *)
Expand All @@ -75,8 +75,8 @@ module ``about classes`` =
let person = new Person2("Shaun")

let firstPhrase = person.Speak()
AssertEquality firstPhrase "Hi my name is Shaun"
AssertEquality firstPhrase __

person.Name <- "Shaun of the Dead"
let secondPhrase = person.Speak()
AssertEquality secondPhrase "Hi my name is Shaun of the Dead"
AssertEquality secondPhrase __
6 changes: 3 additions & 3 deletions FSharpKoans/AboutDiscriminatedUnions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module ``about discriminated unions`` =

let choice = Mustard

AssertEquality (toColor choice) "yellow"
AssertEquality (toColor choice) __

(* TRY IT: What happens if you remove a case from the above pattern
match? *)
Expand All @@ -51,5 +51,5 @@ module ``about discriminated unions`` =
let bourbonResult = saySomethingAboutYourFavorite <| Bourbon "Maker's Mark"
let numberResult = saySomethingAboutYourFavorite <| Number 7

AssertEquality bourbonResult "I prefer Bookers to Maker's Mark"
AssertEquality numberResult "me too!"
AssertEquality bourbonResult __
AssertEquality numberResult __
20 changes: 10 additions & 10 deletions FSharpKoans/AboutDotNetCollections.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ module ``about dot net collections`` =
fruits.Add("apple")
fruits.Add("pear")

AssertEquality fruits.[0] "apple"
AssertEquality fruits.[1] "pear"
AssertEquality fruits.[0] __
AssertEquality fruits.[1] __

[<Koan>]
let CreatingDotNetDictionaries() =
Expand All @@ -29,8 +29,8 @@ module ``about dot net collections`` =
addressBook.["Chris"] <- "Ann Arbor"
addressBook.["SkillsMatter"] <- "London"

AssertEquality addressBook.["Chris"] "Ann Arbor"
AssertEquality addressBook.["SkillsMatter"] "London"
AssertEquality addressBook.["Chris"] __
AssertEquality addressBook.["SkillsMatter"] __

[<Koan>]
let YouUseCombinatorsWithDotNetTypes() =
Expand All @@ -49,15 +49,15 @@ module ``about dot net collections`` =
// that you can combine to perform operations on types implementing
// seq/IEnumerable.

AssertEquality verboseBook.[0] "Name: Chris - City: Ann Arbor"
AssertEquality verboseBook.[1] "Name: SkillsMatter - City: London"
AssertEquality verboseBook.[0] __
AssertEquality verboseBook.[1] __

[<Koan>]
let SkippingElements() =
let original = [0..5]
let result = Seq.skip 2 original |> Seq.toList
let result = Seq.skip 2 original

AssertEquality result [2; 3; 4; 5]
AssertEquality result __

[<Koan>]
let FindingTheMax() =
Expand All @@ -71,7 +71,7 @@ module ``about dot net collections`` =

let result = Seq.max values

AssertEquality result 20
AssertEquality result __

[<Koan>]
let FindingTheMaxUsingACondition() =
Expand All @@ -81,4 +81,4 @@ module ``about dot net collections`` =
let names = [| "Harry"; "Lloyd"; "Nicholas"; "Mary"; "Joe"; |]
let result = Seq.maxBy getNameLength names

AssertEquality result "Nicholas"
AssertEquality result __
20 changes: 10 additions & 10 deletions FSharpKoans/AboutFiltering.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module ``about filtering`` =
names
|> List.filter (fun name -> name.StartsWith( "A" ))

AssertEquality actual_names [ "Alice" ]
AssertEquality actual_names [ __ ]

//Or passing a function to filter
let startsWithTheLetterB (s: string) =
Expand All @@ -41,18 +41,18 @@ module ``about filtering`` =
names
|> List.filter startsWithTheLetterB

AssertEquality namesBeginningWithB [ "Bob" ]
AssertEquality namesBeginningWithB [ __ ]

[<Koan>]
let FindingJustOneItem() =
let names = [ "Alice"; "Bob"; "Eve" ]
let names = [ "Alice"; "Bob"; "Eve"; ]
let expected_name = "Bob"

// find will return just one item, or throws an exception

let actual_name =
names
|> List.find (fun name -> name = "Bob" )
|> List.find (fun name -> name = __ )

//??? What would happen if there are 2 Bobs in the List?

Expand All @@ -70,8 +70,8 @@ module ``about filtering`` =
names
|> List.tryFind (fun name -> name = "Zelda" )

AssertEquality eve.IsSome true
AssertEquality zelda.IsSome false
AssertEquality eve.IsSome __
AssertEquality zelda.IsSome __

[<Koan>]
let ChoosingItemsFromAList() =
Expand All @@ -83,7 +83,7 @@ module ``about filtering`` =
numbers
|> List.choose someIfEven

AssertEquality evenNumbers [ 2 ]
AssertEquality evenNumbers [ __ ]

//You can also use the "id" function on types of 'a option list
//"id" will return just those that are "Some"
Expand All @@ -94,7 +94,7 @@ module ``about filtering`` =
|> List.choose id

//Notice the type of namesWithValue is 'string list', whereas optionNames is 'string option list'
AssertEquality namesWithValue [ "Alice" ]
AssertEquality namesWithValue [ __ ]

[<Koan>]
let PickingItemsFromAList() =
Expand All @@ -106,7 +106,7 @@ module ``about filtering`` =
numbers
|> List.pick someIfEven

AssertEquality firstEven 6
AssertEquality firstEven __

//As with choose, you can also use the "id" function on types of 'a option list
//to return just those that are "Some"
Expand All @@ -116,6 +116,6 @@ module ``about filtering`` =
optionNames
|> List.pick id

AssertEquality firstNameWithValue "Alice"
AssertEquality firstNameWithValue __

//There is also a tryPick which works like tryFind, returning "None" instead of throwing an exception.
10 changes: 5 additions & 5 deletions FSharpKoans/AboutFunctions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ module ``about functions`` =
let result1 = add 2 2
let result2 = add 5 2

AssertEquality result1 4
AssertEquality result2 7
AssertEquality result1 __
AssertEquality result2 __

[<Koan>]
let NestingFunctions() =
Expand All @@ -36,7 +36,7 @@ module ``about functions`` =
double(double(x))

let result = quadruple 4
AssertEquality result 16
AssertEquality result __

[<Koan>]
let AddingTypeAnnotations() =
Expand All @@ -48,7 +48,7 @@ module ``about functions`` =
text.Replace(" ", "")

let auctioneered = sayItLikeAnAuctioneer "going once going twice sold to the lady in red"
AssertEquality auctioneered "goingoncegoingtwicesoldtotheladyinred"
AssertEquality auctioneered __

//TRY IT: What happens if you remove the type annotation on text?

Expand All @@ -63,7 +63,7 @@ module ``about functions`` =

let caffeinatedReply = caffeinate "hello there"

AssertEquality caffeinatedReply "HELLO THERE!!!"
AssertEquality caffeinatedReply __

(* NOTE: Accessing the suffix variable in the nested caffeinate function
is known as a closure.
Expand Down
12 changes: 6 additions & 6 deletions FSharpKoans/AboutLet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module ``about let`` =
let LetBindsANameToAValue() =
let x = 50

AssertEquality x 50
AssertEquality x __

(* In F#, values created with let are inferred to have a type like
"int" for integer values, "string" for text values, and "bool"
Expand All @@ -28,7 +28,7 @@ module ``about let`` =

let y = "a string"
let expectedType = y.GetType()
AssertEquality expectedType typeof<string>
AssertEquality expectedType typeof<FILL_ME_IN>

[<Koan>]
let YouCanMakeTypesExplicit() =
Expand All @@ -38,8 +38,8 @@ module ``about let`` =
let y:string = "forty two"
let typeOfY = y.GetType()

AssertEquality typeOfX typeof<int>
AssertEquality typeOfY typeof<string>
AssertEquality typeOfX typeof<FILL_ME_IN>
AssertEquality typeOfY typeof<FILL_ME_IN>

(* You don't usually need to provide explicit type annotations types for
local variables, but type annotations can come in handy in other
Expand Down Expand Up @@ -68,7 +68,7 @@ module ``about let`` =
let mutable x = 100
x <- 200

AssertEquality x 200
AssertEquality x __

[<Koan>]
let YouCannotModifyALetBoundValueIfItIsNotMutable() =
Expand All @@ -82,4 +82,4 @@ module ``about let`` =
// to reuse the name of a value in some cases using "shadowing".
let x = 100

AssertEquality x 100
AssertEquality x __
Loading

0 comments on commit c2a8eb1

Please sign in to comment.