Skip to content

Commit 327a66e

Browse files
committed
update
1 parent 7f23262 commit 327a66e

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,4 +365,43 @@ The *num()* function takes one string argument and converts it to a number.
365365
4
366366
>> num(str(4))
367367
4
368+
```
369+
370+
###get(string, index)
371+
372+
The get function, which works for structs and lists as well, takes a string argument and index argument (must be a number for strings) and returns the one character string present at the index. Like other languages, strings are 0-indexed. If the index is out of range, the function evaluates to *undefined*. This behavior can be handled via conditionals which is in a later section.
373+
374+
```
375+
>> =(s, `foo`)
376+
undefined
377+
>> get(s, 1)
378+
"o"
379+
>> get(s, 0)
380+
"f"
381+
>> get(s, 7)
382+
undefined
383+
```
384+
385+
###len(string)
386+
387+
The *len()* function gets the length of the string in terms of the number of characters in it.
388+
389+
```
390+
>> len(`foo`)
391+
3
392+
```
393+
394+
###cut(string, start, end)
395+
396+
The *cut()* function takes a string, a starting index, and ending index and returns a substring or slice of a string between those indexes. The ending parameter can also be a negative number to specify a reverse index from the end of the string.
397+
398+
```
399+
>> cut(`abcdefgh`, 0, 4)
400+
"abcd"
401+
>> cut(`abcdefgh`, 0, 2)
402+
"ab"
403+
>> cut(`abcdefgh`, 0, -1)
404+
"abcdefg"
405+
>> cut(`abcdefgh`, 0, -4)
406+
"abcd"
368407
```

0 commit comments

Comments
 (0)