You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can however reassign an existing variable. If you want to declare a variable with no actual value initially, you can assign it to *null* or *undefined*.
326
326
327
+
##Grouping Functions
328
+
329
+
RoyalScript has 2 special functions that are considered "grouping functions". They do not alter the behavior of their arguments, or compute them in anyway. Their purpose it to allow for arguments to other functions to be grouped to override a single argument requirement, or for executing a series of statements in the call of a single function.
330
+
331
+
###do(...)
332
+
333
+
The *do()* function essentially groups function calls or values togther to be executed or evaluated. It's practicularly useful for displaying a value as a result since all RoyalScript programs require at least one function:
334
+
335
+
```
336
+
>> do(6)
337
+
6
338
+
>> do(true)
339
+
true
340
+
>> do(+(2, 3))
341
+
5
342
+
>> do(=(r, 3), =(r, +(r, r)))
343
+
undefined
344
+
>> do(=(r, 3), =(r, +(r, r)), r)
345
+
6
346
+
```
347
+
348
+
It can also be used to put multiple statements in a loop, though this will be discussed in the loops section.
349
+
350
+
###args(...)
351
+
352
+
The *args()* function allows the grouping of values, to be called by a function that normally only taks a specific number of arguments. The *args()* function cannot be used to call a series of functions, only to group values.
353
+
354
+
##Printing
355
+
356
+
When RoyalScript is run in the browser, one prints arguments by logging them to the console. When RoyalScript is run locally via the NodeJS package, it prints values directly to ther terminal.
357
+
358
+
###$(...)
359
+
360
+
The *$()* function prints an arbitrary number of values. Here are some examples. Note you wont see this on the playground or REPL as it will go to the console.
361
+
362
+
```
363
+
>> $(1)
364
+
1
365
+
undefined
366
+
>> $(1, 2, 3)
367
+
1 2 3
368
+
undefined
369
+
```
370
+
327
371
##String Functions
328
372
329
373
Strings in RoyalScript are types that represent a series of characters or bytes for textual data. They are immutable, but have a series of functions they can be used with for meaningful computation.
@@ -574,4 +618,13 @@ undefined
574
618
1
575
619
>> do(r)
576
620
[4]
621
+
```
622
+
623
+
Even though it only takes one argument to append, it can be extended with the special grouping function called *args()*:
0 commit comments