JoeStrout / miniscript

source code of both C# and C++ implementations of the MiniScript scripting language
MIT License
275 stars 64 forks source link

1<2>1 == 1 ? #166

Closed badiku closed 1 month ago

badiku commented 1 month ago
> 1<2>1
1
> 2>1
1
> 1<2
1
> 1<(2>1)
0
> (1<2)>1
0

feature?

Withered-Flower-0422 commented 1 month ago

Miniscript allows continuous judgment. (Like python)

For 1 < 2 > 1, it's same as 1 < 2 and 2 > 1.

badiku commented 1 month ago

nice feature.

https://softwareengineering.stackexchange.com/questions/316969/why-do-most-mainstream-languages-not-support-x-y-z-syntax-for-3-way-boolea

badiku commented 1 month ago

how about this code:

> 1<2>1<2>1<2>1
1
> 1<2>1
1
> 2>1<2
1
> (1<2>1)<(2>1<2)>1
0
Withered-Flower-0422 commented 1 month ago

Same.

1 < 2 > 1 < 2 > 1 < 2 > 1 will be 1 < 2 and 2 > 1 and 1 < 2 and 2 > 1 and 1 < 2 and 2 > 1, which is true (as known as 1). As for (1 < 2 > 1) < (2 > 1 < 2) > 1, 1 < 2 > 1 is 1, 2 > 1 < 2 is 1, so it's the same as 1 < 1 > 1, which is flase (as known as 0)

badiku commented 1 month ago
> (a<b<c)<d
1
> a<(b<c<d)
0
> (a<b)<(c<d)
0
> a<b<c<d
1
>

can I use a<b<c<d to ensure that a<b and b<c and c<d ?

Withered-Flower-0422 commented 1 month ago

of course

JoeStrout commented 1 month ago

All working as intended and documented.

JoeStrout commented 1 month ago

...and @badiku, please do not use GitHub Issues to discuss things you don't understand about MiniScript. Join the MiniScript Discord server and discuss there, or send email to the support address. Help us keep GitHub issues clean. Thank you!