Skip to content

Commit 820d7e3

Browse files
committed
update
1 parent 8e24939 commit 820d7e3

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,8 @@ undefined
607607
SyntaxError: missing ) after argument list
608608
```
609609

610+
However, this only applies to functions that expect a value. For functions that execute, like conditionals or loops, you can call un-nestable functions like *set()* in their execution spots.
611+
610612
###append(list, arg1)
611613

612614
The *append()* function takes a list and another argument and places that argument at the end of the list. It, like set is a non-nestable function
@@ -690,4 +692,53 @@ undefined
690692
[1,4]
691693
>> do(first)
692694
[1]
693-
```
695+
```
696+
697+
##Conditional Functions
698+
699+
RoyalScript employs several unique conditonal functions to facilitate control flow in programs.
700+
701+
###?(arg1, arg2)
702+
703+
The *?()* function takes one argument that is or evaluates to a boolean, and another function call of any kind. If that first argument is true, it will execute the second argument, if it's false, nothing happens. Here are some examples:
704+
705+
```
706+
>> ?(true, +(3, 3))
707+
6
708+
>> ?(false, +(1, 3))
709+
undefined
710+
>> =(e, 1)
711+
undefined
712+
>> ?(>(e, 0), =(e, +(e, 2)))
713+
undefined
714+
>> do(e)
715+
3
716+
```
717+
718+
These can also nested and called in a nest.
719+
720+
```
721+
>> ?(==(3, 3),
722+
.. ?(>=(3, 1),
723+
.. list(1, 2, 3)
724+
.. )
725+
.. )
726+
[1,2,3]
727+
```
728+
729+
###if(bool_exp, true\_call, false\_call)
730+
731+
The *if()* function takes a boolean expression, a call/statement to execute if the expression is true, and a third parameter to execute if the expression is false. You must provide 3 arguments or else an error will be raised.
732+
733+
```
734+
>> if(false, 3, 2)
735+
2
736+
>> if(==(1, 1), 3, 2)
737+
3
738+
>> if(==(1, 1),
739+
.. list(1, 1, 1),
740+
.. ?(1, $(1, 2, 3))
741+
.. )
742+
[1,1,1]
743+
```
744+

0 commit comments

Comments
 (0)