Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-Variable number definition:
- let $x = 3
- #-Variable text definition:
- let $someText = "hello world"
- #-Variable list definition:
- let $someList = [1, 2, "hello world"]
- #-Variable dictionary definition:
- let $someDictionary = {x: 1, y: "hello world"}
- #-Variable nameless function definition:
- let $f = <[x, y] : $x + $y ;>
- #-Function definition:
- <<-FUNC_NAME[x, y]:
- return $x + $y
- FUNC_NAME
- # or
- define $FUNC_NAME[x, y] as
- return $x + $y
- end
- #-Function Call
- $FUNC_SUM(3, 4)
- #-List element access:
- $someList[0] = 3
- #-List element length
- $someList.length()
- #-List slice
- $someList[1..3]
- #-Dictionary element access
- $someDictionary["y"]
- $someDictionary.y
- #-If condition
- if $x + $y < 3 do
- $x = 6
- end
- #-While loop
- while $y < 3 do
- $y += 1
- end
- #-For loop
- for $x from 0 to 3 do
- $y *= $x
- end
- #-Sample Code
- let $z = 5
- let $square = <[x]: $x * $x ;>
- print("x squared is: ", $square($z))
- if $z > 5 do
- $z += 1
- else
- $z -= 1
- end
- <<-doAllOperations[x, y]:
- let $result = 0
- $result += $x
- $result *= $y
- $result /= $x
- $result -= $y
- return $result
- doAllOperations
- let $grand_value = $doAllOperations(51542, 15314)
- for $x from 0 to 10 do
- print($grand_value * $x)
- end
- let $list = []
- $list.push(2)
- $list += [4, 1, 3]
- $list.sort(<[x, y]: x < y;>)
- print($list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement