Merge pull request #741 from triska/determinism
reflect improved determinism thanks to the improvements by @notoria
This commit is contained in:
@@ -212,8 +212,7 @@ read_line_to_chars(Stream, Cs0, Cs) :-
|
|||||||
Example:
|
Example:
|
||||||
|
|
||||||
?- chars_base64("hello", Bs, []).
|
?- chars_base64("hello", Bs, []).
|
||||||
Bs = "aGVsbG8="
|
Bs = "aGVsbG8=".
|
||||||
; false.
|
|
||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|
||||||
chars_base64(Cs, Bs, Options) :-
|
chars_base64(Cs, Bs, Options) :-
|
||||||
|
|||||||
@@ -58,8 +58,7 @@
|
|||||||
Example:
|
Example:
|
||||||
|
|
||||||
?- hex_bytes("501ACE", Bs).
|
?- hex_bytes("501ACE", Bs).
|
||||||
Bs = [80,26,206]
|
Bs = [80,26,206].
|
||||||
; false.
|
|
||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|
||||||
|
|
||||||
@@ -146,7 +145,7 @@ must_be_byte_chars(Chars, Context) :-
|
|||||||
?- crypto_n_random_bytes(32, Bs),
|
?- crypto_n_random_bytes(32, Bs),
|
||||||
bytes_integer(Bs, I).
|
bytes_integer(Bs, I).
|
||||||
Bs = [146,166,162,210,242,7,25,132,64,94|...],
|
Bs = [146,166,162,210,242,7,25,132,64,94|...],
|
||||||
I = 337420085690608915485...(56 digits omitted)
|
I = 337420085690608915485...(56 digits omitted).
|
||||||
|
|
||||||
The above relation also works in the other direction, letting you
|
The above relation also works in the other direction, letting you
|
||||||
translate an integer _to_ a list of bytes. In addition, you can
|
translate an integer _to_ a list of bytes. In addition, you can
|
||||||
@@ -155,7 +154,7 @@ must_be_byte_chars(Chars, Context) :-
|
|||||||
|
|
||||||
?- crypto_n_random_bytes(12, Bs),
|
?- crypto_n_random_bytes(12, Bs),
|
||||||
hex_bytes(Hex, Bs).
|
hex_bytes(Hex, Bs).
|
||||||
Bs = [34,25,50,72,58,63,50,172,32,46|...], Hex = "221932483a3f32ac202 ..."
|
Bs = [34,25,50,72,58,63,50,172,32,46|...], Hex = "221932483a3f32ac202 ...".
|
||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|
||||||
|
|
||||||
@@ -190,8 +189,7 @@ crypto_random_byte(B) :- '$crypto_random_byte'(B).
|
|||||||
Example:
|
Example:
|
||||||
|
|
||||||
?- crypto_data_hash("abc", Hs, [algorithm(sha256)]).
|
?- crypto_data_hash("abc", Hs, [algorithm(sha256)]).
|
||||||
Hs = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
|
Hs = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad".
|
||||||
; false.
|
|
||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|
||||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|||||||
@@ -166,19 +166,16 @@ file_time_(File, Which, T) :-
|
|||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
?- path_segments("/hello/there", Segments).
|
?- path_segments("/hello/there", Segments).
|
||||||
Segments = [[],"hello","there"]
|
Segments = [[],"hello","there"].
|
||||||
; false.
|
|
||||||
|
|
||||||
?- path_segments(Path, ["hello","there"]).
|
?- path_segments(Path, ["hello","there"]).
|
||||||
Path = "hello/there"
|
Path = "hello/there".
|
||||||
; false.
|
|
||||||
|
|
||||||
|
|
||||||
To obtain the platform-specific directory separator, you can use:
|
To obtain the platform-specific directory separator, you can use:
|
||||||
|
|
||||||
?- path_segments(Separator, ["",""]).
|
?- path_segments(Separator, ["",""]).
|
||||||
Separator = "/"
|
Separator = "/".
|
||||||
; false.
|
|
||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|
||||||
path_segments(Path, Segments) :-
|
path_segments(Path, Segments) :-
|
||||||
|
|||||||
@@ -64,8 +64,7 @@
|
|||||||
Example:
|
Example:
|
||||||
|
|
||||||
?- phrase(format_("~s~n~`.t~w!~12|", ["hello",there]), Cs).
|
?- phrase(format_("~s~n~`.t~w!~12|", ["hello",there]), Cs).
|
||||||
%@ Cs = "hello\n......there!"
|
%@ Cs = "hello\n......there!".
|
||||||
%@ ; false.
|
|
||||||
|
|
||||||
I place this code in the public domain. Use it in any way you want.
|
I place this code in the public domain. Use it in any way you want.
|
||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|||||||
@@ -7,8 +7,7 @@
|
|||||||
Example:
|
Example:
|
||||||
|
|
||||||
?- getenv("LANG", Ls).
|
?- getenv("LANG", Ls).
|
||||||
Ls = "en_US.UTF-8"
|
Ls = "en_US.UTF-8".
|
||||||
; false.
|
|
||||||
|
|
||||||
Public domain code.
|
Public domain code.
|
||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|||||||
@@ -34,8 +34,7 @@
|
|||||||
Example:
|
Example:
|
||||||
|
|
||||||
?- current_time(T), phrase(format_time("%d.%m.%Y (%H:%M:%S)", T), Cs).
|
?- current_time(T), phrase(format_time("%d.%m.%Y (%H:%M:%S)", T), Cs).
|
||||||
T = [...], Cs = "11.06.2020 (00:24:32)"
|
T = [...], Cs = "11.06.2020 (00:24:32)".
|
||||||
; false.
|
|
||||||
|
|
||||||
sleep(S) sleeps for S seconds (a floating point number).
|
sleep(S) sleeps for S seconds (a floating point number).
|
||||||
|
|
||||||
@@ -107,15 +106,14 @@ report_time(T0) :-
|
|||||||
false.
|
false.
|
||||||
|
|
||||||
:- time(use_module(library(clpz))).
|
:- time(use_module(library(clpz))).
|
||||||
% CPU time: 2.762 seconds
|
% CPU time: 0.000 seconds
|
||||||
true
|
% CPU time: 0.001 seconds
|
||||||
; false.
|
true.
|
||||||
|
|
||||||
:- time(use_module(library(lists))).
|
:- time(use_module(library(lists))).
|
||||||
% CPU time: 0.000 seconds
|
% CPU time: 0.000 seconds
|
||||||
true
|
% CPU time: 0.001 seconds
|
||||||
; % CPU time: 0.001 seconds
|
true.
|
||||||
false.
|
|
||||||
|
|
||||||
?- time(member(X, [a,b,c])).
|
?- time(member(X, [a,b,c])).
|
||||||
% CPU time: 0.000 seconds
|
% CPU time: 0.000 seconds
|
||||||
|
|||||||
Reference in New Issue
Block a user