Skip to content

Nitpicking on example in chapter 8 #479

@eevman

Description

@eevman

In "My First Functor", there is this example:

Container.of('bombs').map(concat(' away')).map(prop('length')); 
// Container(10)

Assuming that concat is defined as in appendix C:

const concat = curry((a, b) => a.concat(b));

Container.of('bombs').map(concat(' away'))
gives the result

Container(' awaybombs')

and not

Container('bombs away')

which I suppose was the intended meaning...
Of course both give the final answer 10 :-)
Shouldn't the example be:

Container.of('bombs').map(append(' away')).map(prop('length')); 
// Container(10)

where append is:

const append = flip(concat);

or something similar?
Or is maybe concat defined as

const concat = curry((a, b) => b.concat(a));

but then it would be difficult to know what function concat does without looking at the implementation...
Any thoughts on this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions