Ramda.js R.ap() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Function

Definition

Applies a list of functions to a list of values — each function runs on every value, then results are concatenated. Part of Ramda Function since v0.3.0 (stable — not deprecated).

Note: Dispatches to an ap method on the first argument if present, and also treats curried functions as applicatives (the S combinator form below).

Syntax

Call R.ap. Start with this line.

Ramda
R.ap(fns, values) or R.ap(fns)(values)
CallWhat it does
R.ap(fns, values) or R.ap(fns)(values)Primary signature.
R.ap(...)Call the function helper.

Prefer import { ap } from "ramda" when you want a named import.

Library declarations
Ramda
R.ap(fns, values) or R.ap(fns)(values)

Parameters

ParameterDescription
applyFRequired. List of functions, or a curried function (applicative / S form)
applyXRequired. List of values, or a function of the shared input

Return Value

Return ValueDescription
*New list of results (or a function in S form)

Ramda Examples

Example 1 — Official: Multiply & Add

Apply two number helpers to the same list and concatenate the results.

Ramda
R.ap([R.multiply(2), R.add(3)], [1, 2, 3]);
// → [2, 4, 6, 4, 5, 6]
Try It Yourself

How It Works

  1. First function. R.multiply(2) maps [1,2,3] → [2,4,6].
  2. Second function. R.add(3) maps the same list → [4,5,6].
  3. Concatenate. Results join in function order: [2,4,6,4,5,6].
  4. No mutation. The input list is unchanged.

Example 2 — Official: Tasty Pizza

Prefix each string, then also uppercase each string.

Ramda
R.ap(
  [R.concat("tasty "), R.toUpper],
  ["pizza", "salad"]
);
// → ["tasty pizza", "tasty salad", "PIZZA", "SALAD"]
Try It Yourself

How It Works

  1. Prefix. R.concat("tasty ") → "tasty pizza", "tasty salad".
  2. Uppercase. R.toUpper → "PIZZA", "SALAD".
  3. Order. All results from the first function come before the second.
  4. Same pattern. Works for any unary string helpers.

Example 3 — R.ap vs R.map

One mapper vs many mappers on the same numbers.

Ramda
const nums = [1, 2, 3];

R.map(R.multiply(2), nums);
// → [2, 4, 6]

R.ap([R.multiply(2), R.add(3)], nums);
// → [2, 4, 6, 4, 5, 6]
Try It Yourself

How It Works

  1. map. One function → one result per value.
  2. ap. Two functions → two result blocks concatenated.
  3. Choose map when you have a single transform.
  4. Choose ap when several transforms should share one list.

Example 4 — S Combinator Form

Pass two functions: the same value feeds both, then the first consumes the second’s result.

Ramda
R.ap(R.concat, R.toUpper)("Ramda");
// → "RamdaRAMDA"

// Same as:
// R.concat("Ramda")(R.toUpper("Ramda"))
Try It Yourself

How It Works

  1. Shared input. "Ramda" is given to both functions.
  2. Second first in spirit. R.toUpper("Ramda") → "RAMDA".
  3. First finishes. R.concat("Ramda")("RAMDA") → "RamdaRAMDA".
  4. Rule. R.ap(f, g)(x) === f(x)(g(x)) — f must still expect one more argument.

Example 5 — Several Number Transforms

Run inc, dec, and negate over the same scores.

Ramda
R.ap([R.inc, R.dec, R.negate], [10, 20]);
// → [11, 21, 9, 19, -10, -20]
Try It Yourself

How It Works

  1. inc. [10, 20] → [11, 21].
  2. dec. → [9, 19].
  3. negate. → [-10, -20].
  4. Join. Three blocks in function order — length is fns.length × values.length.

Browser & Runtime Support

R.ap is a Ramda Function helper since v0.3.0. It runs anywhere Ramda runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install ramda.

✓ Stable · Ramda 0.3.0+

R.ap()

Available in full Ramda builds from v0.3.0 onward. Works in evergreen browsers and current Node LTS when Ramda is loaded.

100% With Ramda 0.3+
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
R.ap Ramda 0.3.0+

Bottom line: Safe for production once Ramda is loaded. Use the list form for many transforms, or the S combinator form for f(x)(g(x)). Official reference: ramdajs.com/docs/#ap.

Frequently Asked Questions

R.ap applies a list of functions to a list of values. Each function runs on every value, then the results are concatenated. Official: R.ap([R.multiply(2), R.add(3)], [1,2,3]) → [2, 4, 6, 4, 5, 6].

Next: R.apply()

Call a function with an array of arguments — useful with R.unapply and rest-style APIs.

R.apply() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful