IRCFORTH WORD DICTIONARY ======================== This dictionary contains all built-in Forth words available in the IRC Forth bot, plus user-defined words from ini.fth. Each entry shows the word name, stack effect, and description. Stack Effect Notation: ( before -- after ) - Shows stack contents before and after execution n, n1, n2 - Numbers addr - Memory address flag - Boolean (0 = false, non-zero = true) char - Character code str - String index BUILT-IN WORDS (94 total) ========================== ARITHMETIC OPERATIONS --------------------- + ( n1 n2 -- n3 ) Add two numbers - ( n1 n2 -- n1-n2 ) Subtract n2 from n1 * ( n1 n2 -- n1*n2 ) Multiply two numbers / ( n1 n2 -- n1/n2 ) Divide n1 by n2 MOD ( n1 n2 -- remainder ) Modulo operation SQRT ( n -- sqrt ) Square root of n STACK MANIPULATION ------------------ DUP ( n -- n n ) Duplicate top of stack DROP ( n -- ) Remove top of stack SWAP ( n1 n2 -- n2 n1 ) Exchange top two items OVER ( n1 n2 -- n1 n2 n1 ) Copy second item to top ROT ( n1 n2 n3 -- n2 n3 n1 ) Rotate top three items 2DROP ( n1 n2 -- ) Drop top two items PICK ( ... n -- ... copy ) Copy nth stack item to top ROLL ( ... n -- ... ) Roll nth item to top DEPTH ( -- depth ) Push stack depth TOP ( -- n ) Copy top without removing NIP ( n1 n2 -- n2 ) Remove second item RETURN STACK OPERATIONS ----------------------- >R ( n -- ) R: ( -- n ) Move to return stack R> ( -- n ) R: ( n -- ) Move from return stack R@ ( -- n ) R: ( n -- n ) Copy from return stack R@UL ( -- n ) Fetch from return stack with nesting level R!UL ( n -- ) Store to return stack with nesting level COMPARISON OPERATIONS --------------------- = ( n1 n2 -- flag ) Test equality < ( n1 n2 -- flag ) Test less than > ( n1 n2 -- flag ) Test greater than LOGICAL OPERATIONS ------------------ AND ( flag1 flag2 -- flag ) Logical AND OR ( flag1 flag2 -- flag ) Logical OR NOT ( flag -- flag ) Logical NOT XOR ( flag1 flag2 -- flag ) Logical XOR BITWISE OPERATIONS ------------------ & ( n1 n2 -- n ) Bitwise AND | ( n1 n2 -- n ) Bitwise OR ^ ( n1 n2 -- n ) Bitwise XOR ~ ( n -- n ) Bitwise NOT << ( n1 n2 -- n ) Left shift n1 by n2 bits >> ( n1 n2 -- n ) Right shift n1 by n2 bits INPUT/OUTPUT OPERATIONS ----------------------- . ( n -- ) Print number .S ( -- ) Print stack contents EMIT ( char -- ) Print character CR ( -- ) Print carriage return and flush buffer ." ( -- ) Print string literal (immediate) PRINT ( str-index -- ) Print string from string stack MEMORY OPERATIONS ----------------- VARIABLE ( -- ) Create a variable @ ( addr -- n ) Fetch from memory ! ( n addr -- ) Store to memory +! ( n addr -- ) Add n to memory location ALLOT ( n addr -- ) Allocate n cells to array CREATE ( -- ) Create an array/data structure CONSTANT ( n -- ) Create a constant CONTROL FLOW - CONDITIONALS --------------------------- IF ( flag -- ) Begin conditional execution ELSE ( -- ) Alternative branch THEN ( -- ) End conditional CONTROL FLOW - DEFINITE LOOPS ----------------------------- DO ( limit start -- ) Begin definite loop ?DO ( limit start -- ) Begin loop, skip if start=limit LOOP ( -- ) End loop with increment of 1 +LOOP ( n -- ) End loop with increment of n I ( -- n ) Current loop index J ( -- n ) Outer loop index UNLOOP ( -- ) Exit loop structure early CONTROL FLOW - INDEFINITE LOOPS ------------------------------- BEGIN ( -- ) Start indefinite loop WHILE ( flag -- ) Continue loop if true REPEAT ( -- ) Return to BEGIN UNTIL ( flag -- ) Exit loop when true AGAIN ( -- ) Unconditional return to BEGIN CONTROL FLOW - CASE STRUCTURE ----------------------------- CASE ( n -- n ) Begin case statement OF ( n1 n2 -- n1|empty ) Test case value ENDOF ( -- ) End case branch ENDCASE ( n -- ) End case statement WORD DEFINITION --------------- : ( -- ) Begin word definition ; ( -- ) End word definition EXIT ( -- ) Early exit from word RECURSE ( -- ) Recursive call to current word DICTIONARY OPERATIONS --------------------- WORDS ( -- ) List all defined words SEE ( word-index -- ) Show word definition FORGET ( -- ) Remove word and all subsequent words STRING OPERATIONS ----------------- STRING ( -- ) Create a string variable " ( -- str ) Begin string literal CLEAR-STRINGS ( -- ) Clear string stack UTILITY OPERATIONS ------------------ CLEAR-STACK ( ... -- ) Clear data stack NUM-TO-BIN ( n -- ) Print number in binary PRIME? ( n -- flag ) Test if number is prime CLOCK ( -- time ) Get system time in seconds MICRO ( -- time ) Get time in microseconds MILLI ( -- time ) Get time in milliseconds DELAY ( ms -- ) Delay execution by milliseconds FILE OPERATIONS --------------- LOAD ( filename -- ) Load and execute Forth file APPEND ( text-idx filename-idx -- ) Append text to file IMAGE GENERATION ---------------- IMAGE ( description-idx -- ) Generate image from AI description TEMP-IMAGE ( description-idx -- ) Generate temporary image ASTRONOMICAL OPERATIONS ----------------------- MOON-PHASE ( day month year -- phase illumination ) Calculate lunar phase USER-DEFINED WORDS FROM INI.FTH ================================ STACK UTILITIES --------------- 2SWAP ( x1 x2 x3 x4 -- x3 x4 x1 x2 ) Swap two pairs 2DUP ( x1 x2 -- x1 x2 x1 x2 ) Duplicate top pair 3DUP ( x1 x2 x3 -- x1 x2 x3 x1 x2 x3 ) Duplicate top three 2OVER ( x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2 ) Copy second pair to top TUCK ( n1 n2 -- n2 n1 n2 ) Copy top under second REVERSE ( ... n -- ... ) Reverse top n stack items REVERSE-STACK ( -- ) Reverse entire stack MATHEMATICAL UTILITIES ---------------------- /MOD ( n1 n2 -- rem quot ) Division with remainder MAX ( n1 n2 -- max ) Maximum of two numbers MIN ( n1 n2 -- min ) Minimum of two numbers DOUBLE ( n -- 2n ) Double a number TRIPLE ( n -- 3n ) Triple a number SQUARE ( n -- n² ) Square a number (alias: CARRE) CUBE ( n -- n³ ) Cube a number COMPARISON EXTENSIONS --------------------- >= ( n1 n2 -- flag ) Greater than or equal <= ( n1 n2 -- flag ) Less than or equal 0> ( n -- flag ) Test if positive 0= ( n -- flag ) Test if zero MATHEMATICAL FUNCTIONS ---------------------- FACT ( n -- n! ) Factorial (recursive) FACTLOOP ( n -- n! ) Factorial (iterative) POW ( base exp -- result ) Exponentiation POW2 ( base exp -- result ) Exponentiation with printing FIBONACCI ( n -- fib(n) ) Fibonacci number PGCD ( n1 n2 -- gcd ) Greatest common divisor FPRIME? ( n -- flag ) Fast primality test FPRIME2? ( n -- flag ) Optimized primality test SUM-SQUARED ( n -- sum ) Sum of squares 1² + 2² + ... + n² SUM-CUBES ( n -- sum ) Sum of cubes 1³ + 2³ + ... + n³ SQUARE-SUM ( ... n -- sum² ) Sum of n stack items, then square SQUARE-STACK ( -- sum² ) Square sum of entire stack UTILITY FUNCTIONS ----------------- SPACES ( n -- ) Emit n space characters NUM-TO-STR ( n -- ) Print number as string NUM-TO-ROMAN ( n -- ) Print number in Roman numerals (1-3999) PRINT-ASCII ( -- ) Print ASCII table excerpt MULTI-CHAR ( char n -- ) Print character n times TIME AND DATE ------------- DATE ( -- ) Print current date and time TODAY ( -- day month year ) Get current date values TODAY-CAL-IRC ( -- ) Print calendar with today highlighted CAL ( day month year -- ) Print calendar for given date CAL-IRC-HIGHLIGHT ( day month year -- ) Print calendar with highlighting PRINT-TIME ( -- ) Print current time HH:MM:SS PAD-2DIGIT ( n -- ) Print number with leading zero if < 10 SET-START ( -- ) Record start time TIME-SINCE ( -- microseconds ) Time elapsed since SET-START SHOW-TIME ( -- ) Print elapsed time LUNAR CALCULATIONS ------------------ MOON ( -- ) Show current moon phase with details MOON-PHASE-NAME ( phase -- ) Print moon phase name in French MOON-ICON ( phase -- ) Print moon phase emoji MOON-MESSAGE ( phase -- ) Print poetic moon phase message RANDOM NUMBER GENERATION ------------------------- INIT-RANDOM ( -- ) Initialize random seed with current time RANDOM ( -- n ) Generate pseudo-random number RAND ( min max -- n ) Random number in range [min, max] DIE ( -- n ) Roll one die (1-6) ROLLDICE ( -- ) Roll three dice and show results LOTTERY SIMULATION ------------------ EURO ( -- ) Generate Euro lottery numbers INIT-NUMS ( -- ) Initialize number pool 1-50 SHUFFLE-NUMS ( -- ) Shuffle number pool PICK-NUM ( -- n ) Pick next lottery number INIT-STARS ( -- ) Initialize star pool 1-12 SHUFFLE-STARS ( -- ) Shuffle star pool PICK-STAR ( -- n ) Pick next star number CALENDAR FUNCTIONS ------------------ LEAP-YEAR? ( year -- flag ) Test if year is leap year MONTH-NAME ( month -- ) Print month name WEEKDAY-NAME ( n -- ) Print weekday name (0=Mon...6=Sun) DAYS-IN-MONTH ( month year -- days ) Days in given month/year ZELLER ( month year -- day ) Calculate day of week (Zeller's) GET-DOW ( day month year -- dow ) Get day of week CALC-YEARS ( -- ) Calculate years from days CALC-MONTHS ( -- ) Calculate months from remaining days CALC-DAY ( -- ) Calculate day from remaining days MATHEMATICAL SEQUENCES ---------------------- RECUNACCI ( n -- ) Print Fibonacci sequence up to n PRIME-FACTORS ( n -- ) Print prime factorization SHOW-PRIMES ( n -- ) Print all primes up to n COUNTDOWN ( -- ) Count down from 10 to 1 MULTIPLICATION TABLES --------------------- TABLE ( n -- ) Print multiplication table n×n TABLE-MULT ( n -- ) Print formatted multiplication table ENTERTAINMENT ------------- CAT ( -- ) Print ASCII cat art :D ( -- ) Print smiley emoticon QUOTE ( n -- ) Print inspirational quote (1-3) TEST-CASE ( n -- ) Demonstrate CASE structure HELLO ( -- ) Greet user by name MACRON ( -- ) Print political message CREDIT ( -- ) Print attribution and links TESTING AND DEMOS ----------------- TEST-DELAY ( n -- ) Test delay function n times TREC ( n -- ) Test recursive countdown VARIABLES AND CONSTANTS ----------------------- SEED Variable for random number generator COUNT General-purpose counter variable NUMS Array for lottery numbers (51 cells) STARS Array for lottery stars (13 cells) YEAR Current year variable MONTH Current month variable DAY Current day variable DAYS Days counter for date calculations OFF Calendar offset variable START-TIME Timer start value TODAY-DAY Today's day for calendar highlighting TOTAL WORD COUNT ================ Built-in words: 94 User-defined words from ini.fth: ~140 Grand total: ~234 words available NOTES ===== - All arithmetic uses arbitrary precision integers via GMP library - Stack depth is limited to 10,000 items - Return stack depth is limited to 10,000 items - Words marked (immediate) execute during compilation, not runtime - Some words have multiple aliases (e.g., SQUARE/CARRE) - Calendar functions assume Gregorian calendar - Time functions use system time with CEST timezone offset - Random functions use linear congruential generator - Image functions require network connectivity for AI generation