[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

> understanding: If you want to make a string longer by inserting

William James

9/2/2015 4:07:00 PM

Edi Weitz wrote:

> > understanding: If you want to make a string longer by inserting
> > stuff, this means you MUST cons up a new copy. This is a basic
> > understanding that holds for all computer languages. [...] Perl and
> > VB and the like will paper over this fact, but it still holds for
> > those languages aswell.
>
> Good point. In Perl, e.g., you can write stuff like this
>
> #!/usr/bin/perl -l
>
> $a = "abcdefghi";
> $b = "abcdefghi";
> $c = "abcdefghi";
> (substr $a, 3, 3) = "XXX";
> (substr $b, 2, 4) = "XXX";
> (substr $c, 4, 2) = "XXX";
> print $a;
> print $b;
> print $c;
>
> and expect a result that looks like so:
>
> edi@vmware:~$ perl /tmp/foo.pl
> abcXXXghi
> abXXXghi
> abcdXXXghi

MatzLisp (Ruby):

a = "foo 234 bar who"
a[ /\d+/ ] = "NUMBER_CONCEALED"
a
===>
"foo NUMBER_CONCEALED bar who"

--
For two years ... he was held in solitary confinement in the Toronto West
Detention Centre, on the pretext that he is a threat to national security....
[A] court in Mannheim sentenced him to five years imprisonment for the crime of
"popular incitement" under Germany's notorious "Holocaust denial" statute.
http://www.revisionists.com/revisionists/z...