Re: [PD] split number into digits

2021-01-19 Thread Lorenzo Sutton

On 17/01/21 22:07, Roman Haefeli wrote:

On Sun, 2021-01-17 at 13:29 -0500, José Rafael Subía Valdez wrote:

maybe with [mod]. Is the number always going to have 3 digits??

playing around in 3 minutes, I came up with this (see picture
attached). I do not consider it to be elegant, but maybe its a place
to start


attached patch works with any number of digits (following Claude's
suggestion).


And a variation on the theme (still seems to have problems with 'larger' 
numbers...) :-)


#N canvas 571 224 663 512 12;
#X obj 283 258 mod 10;
#X obj 115 264 div 10;
#X obj 115 317 t f f;
#X obj 55 148 t b f, f 6;
#X obj 168 364 != 0;
#X obj 115 228 t f f;
#X obj 283 363 list store;
#X obj 115 187 f;
#X obj 168 394 t f f;
#X obj 200 424 sel 0;
#X msg 283 317 prepend \$1;
#X floatatom 114 60 20 0 0 0 - - -;
#X obj 283 423 print digits;
#X obj 114 100 moses 0, f 19;
#X msg 221 317 bang;
#X msg 377 317 bang;
#X obj 114 148 t f b, f 38;
#X obj 115 424 spigot, f 8;
#X text 204 294 get list;
#X msg 164 18 123456;
#X msg 114 18 512;
#X text 275 52 >= 0 (negative is ignored);
#X text 275 70 works up to 7 digits;
#X connect 0 0 10 0;
#X connect 1 0 2 0;
#X connect 2 0 17 0;
#X connect 2 1 4 0;
#X connect 3 0 7 0;
#X connect 3 1 7 1;
#X connect 4 0 8 0;
#X connect 5 0 1 0;
#X connect 5 1 0 0;
#X connect 6 0 12 0;
#X connect 7 0 5 0;
#X connect 8 0 17 1;
#X connect 8 1 9 0;
#X connect 9 0 6 0;
#X connect 10 0 6 0;
#X connect 11 0 13 0;
#X connect 13 1 16 0;
#X connect 14 0 6 0;
#X connect 15 0 6 1;
#X connect 16 0 7 0;
#X connect 16 1 15 0;
#X connect 17 0 3 0;
#X connect 19 0 11 0;
#X connect 20 0 11 0;
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] split number into digits

2021-01-17 Thread Joseph Larralde

Hi list,

To elaborate on Claude's answer, here is how I would do it in vanilla :

#N canvas 355 282 450 300 12;
#X obj 214 124 % 10;
#X obj 96 126 / 10;
#X obj 182 91 t f f;
#X floatatom 182 32 5 0 0 0 - - -;
#X obj 96 148 i;
#X obj 96 172 sel 0;
#X obj 214 147 list append;
#X obj 214 170 t a a;
#X obj 182 54 t f b;
#X obj 96 214 list store;
#X obj 96 239 print;
#X connect 0 0 6 0;
#X connect 1 0 4 0;
#X connect 2 0 1 0;
#X connect 2 1 0 0;
#X connect 3 0 8 0;
#X connect 4 0 5 0;
#X connect 5 0 9 0;
#X connect 5 1 2 0;
#X connect 6 0 7 0;
#X connect 7 0 9 1;
#X connect 7 1 6 1;
#X connect 8 0 2 0;
#X connect 8 1 6 1;
#X connect 9 0 10 0;

The inconvenient is that your number cannot start with extra zeros, but 
I guess this is not an issue here.
Also, I have no idea how to perform this in other bases ... but it works 
just fine in base 10 for positive numbers.


Cheers,
Joseph

Le 17/01/2021 à 20:24, pd-list-requ...@lists.iem.at a écrit :

Hi Antoine,

On 17/01/2021 18:15, Antoine Rousseau wrote:

- transform "float 512" into "symbol 512" using [makefilename %d]

I would not recommend this, because symbols stick around forever and Pd
gets slower the more symbols there are.  AKA "symbol table pollution".

Instead, better to use [mod 10] to get the least significant digit, and
[div 10] to get the most significant digits (then repeat until you have
all the digits).  This approach also works for bases other than 10.


___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] split number into digits

2021-01-17 Thread Roman Haefeli
On Sun, 2021-01-17 at 13:29 -0500, José Rafael Subía Valdez wrote:
> maybe with [mod]. Is the number always going to have 3 digits??
> 
> playing around in 3 minutes, I came up with this (see picture
> attached). I do not consider it to be elegant, but maybe its a place
> to start

attached patch works with any number of digits (following Claude's
suggestion).




split-to-digits.pd
Description: application/wine-extension-pd


signature.asc
Description: This is a digitally signed message part
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] split number into digits

2021-01-17 Thread IOhannes m zmölnig

On 1/17/21 9:35 PM, Alexandre Torres Porres wrote:

But at what point does this become a real issue? And how come we don't have
a better way to convert it to symbols?



the problem is not with the "way to convert it to symbols", but with 
symbols itself.


it's the nature of symbols to not get lost. so the more symbols you 
create, the more they will clog your memory.

with modern memory sizes this is usually not a problem.
however, the way Pd stores and retrieves symbols is suboptimal, and 
degrades heavily with high numbers of symbols.


there's a PR (#1172) that attempts to alleviate the problem, but it 
hasn't been accepted into mainline Pd yet.


gfamdsr
IOhannes



OpenPGP_signature
Description: OpenPGP digital signature
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] split number into digits

2021-01-17 Thread Alexandre Torres Porres
Em dom., 17 de jan. de 2021 às 16:18, Claude Heiland-Allen <
cla...@mathr.co.uk> escreveu:

> Hi Antoine,
>
> On 17/01/2021 18:15, Antoine Rousseau wrote:
> > - transform "float 512" into "symbol 512" using [makefilename %d]
> I would not recommend this, because symbols stick around forever and Pd
> gets slower the more symbols there are.  AKA "symbol table pollution".


But at what point does this become a real issue? And how come we don't have
a better way to convert it to symbols?
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] split number into digits

2021-01-17 Thread José Rafael Subía Valdez
maybe with [mod]. Is the number always going to have 3 digits??

playing around in 3 minutes, I came up with this (see picture attached). I
do not consider it to be elegant, but maybe its a place to start

cheers

On Sun, Jan 17, 2021 at 1:18 PM Antoine Rousseau  wrote:

> You can do this:
> - transform "float 512" into "symbol 512" using [makefilename %d]
> - then transform "symbol 512" into "list 53 49 50" with [list fromsymbol].
> - finally subtract 48 (which is the ascii for "0") from every item, you
> get "5 1 2"
>
>
> Le dim. 17 janv. 2021 à 18:23, Jeppi Jeppi  a écrit :
>
>> Hi there,
>> which would be your most elegant way to split a number into a list of
>> digits? that is, I have the number 512 and I want the list 5 1 2
>> ___
>> Pd-list@lists.iem.at mailing list
>> UNSUBSCRIBE and account-management ->
>> https://lists.puredata.info/listinfo/pd-list
>>
> ___
> Pd-list@lists.iem.at mailing list
> UNSUBSCRIBE and account-management ->
> https://lists.puredata.info/listinfo/pd-list
>


-- 
José Rafael Subía Valdez
www.jrsv.net


*"...I am an Anarchist! Wherefore I will*
*Not rule, and also ruled I will not be!"*

- John Henry Mackay -
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] split number into digits

2021-01-17 Thread Claude Heiland-Allen

Hi Antoine,

On 17/01/2021 18:15, Antoine Rousseau wrote:

- transform "float 512" into "symbol 512" using [makefilename %d]
I would not recommend this, because symbols stick around forever and Pd 
gets slower the more symbols there are.  AKA "symbol table pollution".


Instead, better to use [mod 10] to get the least significant digit, and 
[div 10] to get the most significant digits (then repeat until you have 
all the digits).  This approach also works for bases other than 10.



Claude
--
https://mathr.co.uk




___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] split number into digits

2021-01-17 Thread Jeppi Jeppi
Wow brilliant, super elegant. many thanks!
josep m

From: Antoine Rousseau 
Sent: Sunday, January 17, 2021 7:15 PM
To: Jeppi Jeppi 
Cc: pd-list@lists.iem.at 
Subject: Re: [PD] split number into digits

You can do this:
- transform "float 512" into "symbol 512" using [makefilename %d]
- then transform "symbol 512" into "list 53 49 50" with [list fromsymbol].
- finally subtract 48 (which is the ascii for "0") from every item, you get "5 
1 2"


Le dim. 17 janv. 2021 à 18:23, Jeppi Jeppi 
mailto:jepp...@hotmail.com>> a écrit :
Hi there,
which would be your most elegant way to split a number into a list of digits? 
that is, I have the number 512 and I want the list 5 1 2
___
Pd-list@lists.iem.at<mailto:Pd-list@lists.iem.at> mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] split number into digits

2021-01-17 Thread Antoine Rousseau
You can do this:
- transform "float 512" into "symbol 512" using [makefilename %d]
- then transform "symbol 512" into "list 53 49 50" with [list fromsymbol].
- finally subtract 48 (which is the ascii for "0") from every item, you get
"5 1 2"


Le dim. 17 janv. 2021 à 18:23, Jeppi Jeppi  a écrit :

> Hi there,
> which would be your most elegant way to split a number into a list of
> digits? that is, I have the number 512 and I want the list 5 1 2
> ___
> Pd-list@lists.iem.at mailing list
> UNSUBSCRIBE and account-management ->
> https://lists.puredata.info/listinfo/pd-list
>
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


[PD] split number into digits

2021-01-17 Thread Jeppi Jeppi
Hi there,
which would be your most elegant way to split a number into a list of digits? 
that is, I have the number 512 and I want the list 5 1 2
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list