The Sababa Programming Language

Built-in Functions

Sababa has some built in functions, which like I've mentioned in the previous chapter you've already seen. In this chapter I'll list them out, as well as provide you with the part of the Sababa Stanadard Library, written by Daniel Holden and myself. So lets get started (we're almost there guys...).

String Functions

  • print - which as we've seen prints a string, integer, or anything valid you type onto the screen.
sababa> print "Hello number" 5

=> "Hello number" 5

=> ()
  • error - can be used to notify the user for an error, it only excepts ONE string, which should be written subsequent to it.
sababa> error "Can't use a negative number" ;but you can in Sababa :D by the way I'm a comment remember?

=> Error: Can't use a negative number

List Functions

  • list - takes an unlimited amount of arguments, and returns them in a list.
sababa> list 1 2 3 4

=> {1 2 3 4}
  • head - returns the element situated in the list's first index, as a list.
sababa> head {1 2 3 4}

=> {1}
  • tail - returns a list with its first element removed. You can remember it by thinking of the verb curtail.
sababa> tail {1 2 3 4}

=> {2 3 4}
  • join - takes an unlimited number of quoted expression, which we know as lists (getting you acquainted with the Lisp vernacular... be grateful), and returns a combined, single, list.
sababa> join {1 2 3 4} {5 6 7 8}

=> {1 2 3 4 5 6 7 8}

NOTE: won't undo a multi-dimensional list.

  • eval - evaluates a quoted expression as a symbolic expression (normal expression, which can or cannot be engulfed by parenthesis). Or in other words, evaluates the expression with a list.
sababa> eval {+ 3 3}

=> 6

NOTE: eval won't work if one of the indices is non-integer value, such as a string.

Mathematic Functions

  • | - the vertical bar denotes the max function in Sababa, which returns the greater value between two integers.
sababa> | 4 5

=> 5
  • ~ - If there's a max, of course there is a min. Which is denoted by the tilde in Sababa. This returns the smaller of value of a pair.
sababa> ~ 6 7

=> 6

Post Scriptum

I've written some additional variables and functions, which are included in the Sababa standard library (still a work in progress) that can be found here: https://github.com/Dor-Ron/Sababa-Lisp/blob/master/REPL/uniform/stdlib.saba