Category:Night: Difference between revisions

From Rosetta Code
Content added Content deleted
(Created page with "'''Night''' is an interpreted programming language made by [https://www.github.com/DynamicSquid DynamicSquid] that combines the simplicity of [https://www.python.org Python] w...")
 
(Add example)
Line 10: Line 10:
* characters (<code>syb</code>)
* characters (<code>syb</code>)
* string (<code>str</code>)
* string (<code>str</code>)
== Examples ==
Here is the example used on the [https://github.com/DynamicSquid/Night GitHub page] (slightly modified):
<lang night>
print("Hello World!\n");

// this is a comment
bit boolean = true;
syb character = 'c';
int integer = 10;
dec float = 3.14;
str string = "squid";

int answer = 10 + 5;
answer = 2 + 3;
int legs = 10;
bit smart = true;
if (legs == 10 && smart) {
print("Hi squid\n");
}
else if (legs == 8 && smart) {
print("Hi octopus\n");
}
else if (legs == 2 && !smart) {
print("Hi human\n");
}
else {
print("Not sure who you are\n");
}
int add(int a, int b) {
print("Adding to numbers:\n");
return a + b;
}

int number = add(2, 3) + 4;
print(number + "\n");
</lang>
Output:
<code>
Hello world!
Hi squid
Adding to numbers:
9
</code>

Revision as of 09:22, 20 August 2020

Night is an interpreted programming language made by DynamicSquid that combines the simplicity of Python with the type concepts of the C family. Its official website is here and the source code is here.

Built-in functions

Right now the only built-in function is print, similar to C's printf. It takes a string as an argument and prints it to the screen (like C, but unlike Python, without a newline).

Types

The types are:

  • integers (int)
  • floating points (dec)
  • booleans (bit)
  • characters (syb)
  • string (str)

Examples

Here is the example used on the GitHub page (slightly modified): <lang night> print("Hello World!\n");

// this is a comment bit boolean = true; syb character = 'c'; int integer = 10; dec float = 3.14; str string = "squid";

int answer = 10 + 5; answer = 2 + 3; int legs = 10; bit smart = true; if (legs == 10 && smart) {

   print("Hi squid\n");

} else if (legs == 8 && smart) {

   print("Hi octopus\n");

} else if (legs == 2 && !smart) {

   print("Hi human\n");

} else {

   print("Not sure who you are\n");

} int add(int a, int b) {

   print("Adding to numbers:\n");
   return a + b;

}

int number = add(2, 3) + 4; print(number + "\n"); </lang> Output: Hello world! Hi squid Adding to numbers: 9

Pages in category "Night"

This category contains only the following page.