tests/testthat/test_compose.R

test_that("compose", {
  f = compose(function(x) x + 1, function(x) x / 2)
  expect_equal(f(10), 6)

  f = compose(sqrt)
  expect_equal(f(4), 2)
  expect_error(compose(), "length")
})

Try the mlr3misc package in your browser

Any scripts or data that you put into this service are public.

mlr3misc documentation built on Sept. 20, 2023, 5:06 p.m.