Zhcode: Python in Chinese
github.com
Zhcode: Python in Chinese
1–6 of 6 posts
Re: Zhcode: Python in Chinese
#2Re: Zhcode: Python in Chinese
#3Why the「」? Are spaces not good enough to separate words?
Re: Zhcode: Python in Chinese
#4Do you have some examples? Is this Fibonacci? https://github.com/Injng/zhcode/blob/main/zhcode/test.txt Why the「」? Are spaces not good enough to separate words?
The 「」was a design choice that I made so that I can more easily code the translator to differentiate between variables and other names (e.g. functions), with the side benefit of making the code slightly more readable. Spaces I bet can certainly achieve the same level of readability, but would require more complex code. I'll think about implementing that, however.
Re: Zhcode: Python in Chinese
#5Do you have some examples? Is this Fibonacci? https://github.com/Injng/zhcode/blob/main/zhcode/test.txt Why the「」? Are spaces not good enough to separate words?
Yes, that is Fibonacci. The program finds the sum of all the even Fibonacci numbers less than 4 million. As for more examples, I will certainly add in the future. The 「」was a design choice that I made so that I can more easily code the translator to differentiate between variables and other names (e.g. functions), with the side benefit of making the code slightly more readable. Spaces I bet can certainly achieve the…
def something(N, x):
f, g, h = method_1(N)
#f, g, h = method_2(N)
#f, g, h = method_3(N)
return f(x) + g(x) + h(x)
that use variables as functions.Re: Zhcode: Python in Chinese
#6Earlier quoted context omitted.
Yes, that is Fibonacci. The program finds the sum of all the even Fibonacci numbers less than 4 million. As for more examples, I will certainly add in the future. The 「」was a design choice that I made so that I can more easily code the translator to differentiate between variables and other names (e.g. functions), with the side benefit of making the code slightly more readable. Spaces I bet can certainly achieve the…
It's strange that you need to separate functions and other variables. I mostly use Racket, but I'm using Python from time to time. I'm using some code like def something(N, x): f, g, h = method_1(N) #f, g, h = method_2(N) #f, g, h = method_3(N) return f(x) + g(x) + h(x) that use variables as functions.
印(“你好”)
This would be translated to: print("你好")
However, variables are not translated. If I denote 印 as a variable: 「印」(“你好”)
This would get translated to: 印("你好")