Skip to content

Commit ff603d3

Browse files
authored
Update 641-language-def.markdown
1 parent 5ba53df commit ff603d3

1 file changed

Lines changed: 14 additions & 18 deletions

File tree

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
# DEF
22

3-
> DEF name[(par1[,...])] = expression
3+
> DEF name[(par1 [, ... , parN])] = expression
44
5-
Defines a single line function.
5+
Defines a single line function with the function name `name` and the parameters `par1` to `parN`. `expression` is a valid SmallBASIC expression returning a value.
66

77
See FUNC for multiline functions and SUB for multiline subroutines.
88

9-
Example 1: Function with one parameter
9+
### Example 1: Function with one parameter
1010

11-
~~~
11+
```
1212
def f(x) = 2*x+3
13-
1413
print f(3)
15-
~~~
14+
```
1615

17-
Example 2: Function with two parameters
16+
### Example 2: Function with two parameters
1817

19-
~~~
18+
```
2019
def f(x,y) = 2*x + 3*sin(y)
21-
2220
print f(1,2)
23-
~~~
21+
```
2422

25-
Example 3: Random number between low and high
23+
### Example 3: Random number between low and high
2624

27-
~~~
25+
```
2826
' A function for random integer numbers between low and high (inclusive)
2927
DEF randi(lo, hi) = (RND * (hi - lo + 1))\1 + lo
3028
@@ -33,12 +31,11 @@ DEF randf(lo, hi) = (RND * (hi - lo + 1)) + lo
3331
3432
print randi(0, 100)
3533
print randf(0, 100)
36-
~~~
34+
```
3735

38-
Example 4: DEF and LOCAL
39-
40-
~~~
36+
### Example 4: DEF and LOCAL
4137

38+
```
4239
' DEF and LOCAL.bas SmallBASIC 0.12.2 [B+=MGA] 2016-04-06
4340
'can I use DEF locally in a sub without interfering with main variable or DEF names
4441
def aboutMe() = "I am texting from main code."
@@ -52,7 +49,6 @@ sub mySub()
5249
def aboutMe() = "I am texting from mySub."
5350
? "Hi, ";aboutMe
5451
end
55-
56-
~~~
52+
```
5753

5854

0 commit comments

Comments
 (0)