Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to express these logic? #2

Closed
calpa opened this issue Dec 17, 2019 · 5 comments
Closed

How to express these logic? #2

calpa opened this issue Dec 17, 2019 · 5 comments
Labels
stdlib Issues related to standard library

Comments

@calpa
Copy link

calpa commented Dec 17, 2019

  1. a || !b

  2. !a || b

  3. !a && b

  4. a && !b

  5. a << 2

  6. a >> 2

  7. a >> n

  8. a << n

  9. this.

  10. constructor

  11. require()

  12. import

  13. a ** 2

  14. Math.sqrt()

  15. console.table()

@LingDong-
Copy link
Member

LingDong- commented Dec 17, 2019

Hi there,

Good question! You can express logical not with , and logical and/or with 中有陽乎 and 中無陰乎, like so:

吾有二爻。名之曰「甲」。曰「乙」。
變「甲」。名之曰「丙」。夫「乙」「丙」中有陽乎。書之。
變「甲」。名之曰「丙」。夫「乙」「丙」中無陰乎。書之。

Currently you need to simulate bit shifts with multiplication. I don’t intend to add bitwise operations into the syntax itself (as I don’t think they fit with the philosophy), but likely as methods of an importable module.

Which brings us to the question of require. I’m currently thinking of implementing imports with the following syntax:

欲解此中意。必先讀「位元運算」篇。

But I haven’t finalized on the details yet. Similar with the math functions you mentioned. Perhaps in the near future!

P.S. A somewhat hacky alternative at this time would be to use the js identifiers directly, but is of course, hacky :-P

吾有一術。名之曰「平方根」。昔之「平方根」者。今「Math.sqrt」是矣。施「平方根」於四。書之。

Thanks.

@qex
Copy link

qex commented Dec 17, 2019

吾有一術。名之曰「平方根」。昔之「平方根」者。今「Math.sqrt」是矣。施「平方根」於四。書之。

这句话看起来真是充满了玄幻的味道 ...

以及说关于 慾解此中意 此句应为 欲解此中意 ... 「慾」字仅限名词使用如「食慾」「性慾」等 ...

动词用法必须用「欲」 ... 如「欲罷不能」「欲蓋彌彰」等 ... 正体中文不可乱用呀 ...

@LingDong-
Copy link
Member

Good call @qex ! I'm going to blame it on the input method :-P
Just edited my comment.

@LingDong- LingDong- added the stdlib Issues related to standard library label Dec 24, 2019
@RedstoneDave
Copy link

I was thinking about this:
a>>1//倍「甲」
a<<1//半「甲」而棄其餘
a>>2//倍「甲」二番
a<<2//半「甲」而棄其餘者二番也

@antfu
Copy link
Member

antfu commented Feb 2, 2020

We are now having stdlibs for Bit Manipulation and Math, check out here: https://github.com/wenyan-lang/wenyan/wiki/Standard-Library-Cheatsheet

For module importing: https://github.com/wenyan-lang/wenyan/wiki/Importing

Class support is still in the plan, please continue in #31

Thanks.

@antfu antfu closed this as completed Feb 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Issues related to standard library
Projects
None yet
Development

No branches or pull requests

5 participants