AdarshLang Online Runner

AdarshLang Quick Tutorial

AdarshLang is a Hinglish-inspired programming language. Below is a summary of its features:

Basics

  • Variables: badlo x = 10;
  • Printing: dikhao(x);
  • Booleans: sahi_hai_be (true), jhuth (false)
  • Null: khali
  • Comments: # yeh comment hai

Operators

  • Arithmetic: +, -, *, /, % (modulo), ** (power)
  • Comparison: ==, !=, <, >, <=, >=
  • Logical: && (aur), || (ya), ! (nahin)
  • Compound Assignment: +=, -=, *=, /=, %=

Control Flow

  • If/Else: agar (x < 20) { ... } warna { ... } with chained warna agar
  • While: jabtak (y > 0) { ... }
  • For: ginnati (badlo i = 0; i < 10; i += 1) { ... }
  • For-each: ke_liye (badlo item in list) { ... }
  • Switch: chuno (expr) { case val: ... warna_case: ... }
  • Break/Continue: bas; / aage_badho;

Functions

  • Define: kaam add(a, b) { wapas a + b; }
  • Default params: kaam greet(naam, msg = "namaste") { ... }
  • Varargs: kaam total(baaki nums) { ... }
  • Anonymous: badlo fn = kaam (x) { wapas x * 2; };

Collections

  • Lists: [1, 2, 3] with push, pop, length, sort, reverse, slice
  • Dicts: {"key": "value"} with rakho, nikalo, keys, values
  • Structs: dhacha Vyakti { naam, umar };

Built-in Functions

  • Math: abs, floor, ceil, round_val, min_val, max_val, random_number
  • Strings: upper, lower, join, split, trim, replace, find
  • Type: prakar(x) (type), shabdme(42) (toString), sankhya("42") (toNumber)
  • Iteration: range(start, end, step), contains(list, val)
  • Functional: map, filter, reduce
  • Other: current_time()

Error Handling & Modules

  • Try/Catch: pakdo { ... } chhoddo (err) { ... }
  • Throw: chhoddo("error message");
  • Import: lao "module.aak";