Skip to content

Commit

Permalink
Merge pull request #134 from gcanti/133
Browse files Browse the repository at this point in the history
change `Array.snoc` fix #133
  • Loading branch information
gcanti authored Jun 21, 2017
2 parents 888349d + a0e5d3f commit 1855de3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
**Note**: Gaps between patch versions are faulty/broken releases.
**Note**: A feature tagged as Experimental is in a high state of flux, you're at risk of it changing without notice.

# 0.3.4

- **Bug Fix**
- `Array.snoc` returns wrong results with nested arrays, fix #133 (@gcanti)

# 0.3.3

- **New Feature**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fp-ts",
"version": "0.3.3",
"version": "0.3.4",
"description": "Functional programming in TypeScript",
"files": [
"lib"
Expand Down
2 changes: 1 addition & 1 deletion src/Array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export function cons<A>(a: A, as: Array<A>): Array<A> {
}

export function snoc<A>(as: Array<A>, a: A): Array<A> {
return as.concat(a)
return as.concat([a])
}

export function head<A>(as: Array<A>): Option<A> {
Expand Down
2 changes: 2 additions & 0 deletions test/Array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ describe('Array', () => {

it('cons', () => {
assert.deepEqual(array.cons(0, as), [0, 1, 2, 3])
assert.deepEqual(array.cons([1], [[2]]), [[1], [2]])
})

it('snoc', () => {
assert.deepEqual(array.snoc(as, 4), [1, 2, 3, 4])
assert.deepEqual(array.snoc([[1]], [2]), [[1], [2]])
})

it('curriedSnoc', () => {
Expand Down

0 comments on commit 1855de3

Please sign in to comment.