💡 🖨
Pseudocode
Variablen
Ausgabe
Hilfe
  1. Examples
  2. Values
  3. Compounds and Access
    • String definition: Characters enclosed in quotes like "this is a string"
    • String access: A string followed by brackets allows 1-based element access like "abcd"[3] is "c"
    • String slices: A string followed by brackets and intervals slices like "Peter"[2 ... 3] is "et"
    • Array definition: Values enclosed in square brackets separated by commas like [1,2,3], the square brackets are optional
    • Array access: An array followed by brackets allows 1-based element access like [4,5,6][2] is 5, [[2,7],[3,8]][2][1] or [[2,7],[3,8]][2,1] is 3
    • Array slices: An array followed by brackets and intervals slices like [4,5,6,7][2 ... 3] is [5,6], [4,5,6,7][2 ... ] is [5,6,7], [4,5,6,7][... 3] is [4,5,6]
    • Structure definition: Enclosed by braces with name:value tuples separated by commas like {left:3,right:4}
    • Structure access: A structure followed by a point and a name allows access to that value like {left:3,right:4}.left is 3, if names are numbers sparse array access is done with brackets like {3:1,7:0}[3] equals 1
  4. Operators and Terms
    • Logic
      • Disjunction: Boolean terms can by joined by or like true or false
      • Conjunction: Boolean terms can by joined by and like true and true
      • Negation: Boolean terms can be prefixed by not like not true
      • Xor: Boolean terms can be joined by xor like true xor false
    • Compare numbers, boolean, strings with <, <=, >, >=, ==, !=
    • Arithmetic
      • Sum: Add numbers or strings with a + like 4+5
      • Difference: Substract or prefix numbers with a - like 4-3
      • Multiplication: Multiply numbers with a * like 2*3
      • Division: Divide numbers with a / like 8/4
      • Integer division: Use integer division with div like 11 div 3 resulting in 3.
      • Modulo: Compute remainder with a % or mod like 11%3 or 11 mod 3
      • Bitwise operations: Compute and, or, xor, not (32 bit) like 12 and 13, 17 or 8, 39 xor 11, not 12.
    • Use parantheses to group terms like (2+3)*4
  5. Variables and Assignments
    • Identifiers: Match non-keyword regexp [_a-zA-Z][a-zA-Z0-9_]* such as _Hello2
    • Variables: Are Identifiers that represent values or compounds
    • Assignments: Variables can be assigned values from terms like a=3*2
    • Packed assignments: Variable arrays can be assigned arrays like x,y=[1,2]
    • Array assignments: Array entry can be assigned values like x[1]=3, A[3,4]=B[6,3]
  6. Comments
    • Single line comments start with // comment
    • Multi line comments are enclosed like /* hello comment */
  7. Program control
    • Conditional statements: Use if with a boolean to conditionally execute the commands after then or optional otherwise else until endif like if true then x=1 else x=0 endif
    • Chained if statements: Follow if ... then statements with any number of elseif with a condition followed by then and commmands for chained conditions like if false then a=1 elseif true then b=2 else c=3 endif
    • For loops: y = 0 for x = 1, ..., 3 do y = y + x endfor sums 1+2+3
    • For-in loops: y = 1 for x in [1,2,3] do y = y * x endfor computes 1*2*3, and y = 1 for i:x in [4,5,6] do y = y * (x+i) endfor computes (4+1)*(5+2)*(6+3)
    • While loops: y = 0 while y!=5 do y = y + 1 endwhile counts up to 5
    • Repeat loops: y = 0 repeat y = y + 1 until y==5 counts up to 5
    • Swaps: swap x,y swaps x and y like x,y=y,x
    • Algorithms: Algorithm add(x,y=5) return x+y EndAlgorithm with optional default parameters
  8. Standard library
    • print(..) printing the argument(s)
    • round(..), floor(..), ceil(..) compute rounded, rounded down, rounded up values
    • random(low,high) results in an integer pseudo random number between and including low and high, use seed(..) to switch to seeded version. The function can generate arbitrary long integer numbers but surely is not safe for secure cryptography.
    • time() returns seconds since 1.1.1970
    • len(..) results in the length of an array oder a string
    • codepoint(..), unicode(..) returns the codepoint of a character or the unicode symbol of a codepoint
    • value(..), value(..,..) returns the value of a number string or with given base
    • str(...) returns the string representation of given value
    • hex(..), oct(..), bin(..) returns the hexadecimal, octal or binary of a number
    • max(..,..), min(..,..), sum(..,..) computes maximum, minimum or sum of several values or arrays
    • sqrt(..), pow(b,e), pow(b,e,m), exp(..), log(..), log2(..) square root, power (also modulo m), exponential, natural logarithm, dual logarithm
    • sin(..), cos(..), tan(..), asin(..), acos(..), atan(..), atan2(dy,dx) trigonometric functions
    • sinh(..), cosh(..), tanh(..), asinh(..), acosh(..), atanh(..) hyperbolic functions
  9. Globals
    • timeoutms - Milliseconds maximal runtime
    • version - Version of this interpreter
    • pi - π
  10. Plotting
    • plot(function), plot(f1,f2,..), plot(f1,x1,x2,y1,y2)- Plots functions
      plot(sqrt,0,5) 01234500.511.52
    • plot(binarytree) - Plots binary tree
      plot({value:5,left:{value:3,left:{value:1,col:1},right:{value:4,col:5}},right:{value:8}}) 14385
    • plot(dea), plot(nea) - Plots automata
      plot({Start:1, Alphabet:["a","b"], Rules:[ [[2],[3]], [[4,1],[2]], [[],[4]], [[1],[]] ], End:[4,2]}) q4q1q2q3abaabba plot({Start:3, Alphabet:["x","y"], Rules: [ [2,1],[3,1],[1,3] ], End:[3]}) q2q1q3xyxyxy
    • plot(edges), plot(vertices,edges) - Plot graphs
      plot([[1,1],[1,2],[2,3],[3,1]]) 213 plot([1,2,3,4],[[1,1],[1,2],[2,3],[3,1]]) 2134 plot([{id:"v",x:0,y:0},{id:2,x:2,y:0},{id:3}],[["v","v","z_{23}"],["v",2,"a",1],[2,"v","a",1],[3,3]]) v23z23a