From ae1f5a37607e4c4ece88c223b90264615b76ed1f Mon Sep 17 00:00:00 2001 From: xrstf Date: Tue, 5 Dec 2023 16:38:38 +0100 Subject: [PATCH] update docs --- docs/README.md | 2 +- docs/functions/README.md | 2 +- docs/functions/math-div.md | 5 ++++- pkg/eval/functions/args_consumer.go | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/README.md b/docs/README.md index cf97877..d5e584a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -67,7 +67,7 @@ Welcome to the Rudi documentation :smile: * [`*`](functions/math-mult.md) – returns the product of all of its arguments * [`+`](functions/math-add.md) – returns the sum of all of its arguments * [`-`](functions/math-sub.md) – returns arg1 - arg2 - .. - argN -* [`/`](functions/math-div.md) – returns arg1 / arg2 / .. / argN +* [`/`](functions/math-div.md) – returns arg1 / arg2 / .. / argN (always a floating point division, regardless of arguments) ## Strings Functions diff --git a/docs/functions/README.md b/docs/functions/README.md index c26c1f5..70146d0 100644 --- a/docs/functions/README.md +++ b/docs/functions/README.md @@ -71,7 +71,7 @@ applied to all functions (so technically `eq?!` is valid, though weird looking). * [`*`](../functions/math-mult.md) – returns the product of all of its arguments * [`+`](../functions/math-add.md) – returns the sum of all of its arguments * [`-`](../functions/math-sub.md) – returns arg1 - arg2 - .. - argN -* [`/`](../functions/math-div.md) – returns arg1 / arg2 / .. / argN +* [`/`](../functions/math-div.md) – returns arg1 / arg2 / .. / argN (always a floating point division, regardless of arguments) ## Strings Functions diff --git a/docs/functions/math-div.md b/docs/functions/math-div.md index 6672656..84338f4 100644 --- a/docs/functions/math-div.md +++ b/docs/functions/math-div.md @@ -3,9 +3,12 @@ `/` returns the quotient of dividing all arguments. Arguments must evaluate to numeric values. `div` is an alias for this function. +To prevent ambiguity, this function always performs floating point divisions, +regardless if all its arguments are integer numbers. + ## Examples -* `(/ 9 3 2)` -> `1.5` ((9 / 3) / 2) +* `(/ 9 3 2)` -> `1.5` ((9.0 / 3.0) / 2.0) * `(/ 1 0)` -> invalid: division by zero ## Forms diff --git a/pkg/eval/functions/args_consumer.go b/pkg/eval/functions/args_consumer.go index 95662cd..823f074 100644 --- a/pkg/eval/functions/args_consumer.go +++ b/pkg/eval/functions/args_consumer.go @@ -222,7 +222,7 @@ func contextConsumer(ctx types.Context, args []cachedExpression) (asserted []any return []any{ctx}, args, nil } -// toVariadicConsumer wraps a singular consumer to consume all remaining args. In constrast to +// toVariadicConsumer wraps a singular consumer to consume all remaining args. In contrast to // Go, variadic arguments must have at least 1 item (i.e. calling func(foo string, a ...int) with // ("abc") only is invalid). func toVariadicConsumer(singleConsumer argsConsumer) argsConsumer {