Hi guys, I’m trying to set a column in order to get an array (like a vector) of entire unique numbers… something like this (12, 22, 34,49,52,60)
After a quick investigation, I saw the Hyperformula option where we could set excel formulas in glide…
I tried to set the RANDARRAY formula but it seems it´s not supported by Hyperformula yet
I wonder if any of you guys have done this before or if you have any ideas for it.
Yes, it´s a fixed array like the example (2,4,8,14,17,34) and they shouldn’t get repeated.
I think if I use the dice roll then the number could get repeated like (2,2,4,8,5,9) and that is a problem for me.
And if I’m myself clear and transparent I haven’t used or studied how the JavaScrip works
I don´t know if you could help me with an example of this JS snippet code you mentioned… mean while I’m going to investigate by my side about it too.
var arr = [];
while (arr.length < 6) {
var r = Math.floor(Math.random() * 100) + 1;
if (arr.indexOf(r) === -1) {
arr.push(r);
}
}
return arr.join(',');
One thing to note is that you can’t pass or return arrays to/from the JavaScript column. So it has to be returned as a string. But that can be coerced into an array by using a Split Text column if that’s what you actually need.
yeah, that’s an issue that’s been around for a while.
When you create an array of numbers using Split Text, you actually get an array of strings that look like numbers. So if you then subsequently try to sort the array using the Sort Array plugin, it does a lexical sort rather than a numerical sort.
Oh, looks like JS is also doing a lexical sort. Will need a custom sorting function. I’m away from my keyboard for a short while. Will come back with a solution when I get back.