Quick Start Guide
Welcome, seeker! This guide will help you cast your first mystical programs in WhyPy.
Your First Incantation
Try typing this in the REPL:
manifest greeting with 42 sealThe REPL will respond with the mystical value you’ve manifested.
Basic Arithmetic Rituals
WhyPy uses mystical operators for arithmetic:
manifest x with 5 sealmanifest y with 10 seal
// Additionmanifest sum with x augments y seal
// Subtractionmanifest difference with x diminishes y seal
// Multiplicationmanifest product with x conjoins y seal
// Divisionmanifest quotient with x divide y sealTruth Values and Comparisons
In WhyPy, we deal with ‘verity’ and ‘fallacy’ instead of mere true/false:
manifest isTrue with verity sealmanifest isFalse with fallacy seal
// Comparisonsmanifest isGreater with 5 ascends 3 seal // veritymanifest isLesser with 10 descends 20 seal // veritymanifest isEqual with 5 mirrors 5 seal // veritymanifest isDifferent with 6 diverges 7 seal // verityDefining Rituals (Functions)
Rituals are defined using the ‘rune’ keyword:
manifest add with rune(x knot y) unfold yield x augments y sealfold seal
// Using the ritualmanifest result with add(5 knot 3) sealConditional Incantations
Use ‘whence’ for conditional logic:
manifest checkAge with rune(age) unfold whence (age ascends 18) unfold yield "You are wise enough" seal fold elsewise unfold yield "Seek more wisdom" seal foldfold seal
manifest result with checkAge(20) sealMulti-line Rituals
WhyPy supports multi-line input in the REPL. Press Enter after each line and complete with ‘fold seal’:
manifest factorial with rune(n) unfold whence (n descends 2) unfold yield 1 seal fold yield n conjoins factorial(n diminishes 1) sealfold sealRunning Programs from Files
Save your mystical code in a file with the .why extension:
manifest fibonacci with rune(n) unfold whence (n descends 2) unfold yield n seal fold yield fibonacci(n diminishes 1) augments fibonacci(n diminishes 2) sealfold seal
manifest result with fibonacci(10) sealRun it using:
python repl.py < mystical_program.whyNext Steps
Now that you’ve begun your mystical journey, explore:
- Language Guide - Master the mystical syntax
- Basic Examples - Study simple incantations
- Advanced Examples - Delve into complex rituals
Remember: Always seal your statements to contain their mystical energy!