Project

General

Profile

Operators in Scol » History » Version 1

iri, 09/25/2012 12:09 AM

1 1 iri
h1. Operators in Scol
2
3
h2. On integers :
4
5
plus : + : 1+2  5 + 20
6
minus : - : 1 - 2  20 - 5
7
multiply : * : 1*2  20 * 5
8
divide : / : 1/2  20 / 5
9
modulo : mod : mod 1 2  mod 20 5
10
11
h2. On floatting points :
12
13
plus : +. : 1.0 +.2.2  5.1 +. 20.0
14
minus : -. : 1.0 -. 2.2  20.0 -. 5.1
15
multiply : @*.@ : 1.0*.2.2  20.0 *. 5.1
16
divide : /. : 1.0/.2.2  20.0 /. 5.1
17
modulo : mod. : 
18
19
h2. On strings :
20
21
concatenate : strcat : strcat "Bob" "Alice" => "BobAlice"
22
concatenate : strncat : strncat "Bob" :: " and " :: "Alice" :: nil => "Bob and Alice"
23
sub string : substr aString position length : substr "Bob and Alice are married" 8 5 => "Alice" 
24
25
h2. Logicals :
26
27
and : && : (x > 5) && (x < 10)
28
or : || : (x < 5) || (x > 10)
29
not : ! : !1 (=> 0)
30
31
h2. Bit by bit  (like C) :
32
33
and : & : 5 & 3   5 & 2
34
or : | : 5 | 3   5 | 2
35
@>> : 5 >> 1@
36
@<< : 5 << 1
37
@
38
h2. Compare :
39
40
@> : 5 > 2 is true@
41
@>= : 5 >= 5 is true@
42
@< : 5 < 2 is false@
43
@<= : 5 <= 2 is false@
44
@== : 5 == 5 is true@
45
46
h2. Others :
47
48
different != : 5 != 2 is true
49
compare two strings : strcmp stringA stringB : return 1, -1 or 0 if equal (like C)
50
51
h2. Priority :
52
53
like C
54
55
License : "CC-BY-SA-2.0":https://creativecommons.org/licenses/by-sa/2.0/
56
Tutorial by iri
57
Updated by /