Re: [m-users.] lists and sets, unordered or ordered.

Volker Wysk <[email protected]>
Newsgroups gmane.comp.lang.mercury.general
Message-ID <[email protected]>
Am Dienstag, dem 03.10.2023 um 22:07 +0100 schrieb Sean Charles
(emacstheviking):
> In my detection, the same missile might hit more than one object if they
> are close: thus I only wanted to process it once even of it hits five
> things, so I wanted deduped list just to save setting the hit flag five
> times if that makes sense.
> 
> I checked out all the others sets, the only one I saw that looked good was
> set_unordlist but is says 'may contain duplicates'.
> 
> How do I get an unsorted deduped list from a set then, educate me, i sure
> as hell need it!

With the the set_c234.to_sorted_list/1 function, for instance. I still don't
know why your set needs to be unsorted.

V.

> 
> HAHA It's possible I have missed it in the melee, like 'cirle' not 'circle' las week, it's late, I'm tired
> :D
> 
> > On 3 Oct 2023, at 22:04, Volker Wysk <[email protected]> wrote:
> > 
> > Hi
> > 
> > You can get a sorted de-duped list from a set. Why do you need an unsorted
> > one? If it's efficiency, you need to have it sorted, unless you have only a
> > few elements.
> > 
> > But be aware that there is the "set" module and five "set_*" modules. The
> > "set" is using ordered lists. That's inefficient for large sets. Use the
> > other modules when you have a big set.
> > 
> > Cheers,
> > Volker
> > 
> > Am Dienstag, dem 03.10.2023 um 21:55 +0100 schrieb Sean Charles
> > (emacstheviking):
> > > Indeed. nothing in my drafts folder and I swear it was complete before I hit send... well,
> > > basically,
> > > is there a reason you can't get an unsorted de-duped list from a set?
> > > 
> > > That's all...   :D
> > > 
> > > > On 3 Oct 2023, at 21:53, Volker Wysk <[email protected]> wrote:
> > > > 
> > > > Hi, Sean
> > > > 
> > > > Your message suddenly stops in the middle of a sentence.
> > > > 
> > > > Volker
> > > > 
> > > > Am Dienstag, dem 03.10.2023 um 21:39 +0100 schrieb Sean Charles
> > > > (emacstheviking):
> > > > > I've just completed a generic typeclass based collision detection system and learned quite a bit doing it!
> > > > > 
> > > > > As I was reading the module docs, it seems that there is no 'unordered set without duplicates' unless I missed it, which is entirely reasonable.
> > > > > 
> > > > > The output from the collision detection  is two sets of integers, these are the identifiers of the missiles and the things that were hit at the moment. I now want to take this list and then set the '^hit' flag for every missile in that list, for example, the existing code will then no longer render it and remove it on the next iteration.
> > > > > 
> > > > > I used sets because they de-dupe as you go, meaning that my checking process is simply iterating two loops, m x n, m missiles and n moving targets, for now it is naive and will probably always be fine given the limited numbers of things on screen at any one time.
> > > > > 
> > > > > There seems to be no way to get an unordered, deduplicated list from a set, I can use set_unordlist but that leaves duplicates.
> > > > > 
> > > > > 
> > > > > For now I've decided to use set_unordlist, at the cost of maybe updating the same missile record more than once poost-collision detection, it's not going to kill anything really but mentally, and from a purity point of view it feels 'less optimal' than I wanted. Failing that I might just usr  list.member and use lists for everything like I did!
> > > > > 
> > > > > I just wondered what the reasons were for not having the ability to get an unsorted 
> > > > > _______________________________________________
> > > > > users mailing list
> > > > > [email protected]
> > > > > https://lists.mercurylang.org/listinfo/users
> > > > 
> > > > _______________________________________________
> > > > users mailing list
> > > > [email protected]
> > > > https://lists.mercurylang.org/listinfo/users
> > > 
> > 
> > _______________________________________________
> > users mailing list
> > [email protected]
> > https://lists.mercurylang.org/listinfo/users
>

_______________________________________________
users mailing list
[email protected]
https://lists.mercurylang.org/listinfo/users
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEE6QXGh82Ov3+2nrxp+K4ydFOsHoUFAmUchAQACgkQ+K4ydFOs
HoXyPg/+Is7JIA5cgrsjh9CmI3W2NiESXePXGP14ENmaODU2yLBOjni4RmiCphd6
9Ly5zpIHNotkFWnhDpc3nvDKBBWnbkOQyaIE4W4ElJ83V3jJv43yAFQhkXp3jg9Y
BkiIjrjAjixTi/pZKQkhmC0DCwegE4T5gdCxvaD06d2/DLBc4E3fOoNG/1h22cK+
anLps1eucHAcft9rdRxnkm5t+B1Ed9gK9jZNvUhSzcFAIqL2f3XyqGr098Nj6Y9n
qMDA4UuWzPM4hNHTnd13rAi87Aw32YQvMIn7JtHSd/z3OkHyvklLl6KMTXwrAFm2
5JlCqM/5j4z6Jewc9/ytGPVlEwY6p7vHybNvMclf9D0BFAY+vlIRFRVVbTkVQ9J7
aw4sD7ZC+BzVj0qIdukAwBqBMlmoCo8kgMmah6G3HoPABTjrm5agYUU+WaNgGS93
TQ5VA2oGi8yPK3MggCSSoEUZ9FYlnnjkzlDdNsIpja+W10U9tFeIyA0V+1ebvsF8
y4hLx2j3Co+ONF8rT/5UeuXNMdPBxyRpfc9kjQvxxL73+6ApcIfPS4guh0zYjO6+
k8Wcl0dAEn21X8q+1WAz2rt0quyrVucxuV/oM6HKBUaAFJ4hVCAodKV9O48dIwcg
Q5XSquXe5J5bs1pX8erEZp7Se4oxzwA9HumTUN795b6mdvqiqIs=
=XX5j
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.