Hi folks. Newbie question here.
I was wondering if there's a regular way of extracting the head and the tail (meaning everything but the first element... think car/cdr) of an arbitrary list message. I'm rooting through the docs, and am not able to come up with an elegant way of doing this. (looked through the past two months of archives, and didn't find much)
I'm running on Mac OS X (yay!), so I'm not terribly excited about externals that provide a way to do this, but abstractions would be useful.
Why do I want to do this? I'm trying to write an abstraction that takes in a netreceive and dispatches it to a receiver that's labelled with the first name in the list, e.g. a netsend of:
foo bar baz;
...results in a message of "bar baz" being sent to [r foo].
I have a hack with a set number of arguments making heavy use of [trigger], variable substitution, and "add2" and "set" message boxes, but I can't get it to work with arbitrary-length messages.
Thanks in advance, adam
Hi, Adam T. Lindsay hat gesagt: // Adam T. Lindsay wrote:
I was wondering if there's a regular way of extracting the head and the tail (meaning everything but the first element... think car/cdr) of an arbitrary list message. I'm rooting through the docs, and am not able to come up with an elegant way of doing this. (looked through the past two months of archives, and didn't find much)
I think, the "cdr" part doesn't exist, but I would be very happy if I'm going to be proved wrong. Maybe ZEXY has some things inside to handle "cdr" cases, but I'm not that familiar with ZEXY.
Why do I want to do this? I'm trying to write an abstraction that takes in a netreceive and dispatches it to a receiver that's labelled with the first name in the list, e.g. a netsend of:
foo bar baz;
...results in a message of "bar baz" being sent to [r foo].
You might want to explore ";"-messages, like the well known [; pd dsp 1(
They work like named sends. If you have a colon message like:
[; $1 $2(
and you send it a list with, say, "volume 17" a receiver [r volume] will get the value "17".
I have a hack with a set number of arguments making heavy use of [trigger], variable substitution, and "add2" and "set" message boxes, but I can't get it to work with arbitrary-length messages.
Wll, with arbitrary lenght messages, the ";" trick will fail. You might get a bit farther with [textfile]
Frank Barknecht _ ______footils.org__
inside my external i have t_float secondfloat; t_float firstfloat;
because they're inlets. i need to convert those to int, basically i need to truncate the decimal part. how do i do that? thanks,
scott
"640K ought to be enough for anybody." -- Bill Gates, 1981
Subject: [PD] converting float to int
Date: gio, ago 15, 2002 at 12:45:17 -0700
Quoting J. Scott Hildebrand (jshildebrand@ucdavis.edu):
inside my external i have t_float secondfloat; t_float firstfloat;
because they're inlets. i need to convert those to int, basically i need to truncate the decimal part. how do i do that? thanks,
Maybe I did not get your question right. This is very elementary C.
If you want to just truncate the decimal part of a floating point variable you just cast it to int:
int firstint=(int)firstfloat; int secondint=(int)secondfloat;
If you want to have the nearest integer, this is what you need
int firstint=(int)(firstfloat+0.5); int secondint=(int)(secondfloat+0.5);
In the hope of being useful...
Carlo
On Thu, 15 Aug 2002, Carlo E. Prelz wrote:
Maybe I did not get your question right. This is very elementary C. If you want to just truncate the decimal part of a floating point variable you just cast it to int: int firstint=(int)firstfloat; int secondint=(int)secondfloat;
If you want to have the nearest integer, this is what you need int firstint=(int)(firstfloat+0.5); int secondint=(int)(secondfloat+0.5);
This does not round to the nearest, because for the +0.5 trick to work, the rounding that occurs after must be downwards, like floor(), instead of towards zero, like a (int) cast.
(This is very elementary C too ;-)
Mathieu Bouchard http://artengine.ca/matju
On Thu, 15 Aug 2002, Frank Barknecht wrote:
I think, the "cdr" part doesn't exist, but I would be very happy if I'm going to be proved wrong. Maybe ZEXY has some things inside to handle "cdr" cases, but I'm not that familiar with ZEXY.
Larry Troxler's pd-scheme?
www.ariada.uea.ac.uk/~dcasal --)+
Hi Adam, hi list,
On 15 August 2002 at 17:36:08, Adam T. Lindsay wrote:
Why do I want to do this? I'm trying to write an abstraction that takes in a netreceive and dispatches it to a receiver that's labelled with the first name in the list, e.g. a netsend of:
foo bar baz;
...results in a message of "bar baz" being sent to [r foo].
... sorry I didn't see this earlier; I've been somewhat preoccupied by my graphics card goofing off... at any rate, this sounds like exactly what my 'forward' external does... I've only ever tested it under linux, but I'd be happy to help diagnose compiler errors, etc.... it's available at:
http://www.ling.uni-potsdam.de/~moocow/projects/pd
I've successfully used it with both [textfile] and [netreceive].
marmosets, Bryan
Bryan, all,
I tried your forward external, and it seems to be just what I was looking for. The makefile wasn't very helpful for MacOSX, to be honest, but the externals packaged with PD gave enough of a guide to get a working forward.pd_darwin to be usable. [should I send you a copy?]
And it works. The way it types messages was unexpected, but it seems to work better with the pd datatype model than my attempts. The only non- feature that surprised me was that a message list of "pd dsp 1" doesn't work... but *that* has taught me a bit about the model, which in turn makes it less surprising.
But so the answer to my original question seems to be: no, there are no car/cdr message/list manipulations native to PD.
Thanks, adam
Bryan Jurish said this at Sat, 17 Aug 2002 19:27:13 +0200:
On 15 August 2002 at 17:36:08, Adam T. Lindsay wrote:
list, e.g. a netsend of:
foo bar baz;
...results in a message of "bar baz" being sent to [r foo].
... sorry I didn't see this earlier; I've been somewhat preoccupied by my graphics card goofing off... at any rate, this sounds like exactly what my 'forward' external does... I've only ever tested it under linux, but I'd be happy to help diagnose compiler errors, etc.... it's available at:
http://www.ling.uni-potsdam.de/~moocow/projects/pd
I've successfully used it with both [textfile] and [netreceive].