Merge branch 'master' into http-server

This commit is contained in:
Adrián Arroyo Calle
2020-12-27 12:18:05 +01:00
19 changed files with 262 additions and 126 deletions

View File

@@ -212,8 +212,7 @@ read_line_to_chars(Stream, Cs0, Cs) :-
Example:
?- chars_base64("hello", Bs, []).
Bs = "aGVsbG8="
; false.
Bs = "aGVsbG8=".
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
chars_base64(Cs, Bs, Options) :-

View File

@@ -58,8 +58,7 @@
Example:
?- hex_bytes("501ACE", Bs).
Bs = [80,26,206]
; false.
Bs = [80,26,206].
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
@@ -146,7 +145,7 @@ must_be_byte_chars(Chars, Context) :-
?- crypto_n_random_bytes(32, Bs),
bytes_integer(Bs, I).
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
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),
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:
?- crypto_data_hash("abc", Hs, [algorithm(sha256)]).
Hs = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
; false.
Hs = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad".
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@@ -166,19 +166,16 @@ file_time_(File, Which, T) :-
Examples:
?- path_segments("/hello/there", Segments).
Segments = [[],"hello","there"]
; false.
Segments = [[],"hello","there"].
?- path_segments(Path, ["hello","there"]).
Path = "hello/there"
; false.
Path = "hello/there".
To obtain the platform-specific directory separator, you can use:
?- path_segments(Separator, ["",""]).
Separator = "/"
; false.
Separator = "/".
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
path_segments(Path, Segments) :-

View File

@@ -64,8 +64,7 @@
Example:
?- phrase(format_("~s~n~`.t~w!~12|", ["hello",there]), Cs).
%@ Cs = "hello\n......there!"
%@ ; false.
%@ Cs = "hello\n......there!".
I place this code in the public domain. Use it in any way you want.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
@@ -158,7 +157,7 @@ element_gluevar(glue(_,V), N, N) --> [V].
consume whitespace in the sense of format strings.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
cells([], Args, Tab, Es, _) -->
cells([], Args, Tab, Es, _) --> !,
( { Args == [] } -> cell(Tab, Tab, Es)
; { domain_error(empty_list, Args, format_//2) }
).
@@ -404,32 +403,28 @@ Cs = [cell(0,4,[glue(' ',_A),chars("a"),glue(' ',_B)])]
?- phrase(format_("hello~n~tthere~6|", []), Ls).
?- format("~ta~t~4|", []).
a true
; false.
a true.
?- format("~ta~tb~tc~10|", []).
a b c true
; false.
a b c true.
?- format("~tabc~3|", []).
?- format("~ta~t~4|", []).
?- format("~ta~t~tb~tc~20|", []).
a b c true
; false.
a b c true.
?- format("~2f~n", [3]).
3.00
true
true.
?- format("~20f", [0.1]).
0.10000000000000000000 true % this should use higher accuracy!
; false.
0.10000000000000000000 true.
?- X is atan(2), format("~7f~n", [X]).
1.1071487
X = 1.1071487177940906
X = 1.1071487177940906.
?- format("~`at~50|~n", []).
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -438,10 +433,10 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
?- format("~t~N", []).
?- format("~q", [.]).
'.' true
'.' true.
?- format("~12r", [300]).
210 true
210 true.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -537,7 +532,7 @@ a :-
b,
c,
d.
true
true.
?- portray_clause([a,b,c,d]).

View File

@@ -17,8 +17,7 @@
Example:
?- http_open("https://github.com/mthom/scryer-prolog", S, []).
%@ S = '$stream'(0x7f86f94a6cd0)
%@ ; false.
%@ S = '$stream'(0x7fcfc9e00f00).
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

View File

@@ -7,8 +7,7 @@
Example:
?- getenv("LANG", Ls).
Ls = "en_US.UTF-8"
; false.
Ls = "en_US.UTF-8".
Public domain code.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

View File

@@ -34,8 +34,7 @@
Example:
?- current_time(T), phrase(format_time("%d.%m.%Y (%H:%M:%S)", T), Cs).
T = [...], Cs = "11.06.2020 (00:24:32)"
; false.
T = [...], Cs = "11.06.2020 (00:24:32)".
sleep(S) sleeps for S seconds (a floating point number).
@@ -107,15 +106,14 @@ report_time(T0) :-
false.
:- time(use_module(library(clpz))).
% CPU time: 2.762 seconds
true
; false.
% CPU time: 0.000 seconds
% CPU time: 0.001 seconds
true.
:- time(use_module(library(lists))).
% CPU time: 0.000 seconds
true
; % CPU time: 0.001 seconds
false.
% CPU time: 0.001 seconds
true.
?- time(member(X, [a,b,c])).
% CPU time: 0.000 seconds