Skip to content

Functional Data Structures Section corrections #24

@tim-ruhland

Description

@tim-ruhland

I was unable to do PR for following. I couldn't find source for first item.
Multiple edits, separated by horizontal lines


The sealed trait definition for List is missing the case class for Cons
should be:

sealed trait List[+A]
case object Nil extends List[Nothing]
case class Cons[+A](head: A, tail: List[A]) extends List[A]


just prior to the tail function definition, "...how we handle the use of take on Nil lists:"
should be "tail" instead of "take"


"We can generalize take to the function drop,..."
should be:
"We can generalize tail to the function drop,..."


Where the statement: "Let's apply the same principle as we use in map..." appears, the "map" term has not been defined.
The section above this statement (which corresponds to 'add1' in the red book) is a specific application of "map", but it isn't described as such.
The book follows 'add1' with an exercise to generalize it to "map". This could probably be corrected by just adding some additional explanatory text to the 'add1' section.


The 'flatMap' section, which provides this definition:

def flatMap[A, B](l: List[A])(f: A => List[B]): List[B] =
concat(map(l)(f))

uses the concat function, which has not been discussed or covered in previous sections. At a minimum, there should be some description of what concat does.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions