enilKode

From Esolang
Jump to navigation Jump to search

(I have different places where I am writing about enilKode. I have changed things a few times. the official site has up-to-date information about enilKode. The document [should] have every function, though I will create a page on the site for it. This wiki page is outdated, and since anybody can edit this, the site takes precedence over any conflicts.)
enilKode is the first programming language created by enilKoder, which is where he got his username for Esolang. The name enilKode comes from his username on Scratch, enilK. enilKode is somewhat based on Snap!, which is based on Scratch.

Values

(See https://sites.google.com/view/enilkode/data-types)

Void

Void - the V must be capitalized and the only capital
This takes place of undefined and null in other languages

Boolean

True - the T must be capitalized and the only capital
False - same with the F

Number

Digits 0-9
Hyphen at the beginning if the number is negative
Decimal point somewhere after the first digit if the number is not an integer
A colon at the end followed by an integer 2 - 36 can be used to change the number base (if > 10, lowercase letters can be used before the colon)
E - must be capitalized
Pi - just the P must be capitalized
Phi - golden ratio Infinity - just the first I is capitalized

Text String

Surround the text with quotation marks
Use an apostrophe to escape characters if the next character is a letter
Text Strings must start and end on one line Outside of a Text String, an apostrophe can be used to create a one-character Text String with the next character

Sprite

@spriteNameHere - the sprite itself
attributeNameHere@spriteNameHere - this gets attributes of sprites, which can be any value depending on the attribute

List

[] - empty list
Put values in the list and separate with commas

Code block

Open with {}

Close with }{
Code blocks are not automatically evaluated, so you can treat this as a multi-line comment
``Two grave accents indicate that this line is a comment

Box

(See https://sites.google.com/view/enilkode/boxes) By default, no value is mutable (except for sprites, which are inherently mutable). To make a new mutable version of any value, use the mut() function. See the documentation for how that works and other mutable value functions.

Basic syntax

There are no "keywords"; everything executable is treated like functions with () after the name. Without the parentheses, they do nothing (might be treated as a number [base higher than 10, but gives an error], or give another error).

Variables

(See https://sites.google.com/view/enilkode/vars) (This section needs to be updated) def("signature")..{}defEnd("From enilKoder" )}{; signature() (talk) 00:24, 15 June 2020 (UTC) All variables are always public to all Sprites.
If a variable name only contains letters, you can access the variable with a preceding dollar sign. Example:

``There is not an assignment operator; setVar() must be used
setVar("exVar", 5)
print($exVar)
``This will print 5 to the enilKonsole (output console for enilKode)

You can use getVar() to access a variable with any name

``The name of this variable is the bell control character!
setVar("'b", 5)
print(getVar("'b"))
``This will print 5 to the enilKonsole (output console for enilKode)

Defining custom functions

(See https://sites.google.com/view/enilkode/def) Note: this might change in the future.

``pending

To run, type it like other functions

Symbols

(See https://sites.google.com/view/enilkode/ops-and-syms) ~ logical NOT
` comment
! logical XOR
@ sprite
# tag the current line
$ variable
% percentage (divide by 100)
^ exponentiation
& logical AND
* multiplication
( begin: grouping, parameter list, argument list, or allow any Text String to be used with other symbols with labels
) end: grouping, parameter list, argument list, or allow any Text String to be used with other symbols with labels
_ string concatenation
- subtraction
+ addition
= comparison
{} open code block
[ begin list
}{ close code block
] end list
| logical OR
\ modulo
: Represent numbers in different bases, e.g. 11011:2 or 123abc:16
; Separate lines of code on one line
" start or end Text String
' if in a Text String and is followed by a letter, escape a character; otherwise, a one-char Text String with next char
< less-than
, separate items, parameters, or arguments
> greater-than
. decimal point
.. append Code Blocks to the end of functions
? second value if the first value is Void
/ division

Documentation

The Google doc for enilKode can be found here. That document has many other functions, data conversions, and escape characters. As of now, there aren't any interpreters for enilKode, but I'm planning on creating one in Snap!

Example Programs

Hello, world!

print("Hello, world!")

Quine

setVar("Q")..{}print("setVar('qQ'q).." _ $Q _ "'ldo()..$Q")}{
do()..$Q

Cat

print(ask())

Fibonacci

def("Fib")..{$pos}
 if($pos<0 | $pos~=round($pos))..{}
  error("Argument must be a non-negative integer")
 }{
defEnd(branch($pos^2 = $pos, $pos, Fib($pos - 1) + Fib($pos - 2)))
}{

Disan Count

setVar("limit", ask("number"))
setVar("count", 0)
until($count = $limit)..{}
if($count\2 = 0)..{}
print($count)
}{
setVar("count", $count + 1)
}{

FizzBuzz

setVar("n", 0)
#start
print(branch($n\3 = 0, branch($n\5 = 0, "FizzBuzz", "Fizz"), branch($n\5 = 0, "Buzz", $n)))
goToTag("start")

Bootstrap

do() addLine(ask("Type or paste enilKode below, then press [OK] to run it", "print('qHello, world!'q)"))..{}
}{

Truth Machine

ifElse(try())..{}
#a
print(1)
goToTag("a")
}{..{}
print(0)
}{