Files
modeling-app/docs/kcl/rem.md
Adam Chalmers 6366bc4766 KCL: Keyword function calls for stdlib (#4647)
Part of https://github.com/KittyCAD/modeling-app/issues/4600

Adds support for keyword arguments to the stdlib, and calling stdlib functions with keyword arguments.

So far, I've changed one function: `rem`. Previously you would have used `rem(7, 2)` but now it's `rem(7, divisor: 2)`.

This is a proof-of-concept. If it's approved, we will:

1. Support closures with keyword arguments, and calling them
2. Move the rest of the stdlib to use kw arguments
2024-12-05 14:27:51 -06:00

26 KiB

title, excerpt, layout
title excerpt layout
rem Compute the remainder after dividing `num` by `div`. manual

Compute the remainder after dividing num by div.

If num is negative, the result will be too.

rem(num: i64, divisor: i64) -> i64

Tags

  • math

Arguments

Name Type Description Required
num i64 Yes
divisor i64 Yes

Returns

i64

Examples

assertEqual(rem(7, divisor: 4), 3, 0.01, "remainder is 3")
assertEqual(rem(-7, divisor: 4), -3, 0.01, "remainder is 3")
assertEqual(rem(7, divisor: -4), 3, 0.01, "remainder is 3")

Rendered example of rem 0