YAL is Yet Another scripting Language(but worse)

Related tags

Command-line yal
Overview

YAL - Yet Another Language

YAL is yet another scripting language(but worse).

Syntax

Basic syntax

fun main() {
    print("Hello, World!");
}

Fibonacci

fun fib(n) {
	if (n <= 1) {
		ret n;
	}

	ret fib(n - 1) + fib(n - 2);
}

fun main() {
	mut n = 10;
	loop {
		if (n < 0) {
			break;
		}

		println(fib(n));
		n -= 1;
	}
}

Comments

// This is a single line comment

Variables

fun main() {
    // A variable is either const,
    const a = 1;
    // or mutable
    mut b = 2;
    const result = a + b;
    print(result); // 3
}

Conditions

fun main() {
    const a = int(input());
    const b = int(input());
    
    if (a > b) {
        print("a is greater than b");
    } else if (a < b) {
        print("a is less than b");
    } else {
        print("a is equal to b");
    }
}

Loops

fun main() {
    const n = int(input());
    mut i = 1;
    
    loop {
        if (i > n) {
            break;
        }
        println(i);
        i += 1;
    }
}

Arrays

fun main() {
    const arr = [1, 2, 3, 4, 5];
    print(arr[0]); // 1
    print(arr[1]); // 2
    print(arr[2]); // 3
    print(arr[3]); // 4
    print(arr[4]); // 5
    
    // iterate
    iter arr: it {
        print(it);
    }
}

Functions

fun add(a, b) {
    ret a + b;
}

Data

data Triangle {
    AB,
    AC,
    BC
}

methods Triangle {
    fun area() {
        const s = (@AB + @AC + @BC) / 2;
        ret pow(s * (s - @AB) * (s - @BC) * (s - @AC), 0.5);
    }
}

fun main() {
    const triangle = Triangle {
        AB: 4,
        AC: 5,
        BC: 6
    };
    println(triangle.area());
}

Operators

Operator Description
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulo
= Assignment
== Equal
!= Not equal
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
&& Logical and
\\ Logical or
! Logical not
+= Increment by rhs
-= Decrement by rhs
*= Multiply by rhs
/= Divide by rhs
%= Modulo by rhs
>> Right shift
<< Left shift
& Bitwise and
| Bitwise or
^ Bitwise xor
~ Bitwise not
&= Bitwise and by rhs
|= Bitwise or by rhs
^= Bitwise xor by rhs
>>= Right shift by rhs
<<= Left shift by rhs

Native Functions

Function Description Prototype
print Prints arguments to STDOUT fn print(..) -> None
println print, but with newline at the end fn println(..) -> None
sleep Sleeps for n seconds fn sleep(n: int/float) -> None
pop Removes last element of given array fn pop(arr: [any]) -> any
input Prints prompt(if given) and takes user input as string fn input(prompt: string?) -> string
int Converts given argument to int type fn int(n: string/int/float) -> int
float Converts given argument to float type fn float(n: string/int/float) -> float
pow Applies nth power on x fn pow(x: int/float, n: int/float) -> float
You might also like...
โšก๐Ÿฆ€ Yet another rust system info fetcher.
โšก๐Ÿฆ€ Yet another rust system info fetcher.

Yarsi: Yet another rust sys info fetcher โœจ Showcase requirements ๐Ÿ™€ cargo ๐Ÿฆ€ install with $ curl https://sh.rustup.rs -sSf | sh installation โค๏ธโ€๐Ÿฉน Ya

Yet another command-line chat GPT frontend written in Rust.
Yet another command-line chat GPT frontend written in Rust.

gpterm Yet another command-line chat GPT frontend written in Rust. Features Stream output with typing effect Store chat messages/history Context aware

Yet another code execution engine written in Rust.
Yet another code execution engine written in Rust.

exec Yet another blazingly fast code execution engine written in Rust. Paths GET /api/v1/status GET /api/v1/runtimes POST /api/v1/execute POST /api/v1

Nerf is (yet another) rust GUI lib

NERF Nerf is (yet another) rust GUI lib. It is heavily inspired by Flutter, and is designed to build apps that could run on any plateforms, such as wi

Yet another Python environment manager.

yen The easiest Python environment manager. Create virtual environments for any Python version, without needing Python pre-installed. Installation Get

A simple, human-friendly, embeddable scripting language

Mica Language reference ยท Rust API A simple, human-friendly scripting language, developed one feature at a time. Human-friendly syntax inspired by Rub

The GameLisp scripting language

GameLisp GameLisp is a scripting language for Rust game development. To get started, take a look at the homepage. Please note that GameLisp currently

Open-source compiler for the Papyrus scripting language of Bethesda games.

Open Papyrus Compiler This project is still WORK IN PROGRESS. If you have any feature requests, head over to the Issues tab and describe your needs. Y

A safe, fast, lightweight embeddable scripting language written in Rust.

Bud (budlang) A safe, fast, lightweight embeddable scripting language written in Rust. WARNING: This crate is not anywhere near being ready to publish

Owner
MD Gaziur Rahman Noor
16 years old FOSS enthusiast
MD Gaziur Rahman Noor
Yay - Yet another Yogurt - An AUR Helper written in Go

Yay Yet Another Yogurt - An AUR Helper Written in Go Help translate yay: Transifex Features Advanced dependency solving PKGBUILD downloading from ABS

J Guerreiro 8.6k Jan 1, 2023
Yet another fractal generator (based on glium)

Juliabrot Yet another fractal generator. Juliabrot is a Rust application using the OpenGL Framework to render in realtime. Install Rust To download Ru

Max 2 Feb 27, 2022
Yet another package manager for Rust.

Rpip Installing. Make sure you have just (packages) installed! Once you have just installed move into the root directory (where this file is) and run

null 2 Apr 27, 2022
Yet another Codeforces cli

cf-tool-rs A Rust implement for https://github.com/xalanq/cf-tool WIP. Pull Requests / Contributions are welcomed! How to Configure? Configure File sh

Woshiluo Luo 2 May 8, 2022
Yet Another Kalman Filter Implementation. As well as Lie Theory (Lie group and algebra) on SE(3). [no_std] is supported by default.

yakf - Yet Another Kalman Filter Yet Another Kalman Filter Implementation, as well as, Lie Theory (Lie group, algebra, vector) on SO(3), SE(3), SO(2),

null 7 Dec 1, 2022
Yet another lightweight and easy to use HTTP(S) server

Raptor Web server Raptor is a HTTP server written in Rust with aims to use as little memory as possible and an easy configuration. It is built on top

Volham 5 Oct 15, 2022
Yet Another Texture Packer - a small and simple CLI application to pack multiple textures/sprites into a texture atlas/sprite sheet

YATP (Yet Another Texture Packer) A small and simple CLI application to pack multiple textures/sprites into a texture atlas/sprite sheet. Installation

Petar Petrov 2 Sep 11, 2022
Yet another sort crate, porting Golang sort package to Rust.

IndexSort IndexSort Yet another sort crate (in place), porting Golang's standard sort package to Rust. Installation [dependencies] indexsort = "0.1.0"

Al Liu 4 Sep 28, 2022
๐Ÿš€ Yet another repository management with auto-attaching profiles.

?? ghr Yet another repository management with auto-attaching profiles. ?? Motivation ghq is the most famous solution to resolve stress of our reposito

Naoki Ikeguchi 29 Dec 2, 2022
Yet another phigros chart player.

prpr - P hig R os P layer, written in R ust Usage To begin with, clone the repo: git clone https://github.com/Mivik/prpr.git && cd prpr For compactnes

Mivik 6 Jan 1, 2023