User.reds is collection of useful functions and definitions.
PI
CRLF
Return absolute value of number (integer! and float! version)
Usage:
abs -3
== 3
fabs -3.14
== -3.0
Return x power y (integer! version only)
Usage:
2 ** 3
== 8
Negate integer! number
negate 23
== -23
Converts float! value to integer!
Usage:
float-to-int 3.14
== 3
Converts integer! value to float!
Usage:
int-to-float 3
== 3.0
Converts integer! to readable string
Usage:
form-int 123
== "123"
Converts string to integer!
Usage:
load-int "123"
== 123
Convert string with single digit (0-9) to byte!
Usage:
load-byte "6"
== 6
Convert string with byte value (0-255) to byte!
Usage:
load-byte "123"
== 123
Move one position forward or backward in string. NOTE: This is just simple pointer arithmetics and doesn't check for boundaries!
Usage:
next "adamov"
== "damov"
Check if first value of given c-string! is null-byte
Usage:
end? next "x"
== true
Compares two strings.
Usage:
equal-string? string-1 string-2
Check if the beginnign of string is same other string.
Usage:
match-string "Hello world!" "Hello"
== true
Find substring in string.
Usage:
find-string "Hello world!" "world"
== "world!"
Return new string that is reversed copy of original string
Usage:
reverse-string "BRNO"
== "ONRB"
Change begining of the string with new value, or change string at index with new value
Usage:
change-string "Rebol" "Red"
== "Redol"
change-string-at "Rebol" "d" 3
== "Redol"
Copy substring to given match
Usage:
copy-string-to "Hello, World" ","
== "Hello"
Count character occurrence in string.
Usage:
count-char "There are three spaces" #" "
== 3
This file is distributed under same BSL license as Red/System runtime.