String Manipulation Routines 
Author Message
 String Manipulation Routines

--============_-1268835467==_============
Content-Type: text/plain; charset="us-ascii" ; format="flowed"

Hi,

One of the areas of Poplog that I have often felt was a bit lightweight
is the string manipulation routines.  I have forever found myself
writing ugly bits of code like this ...
     substring( a, b - a + 1, s )
which just means I want the substring from indexes a to b inclusive, and
things like this
     allbutfirst( 2, allbutlast( 2, s ) )
meaning that I want to strip two from the front and back.  This gets
ugly when the subexpressions get complex.

By contrast, python has got a very elegant string splicing construct
that looks like
     s[ a:b ]
And this gives the same effect as
     substring( a, b - a + 1, s )
except that it works on general arrays.

One feature that seems odd at first - but works well in practice - is the
use of negative indices for addressing from the end of an array.  So
in Python you would write my second fragment as :-
     s[ 2: -3 ]
[The lack of symmetry is due to the use of 0-indexing, incidentally.]

The final straw was reading the REALbasic manual and finding it too has
got the routines I want.  REALbasic is a competitor to Visual Basic,
started on the Mac and is now going cross-platform to Windows.  It
is immature but is evidently taking over from where HyperCard left off.

I could not suffer this language envy any more :-)  So I've written a few
routines, -cut- -allbutcut- and -splice- that give me the power I want.
They work on lists, vectors, strings, words, and general vectorclass
objects.  They are general and efficient - but could do with more
testing.  However, before I waste my time testing them, I am submitting
them as an attached uuencoded, gzipped, tar archive for general comment.

The running examples above can be written using -cut- as
     cut( a, b, s )
and
     cut( 3, -3, s )
respectively.  [Note that a symmetrical cut has symmetrical arguments,
thanks to the 1-indexing of Poplog.  Interpreting -ve indices was a bit
tricky but there is a best answer and I have used it.]

I probably should be posting this to Poplog developers but I thought
it was worth getting some discussion started on the areas Poplog
needs beefing up in.  Now Poplog is Open Source we ought to start
thinking collectively about where it needs to go.

I think systems like REALbasic are well worth checking out to get
inspiration.  And reading the REALbasic manual made me recall Aaron
Sloman talking about the time Poplog was being named and one suggestion
was SuperBasic.  For me, that name encapsulates one of the really
valuable ideas behind Poplog - it is a very friendly, interactive
and super-powered IDE.

So what other languages have features that you really miss in Poplog?
Let's get them into the standard distribution!  (I mean, dates?  Where
is the date type in Poplog?  Doesn't anyone do database programming
apart from me?)

Steve

P.S. As an aside for HP Labs people, the -cut- routines supercedes the
-cutstring- routine.
--============_-1268835467==_============

Content-Type: application/mac-binhex40; name="string_ops.uu"
Content-Disposition: attachment; filename="string_ops.uu"
 ; modification-date="Mon, 22 Nov 1999 15:36:56 +0000"

(This file must be converted with BinHex 4.0)

<encoded_portion_removed>

--============_-1268835467==_============--



Fri, 10 May 2002 03:00:00 GMT  
 String Manipulation Routines

Quote:
> I probably should be posting this to Poplog developers but I thought
> it was worth getting some discussion started on the areas Poplog
> needs beefing up in.  Now Poplog is Open Source we ought to start
> thinking collectively about where it needs to go.

I'm glad you said that :)

I've just started on Pop-11 (as you can tell from my address, I'm an
undergrad), and found that a lot of people found it difficult to install
and start using Poplog.  To that end, I've been looking at ways to make it
less painful to install and get started with it on a Linux system.

Eventually, I'd like to get it all fitted into an 'RPM' ('Redhat
Package Manager') file.  The RPM program is designed to automate
installation and uninstallation of programs, as the name suggests.

As a first step down that road, I'm trying to cut out the need to define
all of the environment variables pop11 needs by hand, as people
used to Windows are intimidated by the prospect, and would
probably be confused to see swathes of variables if they were
(for example) following one of the many HOW-TO documents and
were (for example) told to look for DISPLAY.  Included is a modified
version of Aaron Sloman's 'poplog' script that only requires
$poplocal to be pre-defined.

I'm planning to do a few other things with this, and I'd just like some
feedback on how worthwhile you all expect this would be to newbies (I
expect that old hands will see no gain in swapping to a new way of doing
things).

1) Once I work out how to use sed, I'll write a one-liner that examines
the name the script was called as, and call the equivalent program in
$poplocal/pop/pop/.  That way I can, for example, have a symlink
'/usr/bin/ved -> /bin/poplog', which then run '$poplocal/pop/pop/ved'.
That way, we don't need to extend the path variable.
2) I'll define $poplocal in /etc/profile.d/poplog.sh.  Under Linux,
/etc/profile.d/*.sh are executed on log-in.  If any other operating
systems use similar principles, and want to do something like this, it'd
be a simple move.
3) I'll look into how KDE and GNOME handle menus, and hopefully add some
automatically.  I choose those two because most newbies are likely to use
one or other of them.  If anyone has any other options, I'd be glad to
hear them, but since I'll have a hard enough job getting hold of a KDE
workstation, you'd need to do it yourself :)

Anyway, any thoughts on those, or any further suggestions would be gladly
appreciated.

        - Andrew



Sat, 11 May 2002 03:00:00 GMT  
 String Manipulation Routines
<snip>

Quote:
> Eventually, I'd like to get it all fitted into an 'RPM' ('Redhat
> Package Manager') file.  The RPM program is designed to automate
> installation and uninstallation of programs, as the name suggests.
<snip>
> Anyway, any thoughts on those, or any further suggestions would be gladly
> appreciated.

I'd like to volunteer to be a guinea pig for the Linux RPM. I keep
meaning to get the POP sources and compile 'em up and install them
myself, but I keep never having the time.

BTW: I went to Plymouth Polytechnic (oops, showing my age), umm, I mean
that I attended the University of Plymouth! (No-one on the U.S. side of
the pond knows what a polytechnic is! :-)

Blessings,

Simon

-----------------------------------------------------------------

Web Developer / Programming Specialist           www.landsend.com
Lands' End, Inc.                                   (608) 935-4526

"He who thinks he's a leader and has no-one following him is just
 out taking a walk!"            - Dr. John C. Maxwell, Injoy Inc.



Sat, 11 May 2002 03:00:00 GMT  
 String Manipulation Routines

Quote:
> I'd like to volunteer to be a guinea pig for the Linux RPM. I keep
> meaning to get the POP sources and compile 'em up and install them
> myself, but I keep never having the time.

Thanks, that'll be very useful.  Anyone else want to help?

        - Andrew



Sun, 12 May 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. string manipulation routines for fortran?

2. string manipulation routines

3. Bit Manipulation Routines

4. Some x86 bit-manipulation instructions/routines wanted

5. Diana and/or ASIS manipulation routines

6. Matrix manipulation routines - HELP!

7. Date Manipulation Routines

8. Character manipulation routines...

9. seeking simple bit manipulation routines for f77

10. string manipulations

11. Question: String manipulation

12. String manipulation

 

 
Powered by phpBB® Forum Software