[t=Thing.consumableList] already makes it so [t] takes from the Thing list, which only has one item. So anytime you place t between brackets, it tries to do it again, but it already consumed that one item, so it fails.
It takes from both lists, twice, and gives you the result, without elements from either list being repeated. I think there ought to be a better way to do it, but it gets the job done :)
Unfortunately, it’s not quite what I wanted. I’m wanting the effect of a consumable list where the elements are all the combinations of Adjective+Noun. I think I’ll have to figure out how to iterate through each of Adjective and Noun and construct a new list with all the combinations and stash that. I’ve not written an function like Thing() before, so I’ll have to think about that.
Oooh, alright, it’d be a different approach then. I’m more fluent in pure Javascript than Perchance syntax, so I may miss a thing or two here and there :B
Anyway, I think this would be the pattern you want:
AdjectiveNoun()=>
let combo=[];
for(const a of Adjective.selectAll) {
for(const n of Noun.selectAll) {
combo.push([a,n].join(' '));
};
};
return combo;
Which translates to “for each adjective, give me that adjective plus each noun”. That’s the generic way to get all variations. It’s quite possible that there is simpler way to do it in Perchance that I’m not aware of though.
That aside, the join-lists-plugin works for turning an array into a list, far as I tested:
OK, now the entire generator (in case having each piece separately is too confusing)
joinLists = {import:join-lists-plugin}
title
tee--temp
output
[t=Thing] [t]
Thing=[joinLists(AdjectiveNoun()).consumableList]
AdjectiveNoun()=>
let combo=[];
for(const a of Adjective.selectAll) {
for(const n of Noun.selectAll) {
combo.push([a,n].join(' '));
};
};
return combo;
Adjective
furry
spiky
green
loud
Noun
rat
bug
cat
tree
That’s looking very promising! I can’t try it right now, but I think it’ll do, once I parameterize the function to allow passing in the two lists to be combined.
Since I’m wanting to be able to use this multiple times, for various lists, I end up with:
AdjectiveNoun(Adj, Noun)=>
let combo=[];
for(const a of Adj.selectAll) {
for(const n of Noun.selectAll) {
combo.push([a,n].join(' '));
};
};
return [joinlists(combo).consumableList];
[t=Thing.consumableList]already makes it so[t]takes from theThinglist, which only has one item. So anytime you placetbetween brackets, it tries to do it again, but it already consumed that one item, so it fails.So I tried this:
It takes from both lists, twice, and gives you the result, without elements from either list being repeated. I think there ought to be a better way to do it, but it gets the job done :)
Thanks @Almaumbria.
Unfortunately, it’s not quite what I wanted. I’m wanting the effect of a consumable list where the elements are all the combinations of Adjective+Noun. I think I’ll have to figure out how to iterate through each of Adjective and Noun and construct a new list with all the combinations and stash that. I’ve not written an function like Thing() before, so I’ll have to think about that.
Oooh, alright, it’d be a different approach then. I’m more fluent in pure Javascript than Perchance syntax, so I may miss a thing or two here and there :B
Anyway, I think this would be the pattern you want:
Which translates to “for each adjective, give me that adjective plus each noun”. That’s the generic way to get all variations. It’s quite possible that there is simpler way to do it in Perchance that I’m not aware of though.
That aside, the
join-lists-pluginworks for turning an array into a list, far as I tested:output [t=Thing] [t] Thing=[joinLists(AdjectiveNoun()).consumableList]OK, now the entire generator (in case having each piece separately is too confusing)
joinLists = {import:join-lists-plugin} title tee--temp output [t=Thing] [t] Thing=[joinLists(AdjectiveNoun()).consumableList] AdjectiveNoun()=> let combo=[]; for(const a of Adjective.selectAll) { for(const n of Noun.selectAll) { combo.push([a,n].join(' ')); }; }; return combo; Adjective furry spiky green loud Noun rat bug cat treeHope I’m not getting it wrong again haha :DD
Alright, happy coding!
That’s looking very promising! I can’t try it right now, but I think it’ll do, once I parameterize the function to allow passing in the two lists to be combined.
Thanks muchly!
Yes. That works great! Thanks again!
Since I’m wanting to be able to use this multiple times, for various lists, I end up with:
AdjectiveNoun(Adj, Noun)=> let combo=[]; for(const a of Adj.selectAll) { for(const n of Noun.selectAll) { combo.push([a,n].join(' ')); }; }; return [joinlists(combo).consumableList];