From 161f0f08762f730cd5dca561ec1bd2dd5e502fd2 Mon Sep 17 00:00:00 2001 From: jdbillings Date: Wed, 10 Apr 2024 14:05:29 -0400 Subject: [PATCH 1/3] Revert "Add example of parsing hex and binary with to_number (#140)" This reverts commit bbaceaefb8fa64233d358678d59e89a20439eda5. --- pages/docs/arguments.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pages/docs/arguments.md b/pages/docs/arguments.md index c75ce29..49d6e39 100644 --- a/pages/docs/arguments.md +++ b/pages/docs/arguments.md @@ -78,21 +78,17 @@ llo ld! ``` -Functor **to_number(*string*)** transforms a string representing a number to its associated number, it also recognises hex and binary numbers with a prefix. +Functor **to_number(*string*)** transforms a string representing a number to its associated number. ```prolog .decl tonumber(n:number) .output tonumber tonumber(n) :- n=to_number("123"). tonumber(n) :- n=to_number("1534"). -tonumber(n) :- n=to_number("0xff"). -tonumber(n) :- n=to_number("0b111"). ``` The output would be: ``` 123 1534 -255 -7 ``` The reverse operation **to_string(*number*)** also exists, which turns a number to its string representation. From cfe95d561cec7f6c55f30a114f2116324640736e Mon Sep 17 00:00:00 2001 From: jdbillings Date: Wed, 10 Apr 2024 14:22:42 -0400 Subject: [PATCH 2/3] Add back the example with binary and hex strings, but with a version disclaimer --- pages/docs/arguments.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pages/docs/arguments.md b/pages/docs/arguments.md index 49d6e39..4086fd5 100644 --- a/pages/docs/arguments.md +++ b/pages/docs/arguments.md @@ -90,6 +90,18 @@ The output would be: 123 1534 ``` +In souffle >2.4.1, or when building from source after [030e111b](https://github.com/souffle-lang/souffle/commit/030e111be9e3aa90033092e56ce49af96dd36790), functor **to_number(*string*)** will also recognise hex and binary strings with a prefix. +```prolog +.decl tonumber(n:number) +.output tonumber +tonumber(n) :- n=to_number("0xff"). +tonumber(n) :- n=to_number("0b111"). +``` +The output would be: +``` +255 +7 +``` The reverse operation **to_string(*number*)** also exists, which turns a number to its string representation. Soufflé supports standard arithmetic operations **+**, **-**, *****, **/**, **^** and **%**. Examples of this are given below. From 156dabdb5a69654f41fda157a50e1cd483addf08 Mon Sep 17 00:00:00 2001 From: Quentin Sabah Date: Tue, 25 Mar 2025 08:24:12 +0100 Subject: [PATCH 3/3] Update arguments.md --- pages/docs/arguments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/docs/arguments.md b/pages/docs/arguments.md index 4086fd5..69bdd75 100644 --- a/pages/docs/arguments.md +++ b/pages/docs/arguments.md @@ -90,7 +90,7 @@ The output would be: 123 1534 ``` -In souffle >2.4.1, or when building from source after [030e111b](https://github.com/souffle-lang/souffle/commit/030e111be9e3aa90033092e56ce49af96dd36790), functor **to_number(*string*)** will also recognise hex and binary strings with a prefix. +In souffle `>=2.5`, functor **to_number(*string*)** also recognises hex and binary strings with a prefix. ```prolog .decl tonumber(n:number) .output tonumber