R.apex

  • Docs
  • Tutorials
Docs Menu
  • Func
  • R.Funcs
    • Conversion Funcs
    • Arithmetic Funcs
    • Logic Funcs
    • Relation Funcs
    • Function Funcs
    • Comparator Funcs
    • Condition Funcs
    • List Funcs
    • String Funcs
    • Map Funcs
    • Utility Funcs
    • Database Funcs
  • R.Instance
    • Creation Methods
    • Conversion Methods
    • Methods

List Funcs Guide

List Funcs in R

adjust

Adjust the element using the function.

R.adjust.run(R.inc, 1, R.with(1, 2, 3))
// (1, 3, 3)

all

Check if all elements match the predicate.

R.all.run(R.isNotNull, R.with(1, 2, 3))
// true

append

Append an element to the elements.

R.append.run(1, R.with(1, 2, 3))
// (1, 2, 3, 1)

assoc

Set the key value.

R.assoc.run('name', 'test', new Map())
// {name=test}

biMap

Map over both the keys and values.

R.bimap.run(R.append.apply('_key'), R.append.apply('_value'), R.withObj('name', 'test'))
// {test_key=test_value}

concat

Concatenate two objects.

R.concat.run(R.with(1, 2, 3), R.with(4, 5, 6))
// (4, 5, 6, 1, 2, 3)

contains

Check if the element is contained.

R.contains.run(1, R.with(1, 2, 3))
// true

containsBy

Check if the element is contained by the comparator returning boolean.

R.containsBy.run(R.equals, 1, R.with(1, 2, 3))
// true

containsKey

Check if the key is contained.

R.containsKey.run('name', new Map{ 'name' => 'test' })
// true

countBy

Get counts by the key.

R.countBy.run(R.identity, R.with(1, 2, 2))
// {1=1, 2=2}

difference

Make a difference of the two objects.

R.difference.run(R.with(1, 2, 3), R.with(2, 3, 4))
// (4)

dissoc

Remove the key value.

R.dissoc.run('name', new Map{ 'name' => 'test' })
// {}

doInsert

Insert element at the index.

R.doInsert.run(1, 'x', R.with(1, 2, 3))
// (1, x, 2, 3)

doInsertAll

Insert elements at the index.

R.doInsertAll.run(1, R.with('x', 'y'), R.with(1, 2, 3))
// (1, x, y, 2, 3)

doJoin

Join the elements by the separator.

R.doJoin.run('-', R.with(1, 2, 3))
// 1-2-3

doMap

Map over the elements.

R.doMap.run(R.inc, R.with(1, 2, 3))
// (2, 3, 4)

doUpdate

Update an element of the elements.

R.doUpdate.run(1, 3, R.with(1, 2, 3))
// (1, 3, 3)

drop

Drop first N elements.

R.drop.run(1, 'abc')
// bc

dropRight

Drop first N elements from right.

R.dropRight.run(1, 'abc')
// ab

dropRightWhile

Drop elements from right until not satisfied.

R.dropRightWhile.run(R.equals.apply('a'), 'abc')
// abc

dropWhile

Drop elements until not satisfied.

R.dropWhile.run(R.equals.apply('a'), 'abc')
// bc

endsWith

Check ending with.

R.endsWith('a', 'abc')
// false

every

Same as all.

filter

Filter on the elements.

R.filter.run(R.isNotNull, R.with('a', null, 'b'))
// (a, b)

find

Find the first element that matches the predicate.

R.find.run(R.equals.apply('a'), R.with('a', 'b'))
// a

findIndex

Find the index of the first element that matches the predicate.

R.findIndex.run(R.equals.apply('a'), R.with('a', 'b'))
// 0

findLast

Find the first element from last that matches the predicate.

R.findLast.run(R.equals.apply('a'), R.with('a', 'b'))
// a

findLastIndex

Find the index of the first element from last that matches the predicate.

R.findLastIndex.run(R.equals.apply('a'), R.with('a', 'b'))
// 0

first

Get the first element.

R.first.run(R.with(1, 2, 3))
// 1

flatten

Flatten the elements recursively.

R.flatten.run(R.with(1, R.with(2, R.with(3))))
// (1, 2, 3)

forEach

Do for-each on the elements.

R.forEach.run(R.debug, R.with(1, 2, 3));
// 1
// 2
// 3

fromPairs

Convert a list of pairs to map.

R.fromPairs.run(R.with(new R.Pair('a', 1)))
// {a=1}

groupBy

Get groups by the key.

R.groupBy.run(R.identity, R.with(1, 2, 2))
// {1=(1), 2=(2, 2)}

head

Same as first.

indexBy

Get indexes by the key.

R.indexBy.run(R.identity, R.with(1, 2, 2))
// {1=1, 2=2}

indexOf

Get the index of the first element found.

R.indexOf.run(1, R.with(1, 2, 3))
// 0

init

Get the elements except the last.

R.init.run(R.with(1, 2, 3))
// (1, 2)

intersection

Make an intersection of the two objects.

R.intersection.run(R.with(1, 2, 3), R.with(2, 3, 4))
// (2, 3)

isEmpty

Check if it is empty.

R.isEmpty.run(R.with(1, 2, 3))
// false

last

Get the last element.

R.last.run(R.with(1, 2, 3))
// 3

lastIndexOf

Get the index of the first element found from the last.

R.lastIndexOf.run(1, R.with(1, 2, 3))
// 0

length

Get the length.

R.length.run(R.with(1, 2, 3))
// 3

none

Check if none of the elements match the predicate.

R.none.run(R.isNotNull, R.with(1, 2, 3))
// true

nth

Get the nth element.

R.nth.run(1, R.with(1, 2, 3))
// 2

pair

Create a pair.

R.pair.run(1, 2)
// Pair:[fst=1, snd=2]

partition

Create a partitioned pair using the predicate.

R.partition.run(R.equals.apply('a'), R.with('a', 'b', 'c'))
// Pair:[fst=(a), snd=(b, c)]

pluck

Pluck the fields out of elements.

R.pluck.run('Description', R.with(new Account(Description='desc')))
// (desc)

prepend

Prepend an element to the elements.

R.prepend.run(1, R.with(1, 2, 3))
// (1, 1, 2, 3)

project

Project elements into other elements according to the fields.

R.project.run(R.with('Description'), R.with(new Account(Description='desc')))
// ({Description=desc})

range

Generate a range of decimals.

R.range.run(1, 3)
// (1, 2)

reduce

Reduce over the elements.

R.reduce.run(R.add, 0, R.with(1, 2, 3))
// 6

reject

Reject on the elements.

R.reject.run(R.isNull, R.with('a', null, 'b'))
// (a, b)

remove

Remove elements.

R.remove.run(1, 2, R.with(1, 2, 3))
// (1)

repeat

Repeat the target to generate elements.

R.repeat.run(5, 'a')
// (a, a, a, a, a)

reverse

Reverse the elements.

R.reverse.run('abc')
// cba

sample

Get a random element.

R.sample.run('abcdef')
// e

sampleSize

Get a list of random elements.

R.sampleSize.run(2, 'abcdef')
// df

shuffle

Create a shuffled collection.

R.shuffle.run('abcdef')
// fdeabc

size

Get the size. See length.

slice

Get a slice of the elements.

R.slice.run(0, 1, R.with(1, 2, 3))
// (1)

some

Check if some elements match the predicate.

R.some.run(R.isNotNull, R.with(1, 2, 3))
// false

sortBy

Sort by the comparator.

R.sortBy.run(R.compare, R.with(3, 2, 1))
// (1, 2, 3)

sortDefault

Sort by default.

R.sortDefault.run(R.with(3, 2, 1))
// (1, 2, 3)

startsWith

Check starting with.

R.startsWith('a', 'abc')
// true

sum

Get the sum.

R.sum.run(R.with(1, 2, 3))
// 6

tail

Get the elements except the first.

R.tail.run(R.with(1, 2, 3))
// (2, 3)

take

Take the first N elements.

R.take.run(1, 'abc')
// a

takeRight

Take the first N elements from right.

R.takeRight.run(1, 'abc')
// c

takeRightWhile

Take elements from right until not satisfied.

R.takeRightWhile.run(R.equals.apply('a'), 'abc')
//

takeWhile

Take elements until not satisfied.

R.takeWhile.run(R.equals.apply('a'), 'abc')
// a

times

Invoke a function for N times.

R.times.run(3, R.identity)
// (0, 1, 2)

toPairs

Convert a map to a list of pairs.

R.toPairs.run(new Map{ 'name' => 'test' })
// (Pair:[fst=name, snd=test])

union

Make a union of the two objects.

R.union.run(R.with(1, 2, 3), R.with(2, 3, 4))
// (2, 3, 4, 1)

uniq

Get a unique collection of the elements.

R.uniq.run(R.with(1, 2, 2))
// (1, 2)

unnest

Flatten the elements by one level.

R.unnest.run(R.with(1, R.with(2, 3)))
// (1, 2, 3)

without

Same with difference.

xor

Make an xor of the two objects.

R.xor.run(R.with(1, 2, 3), R.with(2, 3, 4))
// (4, 1)

zip

Zip two collections to create a list of pairs.

R.zip.run(R.with('a', 'b'), R.with(1, 2))
// (Pair:[fst=a, snd=1], Pair:[fst=b, snd=2])

zipObj

Zip two collections to create a map.

R.zipObj.run(R.with('a', 'b'), R.with(1, 2))
// {a=1, b=2}

Contribute on Github! Edit this section.