Skip to content
New issue

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

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

Already on GitHub? # to your account

Add quine example (self-replicating code) #123

Merged
merged 1 commit into from
Dec 18, 2019

Conversation

woodrush
Copy link
Contributor

A quine is a program that outputs its own source code. When you input ./examples/quine.wy in the interpreter, it prints exactly the same string as its original source code.

This commit adds a quine program that I've written in wenyan-lang.

The original idea of the implementation, that quines in JavaScript can be implemented via replacement of strings, is referenced from a code in this post by @amo12937 . I've mentioned the URL of this post inside the source code.

@woodrush
Copy link
Contributor Author

One large room of improvement that can be made on this code is that it explicitly states String.fromCharCode inside the source code. This problem can be fixed straightforwardly by implementing #84 .

@woodrush
Copy link
Contributor Author

... it prints exactly the same string as its original source code.

Just for clarity, the code doesn't output the comment at the top.

@LingDong- LingDong- merged commit da091ab into wenyan-lang:master Dec 18, 2019
@LingDong-
Copy link
Member

Wow!! Thanks so much! I always wanted a quine example, but how to make one was beyond me ;)

@woodrush
Copy link
Contributor Author

Thanks for the merge! You're welcome! ;) It was fun writing it in this language. I especially like the rendering of the script, thanks for the cool project!

@woodrush woodrush deleted the add-quine-example branch December 18, 2019 14:25
LingDong- added a commit that referenced this pull request Jan 20, 2020
Add quine example (self-replicating code)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants