Ludii Forum
Quantifier - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Suggestions (https://ludii.games/forums/forumdisplay.php?fid=10)
+--- Forum: Ludii Features / Services (https://ludii.games/forums/forumdisplay.php?fid=11)
+--- Thread: Quantifier (/showthread.php?tid=239)



Quantifier - Michael - 11-06-2020

This is high up on my wishlist :) I would love a boolean like (forAll Sites in:<region> <boolean>) which returns true if the boolean holds of all the sites in the region and false if not. Would this be possible?


RE: Quantifier - Michael - 11-07-2020

I think I just realized that this ludeme, which I have wanted for so long, is easily defined:
Code:
(define "forAllSites"
    (=
        (count Sites
            in:#1
        )
        (count Sites
            in:(forEach
                #1
                if:#2
            )
        )
    )
)
I’m not able to test it currently, but it looks like it should work.

Edit: Equivalently:
Code:
(define "forAllSites"
    (=
        0
        (count Sites
            in:(forEach
                #1
                if:(not #2)
            )
        )
    )
)



RE: Quantifier - Eric Piette - 11-09-2020

Hi,

Yes exactly you can do exactly what you said.

However, we are also planning to add a ludeme doing exactly what you want in this format
(all Sites <region> <boolean>)

That will be probably in the next release.

Regards,
Eric