How to use the append function from ramda

Find comprehensive JavaScript ramda.append code examples handpicked from public code repositorys.

27
28
29
30
31
32
33
34
35
36
// View

const update = (action, model) =>
  Action.case({
    Insert: () => R.evolve({nextId: R.add(1),
                           counters: R.append([model.nextId, counter.init(0)])}, model),
    Remove: () => R.evolve({counters: R.tail}, model),
    Modify: (id, counterAction) =>
      R.evolve({counters: R.map((c) => {
                  const [counterId, counterModel] = c;
fork icon92
star icon0
watch icon72

11
12
13
14
15
16
17
18
19
}

function changeEndPath(folderName, path) {
  const pathAsArray = R.split('/', path);
  const initOfPath = R.init(pathAsArray);
  const folderAddedToPath = R.append(folderName, initOfPath);

  return R.join('/', folderAddedToPath);
}
fork icon1
star icon0
watch icon2

13
14
15
16
17
18
19
20
21
22
    'cwd',
    dir === '/'
      ? R.always([])
      : dir === '..'
      ? R.slice(0, -1)
      : R.append(dir),
    state,
  )
} else if (command === 'ls') {
  const fileSizes = parseDirOutput(output)
fork icon0
star icon1
watch icon0

30
31
32
33
34
35
36
37
38
39
40
// console.log(totalCost / cityCount);


const groupByPropReducer = (acc, city) => {
	const { cost = [], internetSpeed = [] } = acc;
	return R.merge(acc, {
		cost: R.append(city.cost, cost),
		internetSpeed: R.append(city.internetSpeed, internetSpeed)
	});
};

fork icon0
star icon1
watch icon0

63
64
65
66
67
68
69
70
71
72
const targetMonkeys = R.map(worry => monkeys[index][monkeys[index].test(worry)], worries)
const currentMonkey = R.lensIndex(index)
return R.compose(
  R.reduce((acc, [item, target]) => R.over(
    R.compose(R.lensIndex(target), R.lensProp('items')), 
    R.append(item)
  )(acc), R.__, R.zip(worries, targetMonkeys)),
  R.over(currentMonkey, R.assoc('items', [])),
  R.over(R.compose(currentMonkey, R.lensProp('inspects')), R.add(R.length(worries)))
)(monkeys)
fork icon0
star icon0
watch icon0

+ 3 other calls in file

1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
 * @see R.prepend
 * @example
 *
 *      R.append('tests', ['write', 'more']); //=> ['write', 'more', 'tests']
 *      R.append('tests', []); //=> ['tests']
 *      R.append(['tests'], ['write', 'more']); //=> ['write', 'more', ['tests']]
 */
var append = _curry2(function append(el, list) {
    return _concat(list, [el]);
});
fork icon0
star icon0
watch icon0

+ 71 other calls in file

18
19
20
21
22
23
24
25
26
27
28
29
30


const UINT32_MAX = Math.pow(2, 32) - 1;
const PRIMES = [160481183, 179424673, 198491317, 217645177];


const Rand = {
  _nextSeed: seed => R.append(pureRandom.randUint(seed), R.slice(1, 4, seed)),
  _random: (seed, min, max) => Math.round(min + pureRandom.randUint(seed) / UINT32_MAX * (max - min)),


  makeSeed: (iseed, n) => iseed ? R.reduceRight(R.compose, R.identity, R.repeat(Rand._nextSeed, n || 10))(PRIMES.map(p => p * iseed)) : pureRandom.genSeed(),

fork icon0
star icon0
watch icon0

+ 6 other calls in file

35
36
37
38
39
40
41
42
43
44
45
46
47
const snd = require('crocks/Pair/snd');


const UINT32_MAX = Math.pow(2, 32) - 1;
const PRIMES = [160481183, 179424673, 198491317, 217645177];


const nextGen = gen => R.append(pureRandom.randUint(gen), R.slice(1, 4, gen));
const mkStdGen = (seed, n) => seed ? R.reduceRight(R.compose, R.identity, R.repeat(nextGen, n || 10))(PRIMES.map(p => p * seed)) : pureRandom.genSeed();
const random = (seed, min, max) => Math.round(min + pureRandom.randUint(seed) / UINT32_MAX * (max - min));


const foldM = (f, a, list) => {
fork icon0
star icon0
watch icon0

+ 4 other calls in file

200
201
202
203
204
205
206
207
208
209
var orderDependencies = function orderDependencies(graph) {
  var recur = function recur(ins, outs) {
    if (R.isEmpty(ins)) {
      return outs;
    } else if (R.all(R.contains(_, outs), graph[R.head(ins)])) {
      return recur(R.tail(ins), R.append(R.head(ins), outs));
    } else {
      return recur(R.append(R.head(ins), R.tail(ins)), outs);
    }
  };
fork icon0
star icon0
watch icon0

29
30
31
32
33
34
35
36
37
38
39
40


const groupByPropReducer = (acc, city) => {
  const { cost = [], internetSpeed = [] } = acc;
  return R.merge(acc, {
    cost: R.append(city.cost, cost),
    internetSpeed: R.append(city.internetSpeed, internetSpeed),
  });
}


const groupedByProp = R.reduce(groupByPropReducer, {}, cities);
fork icon0
star icon0
watch icon0

+ 5 other calls in file

25
26
27
28
29
30
31
32
33
34
};


const executeIfResultIsSuccessful = R.curry(async (fn, result) => {
    let currentResult = await fn();
    return transformResult((currentValue) => {
        return R.append(currentValue, result);
    })(currentResult);
})
module.exports = onSuccess;
fork icon0
star icon0
watch icon0

94
95
96
97
98
99
100
101
102
103
104
105
106


const grainCount = fillWithSand(board, limits);
console.log(grainCount);


const ylim = limits[1][1] + 2;
const linesAndFloor = R.append([
  [500 - ylim, ylim],
  [500 + ylim, ylim]], lines);


const caveLimits = getLimits(linesAndFloor);
fork icon0
star icon0
watch icon0

26
27
28
29
30
31
32
33
34
35
36
37


const column = (cave, c) => R.compose(
  R.map(R.nth(R.__, cave)),
  R.map(coordinatesToIndex),
  R.apply(R.xprod),
  R.append(R.__, [[c]])
)(R.range(0, normalizedMax[1] + 1))
const row = (cave, r) => R.slice(r * (normalizedMax[0] + 1), (r+1) * (normalizedMax[0] + 1), cave)


const cave = Array(R.apply(R.multiply)(R.map(R.inc, normalizeCoordinates(maxDimensions)))).fill('.')
fork icon0
star icon0
watch icon0

+ 2 other calls in file

29
30
31
32
33
34
35
36
37
38
R.reduce(R.mergeWith(R.merge), {}),
R.map(R.compose(
    R.assocPath(R.__, 1, {}),
    R.map(R.toString))),

R.append(end),
R.unfold((pos) => {
  if (R.equals(pos, end)) return false;
  return [pos, R.zipWith(R.add, pos, direction)];
}))(start);
fork icon0
star icon0
watch icon0

16
17
18
19
20
21
22
23
24

const winFor = (acc, next) => {
  const isIncluded = R.lte(next - interval)
  const list = R.takeLastWhile(isIncluded, acc)

  return R.append(next, list)
}

const windows = R.scan(winFor, [], log)
fork icon0
star icon0
watch icon0

53
54
55
56
57
58
59
60
61
62
  R.compose(
    R.prepend('x'),
    R.pluck(0)
  )(series[0])
),
series => R.append(
  others(limit)(otherLabel)(series),
  R.take(limit, series)
),
R.sort((a, b) => R.sum(R.tail(b)) - R.sum(R.tail(a))),
fork icon0
star icon0
watch icon1

Other functions in ramda

Sorted by popularity

function icon

ramda.clone is the most popular function in ramda (30311 examples)