March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
14
Task/Binary-strings/PARI-GP/binary-strings.pari
Normal file
14
Task/Binary-strings/PARI-GP/binary-strings.pari
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
cmp_str(u,v)=u==v
|
||||
copy_str(v)=v \\ Creates a copy, not a pointer
|
||||
append_str(v,n)=concat(v,n)
|
||||
replace_str(source, n, replacement)=my(v=[]);for(i=1,#source,v=concat(v,if(source[i]==n,replacement,source[i]))); v
|
||||
|
||||
u=[72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100];
|
||||
v=[];
|
||||
cmp_str(u,v)
|
||||
w=copy_str(v)
|
||||
#w==0
|
||||
append_str(u,33)
|
||||
u[8..12]
|
||||
replace_str(u,108,[121])
|
||||
concat(v,w)
|
||||
Loading…
Add table
Add a link
Reference in a new issue