Просмотр предыдущей версии от 30.06.2025 10:30


fLang 2

fLang 2 is a programming language with Lisp-like minimalistic syntax, written on Python 3.

Features

Import

You may use statement "import path" anywhere in code to include some other code into your program. All imports processed it pre-execute step.

Math

  + x y : x + y
  - x y : x - y
  * x y : x * y
  / x y : x / y
  ^ x y : x ** y
  % x y : x mod y
  // x y: x / y (Integer)

Comparsions

  == x y : x == y
  != x y : x != y
  < x y : x < y
  > x y : x > y
  <= x y : x <= y
  >= x y : x >= y
  <> x y : x in y

Logic

  | x y : x or y
  & x y : x and y
  ~ x y : x xor y
  ! x : not x

Console IO

  -> x : print(x)
  <- x : input(x)

List operations

  # x : len(x)
  : x (y z) : x[y:z]
  <: x y : x[:y]
  :> x y : x[y:]
  :+ x y : x + [y]
  +: x y : [y] + x
  :& x y : y.join(x)
  :| x y : x.split(y)

Other

  $ x y : var x = y
  fx x y: lambda x: y
  ~> x : return x
  ? x y z : if x: y else: z
  ... x y : while x: y
  ` x : quote(x)

Functions

You may declare anonymous function

(fx (int:arg1:0 :arg2:0 arg3)
  (~> (+ $arg1 (* $arg2 $arg3)))
)

And use it in-situ

((fx (a) (- (^ $a 3) 1)) 5)

Or assign it to variable and run below

  ($ f (fx (a) (- (^ $a 3) 1)))
  ($ f 10)