Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
36
Task/Substring/Picat/substring.picat
Normal file
36
Task/Substring/Picat/substring.picat
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
go =>
|
||||
S = "Picat is fun",
|
||||
N = 3,
|
||||
M = 4,
|
||||
C = 'i', % must be a char
|
||||
SS = "is",
|
||||
test(S,N,M,C,SS).
|
||||
|
||||
test(S,N,M,C,SS) =>
|
||||
println($test(S,N,M,C,SS)),
|
||||
|
||||
% - starting from n characters in and of m length;
|
||||
println(1=slice(S,N,N+M)),
|
||||
println(1=S[N..N+M]),
|
||||
|
||||
% - starting from n characters in, up to the end of the string;
|
||||
println(2=S.slice(N)),
|
||||
|
||||
% - whole string minus last character;
|
||||
println(3=but_last(S)),
|
||||
println(3=S[1..S.len-1]),
|
||||
|
||||
% - starting from a known character within the string and of m length;
|
||||
println(4=substring4(S,C)),
|
||||
|
||||
% - starting from a known substring within the string and of m length.
|
||||
println(5=substring5(S,SS,M)),
|
||||
nl.
|
||||
|
||||
but_last(S) = slice(S,1,S.length-1).
|
||||
|
||||
substring4(S,C) = slice(S,S.find_first_of(C)).
|
||||
|
||||
% find is non-deterministic, hence the once/1
|
||||
substring5(S,SS,M) = slice(S,Start,Start+M) =>
|
||||
once(find(S,SS,Start,_End)).
|
||||
Loading…
Add table
Add a link
Reference in a new issue