How-To Guide

A comprehensive cookbook covering every aspect of Rampyaaryan, from installation to advanced techniques.

1. Installation

Windows

# Download from Releases
# https://github.com/Rampyaaryans/rampyaaryan/releases

# Or run install script
powershell -ExecutionPolicy Bypass -File install.ps1

Linux

# Option 1: Download binary
curl -L https://github.com/Rampyaaryans/rampyaaryan/releases/latest/download/rampyaaryan-linux-x64 -o rampyaaryan
chmod +x rampyaaryan
sudo mv rampyaaryan /usr/local/bin/

# Option 2: Build from source
git clone https://github.com/Rampyaaryans/rampyaaryan.git
cd rampyaaryan
make
sudo make install

macOS

curl -L https://github.com/Rampyaaryans/rampyaaryan/releases/latest/download/rampyaaryan-macos-x64 -o rampyaaryan
chmod +x rampyaaryan
sudo mv rampyaaryan /usr/local/bin/

Verify

rampyaaryan --version
# Output: Rampyaaryan v3.5.2 (bytecode VM, built ...)

2. Running Programs

Run a .ram file

rampyaaryan hello.ram

Start the REPL

rampyaaryan

Type code interactively. Use .help for available commands.

CommandDescription
.helpShow all keywords and built-in functions
.clearClear screen
.memoryShow memory usage stats
.versionShow version
.exitQuit REPL

3. Variables & Types

Variable Declaration (maano)

maano naam = "Rampyaaryan"
maano umar = 21
maano active = sach
maano kuch_nahi = khali

7 Data Types

TypeHindi NameExamples
Numbersankhya42, 3.14, -7
Stringshabd"hello", "namaste"
Booleanboolsach (true), jhooth (false)
Nullkhalikhali
Listsuchi[1, 2, 3]
Functionkaamkaam fn() { ... }
Map/Dictshabdkosh{"key": "value"}

Print (likho) and Input (pucho)

likho "Hello!"
likho "Naam:", naam
maano naam = pucho("Aapka naam: ")
maano umar = sankhya(pucho("Umar: "))

4. Operators

Arithmetic

OperatorMeaningExample
+Addition5 + 38
-Subtraction10 - 46
*Multiplication6 * 742
/Division10 / 33.333
%Modulo10 % 31
**Power2 ** 101024

Comparison

OperatorMeaning
==Equal
!=Not equal
<Less than
>Greater than
<=Less or equal
>=Greater or equal

Logical

KeywordMeaningExample
aurANDx > 0 aur x < 10
yaORx == 5 ya x == 10
nahiNOTnahi (x > 100)

Compound Assignment

x += 5      # x = x + 5
x -= 3      # x = x - 3
x *= 2      # x = x * 2
x /= 4      # x = x / 4

5. Control Flow

If-Else (agar / warna)

agar umar >= 18 {
    likho "Vote de sakte ho!"
} warna agar umar >= 13 {
    likho "Teenager ho!"
} warna {
    likho "Bachche ho!"
}

While Loop (jab tak)

maano i = 5
jab tak i > 0 {
    likho i
    i = i - 1
}

For Loop (har)

har i = 1; i <= 10; i = i + 1 {
    likho i
}

Break & Continue

har i = 1; i <= 100; i = i + 1 {
    agar i % 2 == 0 { agla }      # Skip even
    agar i > 20 { ruko }          # Stop at 20
    likho i
}

6. Functions (kaam)

Define & Call

kaam namaste(naam) {
    likho "Namaste,", naam, "ji!"
}
namaste("Rampyaaryan")

Return Values

kaam jodo(a, b) {
    wapas do a + b
}
maano result = jodo(5, 3)   # 8

Recursion

kaam factorial(n) {
    agar n <= 1 { wapas do 1 }
    wapas do n * factorial(n - 1)
}
likho factorial(10)    # 3628800

Closures

kaam counter() {
    maano count = 0
    kaam increment() {
        count = count + 1
        wapas do count
    }
    wapas do increment
}
maano c = counter()
likho c(), c(), c()    # 1 2 3

7. Lists (Suchi)

Create & Access

maano fruits = ["seb", "kela", "aam"]
likho fruits[0]      # "seb"
fruits[1] = "angoor"  # Modify

List Operations

joodo(fruits, "santara")        # Append
nikalo(fruits, 0)               # Remove at index
likho lambai(fruits)            # Length
likho shamil(fruits, "seb")     # Contains?
likho index_of(fruits, "aam")   # Find index

Slicing & Advanced

maano nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
likho katao(nums, 0, 3)    # [1, 2, 3]
likho pahla(nums)           # 1
likho aakhri(nums)          # 10
likho ulta(nums)            # [10, 9, ..., 1]
likho kram(nums)            # Sort
likho anokha([1,2,2,3,3]) # [1, 2, 3]

Statistics

maano data = [10, 20, 30, 40, 50]
likho jod(data)              # 150
likho ausat(data)            # 30
likho sabse_bada(data)      # 50
likho sabse_chhota(data)    # 10

# Advanced
flatten([[1,2],[3,[4,5]]])  # [1,2,3,4,5]
tukda([1,2,3,4,5], 2)      # [[1,2],[3,4],[5]]
ghuma([1,2,3,4,5], 2)      # [3,4,5,1,2]
copy_suchi([1,2,3])         # Independent copy
khali_karo(data)             # Clear all

8. Maps / Dictionaries

Creating Maps

# Literal syntax
maano student = {"naam": "Aryan", "umar": 20, "active": sach}

# Empty map
maano m = shabdkosh()

Access & Modify

likho student["naam"]       # Access
student["umar"] = 21        # Modify
student["grade"] = "A"      # Add new key

9 Map Functions

maano m = {"a": 1, "b": 2, "c": 3}

chabi(m)                    # Keys: ["a", "b", "c"]
mulya(m)                    # Values: [1, 2, 3]
jodi(m)                     # Pairs: [["a",1], ...]
map_lambai(m)               # Size: 3
map_hai(m, "a")             # Has key? sach
map_get(m, "d", 0)          # Get with default: 0
map_hatao(m, "c")           # Remove key
map_milao(m, {"d": 4})      # Merge maps
kya_map(m)                  # Is map? sach

9. String Operations

maano s = "  Namaste Duniya  "

lambai(s)                    # Length
bade_akshar(s)               # UPPERCASE
chhote_akshar(s)             # lowercase
saaf(s)                      # Trim whitespace
kato(s, 2, 9)               # Substring
dhundho(s, "Duniya")         # Find (returns index)
badlo(s, "Duniya", "World") # Replace
todo(s, " ")                 # Split
jodo_shabd(list, ", ")       # Join
shuru_se(s, "Nam")          # Starts with?
ant_se(s, "iya")            # Ends with?
dohrao("ha", 3)             # "hahaha"
akshar(s, 0)                 # Character at index
ascii_code("A")             # 65
ascii_se(65)                # "A"
format("{} is {}", "Pi", 3.14)
gino(s, "a")                 # Count occurrences

Advanced String Functions

title_case("hello world")   # "Hello World"
capitalize("hello")         # "Hello"
swapcase("Hello")           # "hELLO"
center("hi", 10, "*")      # "****hi****"
pad_left("42", 5, "0")     # "00042"
pad_right("hi", 8)          # "hi      "
kya_ank("12345")             # sach
kya_akshar("hello")          # sach
kya_alnum("hello1")          # sach
kya_space("  ")              # sach

10. File I/O

# Write
likho_file("output.txt", "Hello World!\n")

# Append
joodo_file("output.txt", "Line 2\n")

# Read
maano content = padho_file("output.txt")
likho content

# Check existence
agar file_hai("data.csv") {
    likho "File mil gayi!"
}

11. Bitwise Operations

maano a = 12    # 1100 in binary
maano b = 10    # 1010 in binary

a & b           # AND: 8 (1000)
a | b           # OR: 14 (1110)
a ^ b           # XOR: 6 (0110)
~a              # NOT: -13
a << 2          # Left shift: 48
a >> 1          # Right shift: 6

# Base conversion
hex_shabd(255)  # "ff"
oct_shabd(255)  # "377"
bin_shabd(255)  # "11111111"

12. Higher-Order Functions

kaam square(x) { wapas do x * x }
kaam is_even(x) { wapas do x % 2 == 0 }
kaam add(a, b) { wapas do a + b }

maano nums = [1, 2, 3, 4, 5]

naksha(nums, square)          # Map: [1, 4, 9, 16, 25]
chhaano(nums, is_even)        # Filter: [2, 4]
ikkatha(nums, add, 0)         # Reduce: 15
sab([1, 2, 3])                # All truthy? sach
koi([0, 0, 1])                # Any truthy? sach
jodi_banao([1,2], ["a","b"]) # Zip
ginati_banao(["a","b"])       # Enumerate

13. Math Functions

# Basic Math
abs_val(-42)        # 42
sqrt_val(144)       # 12
power_val(2, 10)    # 1024
gol(3.7)            # 4
upar(3.2)           # 4
neeche(3.9)         # 3
bada(5, 10)         # 10
chhota(5, 10)       # 5
sign(-42)           # -1
clamp(150, 0, 100)  # 100

# Trigonometry
sin_val(angle)      cos_val(angle)
tan_val(angle)      asin_val(x)
acos_val(x)         atan_val(x)

# Logarithms
log_val(x)    log10_val(x)    exp_val(x)

# Constants
PI()    E()    INF()    NAN_VAL()

# Number Theory
gcd(48, 18)         # 6
lcm(12, 8)          # 24
factorial(10)       # 3628800
kya_prime(17)       # sach
fib(10)             # 55

# Angle Conversion
degrees(PI())       # 180
radians(180)        # 3.14159...

# Advanced
hypot_val(3, 4)     # 5
log2_val(1024)      # 10
is_nan(42)          # jhooth
is_inf(INF())       # sach

14. Type System

Type Checking

kya_sankhya(42)     # sach
kya_shabd("hi")     # sach
kya_suchi([1,2])    # sach
kya_kaam(fn)        # sach
kya_bool(sach)      # sach
kya_khali(khali)    # sach
kya_purn(42)        # sach (is integer?)
prakar(42)          # "sankhya"
kya_map({"a":1})    # sach

Type Conversion

sankhya("42")       # 42
shabd(42)           # "42"
purn(3.99)          # 3
dashmlav("3.14")    # 3.14
bool_val(1)         # sach

15. System & Date/Time

# Timing
samay()             # Execution time (seconds)
ghadi()             # High-precision clock
ruko_samay(1000)    # Sleep 1 second

# Random
yaadrchik()         # Random 0-1
yaadrchik(1, 100)  # Random 1-100

# System
platform()          # "windows"/"linux"/"macos"
env_var("PATH")     # Environment variable
hash_val("hello")   # Hash of value
bahar(0)            # Exit program

# Date & Time
taareekh()          # "2026-03-08"
waqt()              # "14:30:45"
timestamp()         # Unix timestamp
din()               # Day of month
mahina()            # Month (1-12)
saal()              # Year
ghanta()            # Hour (0-23)
minute()            # Minute (0-59)
second()            # Second (0-59)
hafta_din()         # Day of week (0=Sun)

16. Keyword Reference

KeywordEnglishUsage
maanolet/varVariable declaration
likhoprintPrint output
puchoinputRead user input
agarifCondition
warnaelseElse branch
warna agarelse ifElse-if branch
jab takwhileWhile loop
harforFor loop
kaamfunctionFunction definition
wapas doreturnReturn value
rukobreakBreak loop
aglacontinueSkip iteration
sachtrueBoolean true
jhoothfalseBoolean false
khalinullNull value
aurandLogical AND
yaorLogical OR
nahinotLogical NOT

17. Tips & Tricks

  1. Use # for comments — they're ignored by the compiler
  2. Lists can hold mixed types[1, "hello", sach, [2, 3]]
  3. Functions are first-class — pass them as arguments, return them
  4. Closures work — inner functions access outer variables
  5. Use format() for string interpolation — format("{} + {} = {}", 1, 2, 3)
  6. Use ghadi() for benchmarking — high-precision timer
  7. File I/O is cross-platform — read/write/append/check
  8. Use compound assignmentx += 5 instead of x = x + 5

18. Common Errors

ErrorCauseFix
Variable define nahi haiUsing undefined variableAdd maano declaration
Index seema se baharList index out of rangeCheck lambai()
Number convert nahi kar sakteInvalid string to numberValidate input first
'{' lagaoMissing opening braceAdd { after condition/loop
'}' lagaoMissing closing braceAdd }