[PD-dev] proposed new "list" object
Mathieu Bouchard
matju at artengine.ca
Thu Jul 21 05:56:20 CEST 2005
On Thu, 21 Jul 2005, Frank Barknecht wrote:
> I think I'd prefer "split" over "first" and "last" (but maybe the Lisp
> people would even prefer something else... ;)
In Perl, Python, Ruby, etc., split is a string operation that
generates a list of strings according to where a certain pattern was
found. E.g. if the pattern is /\s*-\s*/ which means "a dash surrounded by
any number of spaces, maybe none", then
"-hello- blah blah - foo bar -" .split /\s*-\s*/
gives
["", "hello", "blah blah", "foo bar"]
a list of four elements (trailing delimiters are ignored).
The above sample code is in Ruby:
"" are string delimiters
// are pattern delimiters
. means send message
split is a method selector
[] are list delimiters
, are list element delimiters.
The Tcl language has a similar proc split but works like C's strtok()
instead of using regexp patterns.
A list-oriented split probably should do something similar and thus it
would need to output any number of lists (possibly bundled in a list
themselves).
The "split" that Frank suggests, afaik, doesn't exist in the above
languages; the closest is the "splice" of Perl and the "slice!" of Ruby
(and I don't know enough Python or Tcl)
,-o--------o--------o--------o-. ,---. irc.freenode.net #dataflow |
| The Diagram is the Program tm| | ,-o-------------o--------------o-.
`-o------------o-------------o-' | | Mathieu Bouchard (Montréal QC) |
| téléphone:+1.514.383.3801`---' `-o-- http://artengine.ca/matju -'
More information about the Pd-dev
mailing list