Skip to content

Commit 1862af9

Browse files
committed
Minor refactoring on swap module
1 parent 1918cf9 commit 1862af9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/swap.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
'use strict'
22
const adjustIndex = require('./adjust-index')
33
const and = require('./and')
4-
const concat = require('./concat')
4+
const arrayify = require('./arrayify')
55
const curry = require('./curry')
66
const decr = require('./decr')
77
const eq = require('./eq')
88
const head = require('./head')
99
const isEmpty = require('./is-empty')
1010
const len = require('./len')
1111
const map = require('./map')
12+
const mapcat = require('./mapcat')
1213
const max = require('./max')
1314
const min = require('./min')
1415
const notArr = require('./not-arr')
1516
const notStr = require('./not-str')
1617
const or = require('./or')
1718
const partitionAt = require('./partition-at')
18-
const prepend = require('./prepend')
1919
const sub = require('./sub')
2020
const tail = require('./tail')
2121

@@ -30,7 +30,8 @@ function swap(i, j, xs) {
3030

3131
const [hd, rest] = partitionAt(min(k, n), xs)
3232
const [md, tl] = partitionAt(sub(max(k, n), len(hd)), rest)
33-
return concat(hd, concat(prepend(head(tl), tail(md)), prepend(head(md), tail(tl))))
33+
34+
return mapcat(arrayify, [hd, head(tl), tail(md), head(md), tail(tl)])
3435
}
3536

3637
module.exports = curry(swap)

0 commit comments

Comments
 (0)