Expressive, simple and easy to learn programming language.
var name: String;
func sayHelloTo(name: String) -> Void {
print("Hello");
print(name);
}
sail {
name = "Sailer"
sayHelloTo(name)
}
Hello Sailer
| Data Type | Code |
|---|---|
| Boolean | Bool |
| Character | Character |
| Float | Float |
| Integer | Int |
| String | String |
var boatName: String;
boatName = "Navigator";
Arrays
var coordinates[2]: Float;
coordiantes[0] = 25.686613;
coordiantes[1] = -100.316116;
Logic
| Name | Operator |
|---|---|
| And | && |
| Or | || |
| Not | ! |
| Equal to | == |
| Not equal to | != |
| Greater than | > |
| Less than | < |
| Greater or equal than | >= |
| Less or equal than | <= |
Aritmetic
| Name | Operator |
|---|---|
| Addition | + |
| Subtraction | - |
| Multiplication | * |
| Division | / |
Other
| Name | Operator |
|---|---|
| Assignment | = |
| Print value | print(value) |
if(lightHouseOnSight == true) {
print("There's land near");
} else {
print("We are still far from land");
}
while(windBlowing == true) {
print("Keep the sails open");
}
print("There's no wind anymore, close the sails");
Declaration
func adjustSailPosition(position: Float, by: Float) -> Float {
return position + by;
}Call
newPosition = adjustSailPosition(10.847, -0.532);
No returning value function definition
func printAdjustedSailPosition(position: Float, by: Float) -> Void {
print(position + by);
}Call (Can't assign to a variable)
adjustSailPosition(10.847, -0.532);
var boatName: String;
var boatCoordinates[2]: Float;
var destinationCoordinates[2]: Float;
func printCoordinateDifference(currentLat: Float, currentLong: Float, destinationLat: Float, destinationLong: Float) -> Void {
print("Latitude:");
print(destinationLat - currentLat);
print("Longitude:");
print(destinationLong - currentLong);
}
sail {
boatName = "Navigator";
boatCoordinates[0] = 102.423; // Latitude
boatCoordinates[1] = -52.123; // Longitude
destinationCoordinates[0] = 102.423; // Latitude
destinationCoordinates[1] = -52.123; // Longitudeprint("Coordinate difference for boat:")
print(boatName)
printCoordinateDifference(boatCoordinates[0], boatCoordinates[1], destinationCoordinates[0], destinationCoordinates[1]);
}