arturo 0.3.9

Simple, modern and powerful interpreted programming language for super-fast scripting


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

<img align="left" width="170" src="logo.png">

<h1>Art:uro</h1>

Simple, modern and powerful
interpreted programming language for super-fast scripting.

GitHub Language DUB GitHub code size in bytes

The Language

Arturo is a modern programming language, vaguely inspired by various other ones - including but not limited to Ruby, Haskell, D, SDL, Tcl and Lisp.

It is built on some very simple and straightforward principles:

Everything is a simple statement

There are no "special" language constructs (even `if` is nothing but a simple statement). Everything you see is a statement in the form ID <expression> <expression> <expression> ...

Code is data - and data is code

Arturo can be used both as a data-interchange format and a programming language. Basically all data structures are valid code and all code can be represented as a data structure. Think of it as SDL/Json/YAML/XML combined with the power of Lisp - but without the... sea of opening and closing parentheses.

Each statement returns a value

Whether what you would consider a "function" or any other statement, it will return a value. If it's a block of code (see: function), the last statement's result will be return - unless specified otherwise.

Functions are first-class citizens

Functions - or blocks of statements enclosed in {} - can be anything. Assign them to a symbol/variable, pass them around as arguments to function calls, include them as a dictionary key value, or return them from a function. And of course they can be either named or anonymous/lambda.

Uniform syntax

As already mentioned, everything is a statement of the form ID <expressions>. So, how does this work?

As already mentioned, everything is a statement of the form ID <expressions>. So, how does this work?

  • Is the ID a new or non-function existing symbol? Then, the right-hand value will be assigned to it
  • Is it a function? Then it will be called, with the right-hand values as arguments
  • Do you want to use the result of a function call as part of an expression? Just enclose the function call in $(...) E.g.: print $(reverse #(1 2 3))

Simple, isn't it?

Getting Started

ℹ️ For more examples, you may have a look into the folder /examples/rosetta (all also published @ Rosetta Code) or try them out online via the official Arturo website.

Hello World

"Hello World"

or...

print "Hello World"

Declaring some data

num 	10
str 	"this is a string"

arrA 	1 2 3
arrB 	"one" "two" "three"
arrC	#(1 2 3)

dict 	#{
	name 	"john"
	surname "doe"
	age 	33
	address #{
		city	"Granada"
		country	"Spain"
	}
}

Declaring a function

addNumbers {
	&0 + &1
}

or...

addNumbers [x,y]{
	x + y
}

Fibonacci

maxLimit 20 $(toNumber &0)

fib $(memoize [x]{
	if x<2 { 1 }{
		$(fib x-1) + $(fib x-2)
	} 
})

loop $(range 0 maxLimit) {
	print $(fib &)
}

The Library

LibraryFunctionDescriptionSyntax
arrayallcheck if all elements of array are true or pass the condition of given function[Array or Array/Function] -> Boolean
arrayanycheck if any of the array's elements is true or passes the condition of given function[Array or Array/Function] -> Boolean
arrayavgget average value from array[Array] -> Number or Real
arraycountcount how many of the array's elements is true or passes the condition of given function[Array or Array/Function] -> Number
arraydifferenceget difference of two given arrays[Array/Array] -> Array
arrayfilterget array after filtering each element using given function[Array/Function] -> Array
arrayfirstget first element from array[Array] -> Any
arrayfoldfold array using seed value and the given function[Array/Any/Function] -> Any
arraygcdcalculate greatest common divisor of values from array[Array] -> Number
arrayintersectionget intersection of two given arrays[Array/Array] -> Array
arrayjoinget string by joining array elements with given delimiter[Array/String] -> String
arraylastget last element from array[Array] -> Any
arraymapget array after executing given function for each element[Array/Function] -> Array
arraymaxget maximum value from array[Array] -> Number or Real
arraymedianget median value from array[Array] -> Number or Real
arrayminget minimum value from array[Array] -> Number or Real
arraypermutationsget all permutations for given array[Array] -> Array
arrayproductreturn product of elements of given array[Array] -> Number
arrayrangeget array from given range (from..to) with optional step[Number/Number or Number/Number/Number] -> Array
arraysampleget random sample from given array[Array or Array/Number] -> Any or Array or Null
arrayshuffleshuffle given array[Array] -> Array
arraysortsort given array[Array] -> Array
arraysumreturn sum of elements of given array[Array] -> Number
arraytailget last section of array excluding the first element[Array] -> Array
arrayunionget union of two given arrays[Array/Array] -> Array
arrayuniqueget array by removing duplicates[Array] -> Array
arrayzipreturn array of element pairs using given arrays[Array/Array] -> Array
collectionaddadd element to collection[Array/Any or Dictionary/Any] -> Array or Dictionary
collectioncontainscheck if collection contains given element[String/String or Array/Any or Dictionary/Any] -> Boolean
collectiondeletedelete collection element by using given value[Array/Any or Dictionary/Any] -> Array or Dictionary
collectiondeleteBydelete collection element by using given index/key[Array/Number or Dictionary/String] -> Array or Dictionary
collectionfindreturn index of string/element within string/array, or -1 if not found[String/String or Array/Any] -> Number
collectiongetget element from collection using given index/key[Array/Number or Dictionary/String] -> Any
collectionisEmptycheck if collection is empty[String or Array or Dictionary] -> Boolean
collectionreversereverse given array or string[Array or String] -> Array or String
collectionsetset collection element using given index/key[Array/Number/Any or Dictionary/String/Any] -> Array or Dictionary
collectionsizeget size of collection[String or Array or Dictionary] -> Number
collectionsliceget slice of array/string given a starting and/or end point[Array/Number or Array/Number/Number or String/Number or String/Number/Number] -> Array or String
converttoBinconvert given number to its corresponding binary string value[Number] -> String
converttoHexconvert given number to its corresponding hexadecimal string value[Number] -> String
converttoNumberconvert given value to its corresponding number value[Real or String or Boolean] -> Number or Real
converttoOctconvert given number to its corresponding octal string value[Number] -> String
converttoStringconvert given number/boolean/array/dictionary to its corresponding string value[Number or Real or Boolean or Array or Dictionary] -> String
coreandbitwise/logical AND[Boolean/Boolean or Number/Number] -> Boolean or Number
coreexecexecute given function with optional array of arguments[Function or Function/Any...] -> Any
coreifif condition is true, execute given function - else optionally execute alternative function[Boolean/Function or Boolean/Function/Function] -> Any
coreimportimport external source file from path[String] -> Any
coreinheritinherit existing class/dictionary[String/Dictionary] -> Dictionary
coreinputread line from stdin[] -> String or Any
corelazyget a lazy-evaluated expression[Any] -> Function
coreletforce assign right-hand value to symbol using string name[String/Any] ->
corelogprint value of given expression to screen, in a readable format[Any] -> Any
coreloopexecute given function for each element in array or dictionary, or while condition is true[Array/Function or Dictionary/Function or Boolean/Function] -> Any
corememoizeget a memoized function[Function] -> Function
corenewcopy given object and return a new duplicate one[String or String/Any...] -> Any
corenotbitwise/logical NOT[Boolean or Number] -> Boolean or Number
coreorbitwise/logical OR[Boolean/Boolean or Number/Number] -> Boolean or Number
corepanicexit program printing given error message[String] ->
coreprintprint value of given expression to screen, optionally suppressing newlines[Any or Any/Boolean] -> Any
corereturnreturn given value[Any] -> Any
coretracetrace executing of given expression[Any] -> Any
coreunusestop using given namespace(s)[String or Array] ->
coreuseuse given namespace(s)[String or Array] ->
corexorbitwise/logical XOR[Boolean/Boolean or Number/Number] -> Boolean or Number
cryptodecodeBase64decode given object from base64[String] -> String
cryptoencodeBase64encode given object to base64[String] -> String
cryptohashget hash value for given value[Any] -> String
cryptomd5get MD5 hash of given string data[String] -> String
cryptosha256get SHA256 hash of given string data[String] -> String
cryptosha512get SHA512 hash of given string data[String] -> String
csvparseget object by parsing given CSV string, optionally using headers[String or String/Boolean] -> Array
databasecreatecreate new SQLite database using path[String] -> Dictionary
databaseopenopen SQLite database using path[String] -> Dictionary
datedateNowget current date into string[] -> String
datedatetimeNowget current date and time into string[] -> String
datedayget day from date string[String] -> String
datemonthget month from date string[String] -> String
datetimeNowget current time into string[] -> String
datetimertime the execution of a given function in milliseconds[Function] -> Number
dictionaryhasKeycheck if dictionary has key[Dictionary/String] -> Boolean
dictionarykeysget array of dictionary keys[Dictionary] -> Array
dictionaryvaluesget array of dictionary values[Dictionary] -> Array
fileexistscheck if file exists at given path[String] -> Boolean
filefilesizeget file size of file at given path[String] -> Number
filereadread string from file at given path[String] -> String
filewritewrite string to file at given path[String/String] -> Null
guiappcreate GUI app with given string ID, main window and configuration[String/Dictionary/Dictionary] -> Number
guibuttoncreate GUI button with given title and configuration[String/Dictionary] -> Dictionary
guicheckboxcreate GUI checkbox with given title and configuration[String/Dictionary] -> Dictionary
guiframecreate GUI frame with given title and configuration[String/Dictionary] -> Dictionary
guihboxcreate GUI horizontal box with given configuration[Dictionary] -> Dictionary
guihpanecreate GUI horizontal pane with given configuration[Dictionary] -> Dictionary
guilabelcreate GUI label with given title and configuration[String/Dictionary] -> Dictionary
guitabscreate GUI tabbed view with given configuration[Dictionary] -> Dictionary
guitextfieldcreate GUI textfield with given title and configuration[String/Dictionary] -> Dictionary
guivboxcreate GUI vertical box with given configuration[Dictionary] -> Dictionary
guivpanecreate GUI vertical pane with given configuration[Dictionary] -> Dictionary
guiwindowcreate GUI window for given app and configuration[Dictionary] -> Dictionary
htmlmarkdownToHtmlconvert given markdown string to html[String] -> String
jsongenerateget JSON string from given object[Any] -> String
jsonparseget object by parsing given JSON string[String] -> Any
netdownloaddownload string contents from webpage using given URL[String] -> String
netpostperform POST request using given URL and data[String/String] -> String
numberacosget 'acos' for given number[Number or Real] -> Real
numberacoshget 'acosh' for given number[Number or Real] -> Real
numberasinget 'asin' for given number[Number or Real] -> Real
numberasinhget 'asinh' for given number[Number or Real] -> Real
numberatanget 'atan' for given number[Number or Real] -> Real
numberatanhget 'atanh' for given number[Number or Real] -> Real
numberceilget 'ceil' for given number[Number or Real] -> Real
numbercosget 'cos' for given number[Number or Real] -> Real
numbercoshget 'cosh' for given number[Number or Real] -> Real
numberevencheck if given number is even[Number] -> Boolean
numberexpget 'exp' for given number[Number or Real] -> Real
numberfloorget 'floor' for given number[Number or Real] -> Real
numberisPrimecheck if given number is prime (uses the Miller-Rabin algorithm)[Number] -> Boolean
numberlnget 'ln' for given number[Number or Real] -> Real
numberlog10get 'log10' for given number[Number or Real] -> Real
numberoddcheck if given number is odd[Number] -> Boolean
numberprimeFactorsget list of prime factors for given number[Number] -> Array
numberrandomgenerate random number in given range (from..to)[Number/Number] -> Number
numberroundget 'round' for given number[Number or Real] -> Real
numbershlbitwise left shift[Number/Number] -> Number
numbershrbitwise right shift[Number/Number] -> Number
numbersinget 'sin' for given number[Number or Real] -> Real
numbersinhget 'sinh' for given number[Number or Real] -> Real
numbersqrtget 'sqrt' for given number[Number or Real] -> Real
numbertanget 'tan' for given number[Number or Real] -> Real
numbertanhget 'tanh' for given number[Number or Real] -> Real
pathcreateDircreate directory at given path[String] -> Boolean
pathcurrentDirget current directory path[] -> String
pathdirget array of directory contents at given path[ or String] -> Array
pathgetDirget directory from given path[String] -> String
pathgetExtensionget extension from given path[String] -> String
pathgetFilenameget filename from given path[String] -> String
pathgetUrlComponentsget URL components from given URL[String] -> Dictionary
pathisDirectorycheck if given path is a directory[String] -> Boolean
pathisFilecheck if given path is a file[String] -> Boolean
pathisSymlinkcheck if given path is a symlink[String] -> Boolean
pathnormalizePathget normalized path from given path[String] -> String
reflectionobjectget object for given symbol name[String] -> Any or Null
reflectionpointerget pointer location of object[Any or String] ->
reflectionsymbolExistscheck if given symbol exists[String] -> Boolean
reflectionsymsget list of declared symbols[ or String] ->
reflectiontypeget type for given object[Any] -> String
stringcapitalizecapitalize given string[String] -> String
stringcharget ASCII character from given char code[Number] -> String
stringcharactersget string characters as an array[String] -> Array
stringcolorget colored string using color[String/String] -> String
stringdecodeUrldecode the given URL into a UTF-8 string url, optionally ignoring invalid characters[String or String/Boolean] -> String
stringencodeUrlencode the given UTF-8 string url into a URL, optionally ignoring invalid characters[String or String/Boolean] -> String
stringendsWithcheck if string ends with given string[String/String] -> Boolean
stringisAlphacheck if all characters in given string are ASCII letters[String] -> Boolean
stringisAlphanumericcheck if all characters in given string are ASCII letters or digits[String] -> Boolean
stringisControlcheck if all characters in given string are control characters[String] -> Boolean
stringisDigitcheck if all characters in given string are digits[String] -> Boolean
stringisLowercasecheck if all characters in given string are lowercase[String] -> Boolean
stringisMatchcheck if string matches given regex[String/String] -> Boolean
stringisUppercasecheck if all characters in given string are uppercase[String] -> Boolean
stringisWhitespacecheck if all characters in given string are whitespace[String] -> Boolean
stringlevenshteinget Levenshtein distance between two given strings[String/String] -> Number
stringlinesget lines from string as an array[String] -> Array
stringlowercaselowercase given string[String] -> String
stringmatchesget array of matches for string using given regex[String/String] -> Array
stringpadCentercenter justify string by adding padding[String/Number] -> String
stringpadLeftleft justify string by adding padding[String/Number] -> String
stringpadRightright justify string by adding padding[String/Number] -> String
stringreplaceget string by replacing occurences of string with another string[String/String/String] -> String
stringsplitsplit string by given separator or regex[String/String] -> Array
stringstartsWithcheck if string starts with given string[String/String] -> Boolean
stringstripstrip spaces from given string[String] -> String
stringuppercaseuppercase given string[String] -> String
stringuuidgenerate random UUID string[] -> String
stringwordsget words from string as an array[String] -> Array
systemdelaycreate system delay with a given duration in milliseconds[Number] ->
systemenvget system environment variables as a dictionary[] -> Dictionary
systemshellexecute given shell command[String] -> String or Boolean
systemspawnspawn process using given string and get process id[String] -> Number
systemthreadcreate a background threaded process using given function[Function] ->
webacreate link with title, reference and configuration[String/String or String/String/Dictionary] -> Dictionary
webbcreate bold caption with title and given configuration[String or String/Dictionary] -> Dictionary
webbodycreate web page body with given contents[Dictionary] -> Dictionary
webbrcreate a line break tag[] -> Dictionary
webcellcreate table cell with contents[String or String/Dictionary] -> Dictionary
webcsscreate a link or style tag, with the given CSS source[String] -> Dictionary
webdivcreate div section with contents[Dictionary] -> Dictionary
webh1create H1 header with title and given configuration[String or String/Dictionary] -> Dictionary
webh2create H2 header with title and given configuration[String or String/Dictionary] -> Dictionary
webh3create H3 header with title and given configuration[String or String/Dictionary] -> Dictionary
webh4create H4 header with title and given configuration[String or String/Dictionary] -> Dictionary
webh5create H5 header with title and given configuration[String or String/Dictionary] -> Dictionary
webh6create H6 header with title and given configuration[String or String/Dictionary] -> Dictionary
webheadcreate web page head with given contents[Dictionary] -> Dictionary
webicreate italic caption with title and given configuration[String or String/Dictionary] -> Dictionary
webjscreate a script tag, with the given JavaScript source[String] -> Dictionary
weblicreate unordered list item with title and contents[Dictionary] -> Dictionary
webmetacreate a meta tag with given name and content[String/String] -> Dictionary
webpcreate paragraph with contents[Dictionary] -> Dictionary
webpagecreate web page with given contents[Dictionary] -> Dictionary
webrowcreate table row with contents[Dictionary] -> Dictionary
webtablecreate table with contents[Dictionary] -> Dictionary
webulcreate unordered list section with contents[Dictionary] -> Dictionary
xmlcheckcheck integrity of XML input using given string[String] -> Boolean
xmltestcheck integrity of XML input using given string[] -> Boolean
yamlgenerateget YAML string from given object[Any] -> String
yamlparseget object by parsing given YAML string[String] -> Any

Build Instructions

Prerequisites:

  • Flex
  • Bison
  • D compiler (DMD, or - for production builds - preferably LDC)
  • DUB package manager

Build:

dub build --build=release

Run script:

./arturo <script>

REPL:

./arturo -c

Or... Check it out online!

http://arturo-lang.io

License

MIT License

Copyright (c) 2019 Yanis Zafirópulos (aka Dr.Kameleon)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Authors:
  • drkameleon
Dependencies:
dxml, dmarkdown, urld, dyaml, vibe-d:inet, gtk-d
Versions:
0.3.9 2019-Oct-19
0.3.8 2019-Oct-16
0.3.7 2019-Oct-11
0.3.6 2019-Oct-09
0.3.5 2019-Oct-07
Show all 8 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 25 downloads total

Score:
2.2
Short URL:
arturo.dub.pm