main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
875 bytes
|
Line | |
---|
1 | var _curry3 =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./internal/_curry3.js");
|
---|
4 | /**
|
---|
5 | * Takes a predicate, a transformation function, and an initial value,
|
---|
6 | * and returns a value of the same type as the initial value.
|
---|
7 | * It does so by applying the transformation until the predicate is satisfied,
|
---|
8 | * at which point it returns the satisfactory value.
|
---|
9 | *
|
---|
10 | * @func
|
---|
11 | * @memberOf R
|
---|
12 | * @since v0.20.0
|
---|
13 | * @category Logic
|
---|
14 | * @sig (a -> Boolean) -> (a -> a) -> a -> a
|
---|
15 | * @param {Function} pred A predicate function
|
---|
16 | * @param {Function} fn The iterator function
|
---|
17 | * @param {*} init Initial value
|
---|
18 | * @return {*} Final value that satisfies predicate
|
---|
19 | * @example
|
---|
20 | *
|
---|
21 | * R.until(R.gt(R.__, 100), R.multiply(2))(1) // => 128
|
---|
22 | */
|
---|
23 |
|
---|
24 |
|
---|
25 | var until =
|
---|
26 | /*#__PURE__*/
|
---|
27 | _curry3(function until(pred, fn, init) {
|
---|
28 | var val = init;
|
---|
29 |
|
---|
30 | while (!pred(val)) {
|
---|
31 | val = fn(val);
|
---|
32 | }
|
---|
33 |
|
---|
34 | return val;
|
---|
35 | });
|
---|
36 |
|
---|
37 | module.exports = until; |
---|
Note:
See
TracBrowser
for help on using the repository browser.