Welcome to ToxicCode!

This website was created purely for fun and educational purposes. It's a playful exploration of programming concepts and design.

Feel free to explore and experiment!

ToxicCode Programming Test

Question 1: Basic Syntax

Write a program that prints "Hello, Toxic World!" using ToxicCode syntax:

Writing to file: test.txt Content: Hello World Reading file: test.txt Content: Hello World

ToxicCode Documentation

Introduction

ToxicCode is a modern programming language designed for simplicity and expressiveness. It combines the best features of functional and imperative programming paradigms.

Basic Syntax

  • toxic.print(expression) - Outputs the evaluated expression to the console
  • Statements end with semicolons (;)
  • Comments start with // for single line or /* */ for multi-line

Core Functions

Output Functions

  • toxic.print(value) - Prints value to console
  • toxic.clear() - Clears the console output
  • toxic.format(text, style) - Prints formatted text with styles
  • toxic.alert(message) - Shows an alert message

Control Flow Functions

  • toxic.loop(count, callback) - Executes callback n times
  • toxic.delay(ms, callback) - Executes callback after delay
  • toxic.interval(ms, callback) - Repeatedly executes callback
  • toxic.timeout(ms, callback) - Executes callback once after delay

Math Functions

  • toxic.math.add(a, b) - Adds two numbers
  • toxic.math.subtract(a, b) - Subtracts b from a
  • toxic.math.multiply(a, b) - Multiplies two numbers
  • toxic.math.divide(a, b) - Divides a by b
  • toxic.math.power(base, exp) - Raises base to exponent
  • toxic.math.random(min, max) - Generates random number
  • toxic.math.round(number) - Rounds to nearest integer

Array Functions

  • toxic.array.forEach(array, callback) - Iterates over array
  • toxic.array.map(array, callback) - Maps array to new values
  • toxic.array.filter(array, callback) - Filters array elements
  • toxic.array.reduce(array, callback) - Reduces array to single value
  • toxic.array.sort(array) - Sorts array elements
  • toxic.array.reverse(array) - Reverses array elements

String Functions

  • toxic.string.length(str) - Returns string length
  • toxic.string.uppercase(str) - Converts to uppercase
  • toxic.string.lowercase(str) - Converts to lowercase
  • toxic.string.split(str, delimiter) - Splits string into array

Examples

// Using the loop function
toxic.loop(3, () => toxic.print("Hello"));

// Using math functions
let result = toxic.math.add(5, 3);
toxic.print(result);

// Using array functions
let numbers = [1, 2, 3];
toxic.array.forEach(numbers, (n) => toxic.print(n));

// Using delay
toxic.delay(1000, () => toxic.print("Delayed message"));
      

System Functions

  • toxic.system.getTime() - Returns current time
  • toxic.system.getDate() - Returns current date
  • toxic.system.platform() - Returns system platform
  • toxic.system.browserInfo() - Returns browser information

Validation Functions

  • toxic.validate.isNumber(value) - Checks if value is a number
  • toxic.validate.isString(value) - Checks if value is a string
  • toxic.validate.isArray(value) - Checks if value is an array
  • toxic.validate.isEmpty(value) - Checks if value is empty

String Functions

  • toxic.string.reverse(str) - Reverses a string
  • toxic.string.replaceAll(str, search, replace) - Replaces all occurrences
  • toxic.string.trim(str) - Removes whitespace
  • toxic.string.contains(str, search) - Checks if string contains value

Math Functions

  • toxic.math.sqrt(number) - Calculates square root
  • toxic.math.abs(number) - Returns absolute value
  • toxic.math.max(...numbers) - Returns maximum value
  • toxic.math.min(...numbers) - Returns minimum value

Examples

// Using system functions
toxic.print(toxic.system.getTime());
toxic.print(toxic.system.platform());

// Using validation
toxic.print(toxic.validate.isNumber("123"));
toxic.print(toxic.validate.isString(456));

// Using new string functions
toxic.print(toxic.string.reverse("Hello"));
toxic.print(toxic.string.contains("Hello World", "World"));

// Using new math functions
toxic.print(toxic.math.sqrt(16));
toxic.print(toxic.math.max(1, 5, 3, 9, 2));
      

File System Functions

  • toxic.fileSystem.readFile(filename) - Reads file content
  • toxic.fileSystem.writeFile(filename, content) - Writes to file
  • toxic.fileSystem.deleteFile(filename) - Deletes a file
  • toxic.fileSystem.listFiles() - Lists all files

Network Functions

  • toxic.network.fetch(url) - Fetches data from URL
  • toxic.network.post(url, data) - Posts data to URL
  • toxic.network.websocket(url) - Creates WebSocket connection

Data Structure Functions

  • toxic.dataStructures.stack.create() - Creates a new stack
  • toxic.dataStructures.stack.push(stack, item) - Pushes item to stack
  • toxic.dataStructures.stack.pop(stack) - Pops item from stack
  • toxic.dataStructures.queue.create() - Creates a new queue
  • toxic.dataStructures.queue.enqueue(queue, item) - Adds item to queue
  • toxic.dataStructures.queue.dequeue(queue) - Removes item from queue
  • toxic.dataStructures.set.create() - Creates a new set
  • toxic.dataStructures.set.add(set, item) - Adds item to set
  • toxic.dataStructures.set.delete(set, item) - Removes item from set

Cryptography Functions

  • toxic.crypto.hash(text) - Hashes input text
  • toxic.crypto.encrypt(text, key) - Encrypts text with key
  • toxic.crypto.decrypt(text, key) - Decrypts text with key
  • toxic.crypto.generateKey() - Generates encryption key

Advanced Examples

// Using Data Structures
let stack = toxic.dataStructures.stack.create();
toxic.dataStructures.stack.push(stack, "item1");
toxic.print(toxic.dataStructures.stack.pop(stack));

// Using Crypto
let key = toxic.crypto.generateKey();
toxic.crypto.encrypt("secret message", key);

// Using Network
toxic.network.fetch("https://api.example.com/data");

// Using File System
toxic.fileSystem.writeFile("test.txt", "Hello World");
toxic.fileSystem.readFile("test.txt");