Rax Programming Language Reference

Jan-Mark S. Wams PhD

Gosia Wrzesińska PhD

Coders Co. B.V.

Legal Notices and Information

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise without the prior written permission of publisher Rax'db B.V. The Netherlands. For permission please contact Rax'db B.V. by e-mail at or by mail at "Rax'db B.V.; Zieseniskade 21; 1017 RT Amsterdam; The Netherlands."

Source codes discussed in this book can be copied, modified or distributed without permission from the copyright holder or the publisher by including the below mentioned reference 'Source code taken from "Rax Programming Language Reference" visit http://raxdb.com/ for more information.'

Rax and Rax'db are registered trademarks.

This document also contains registered trademarks, trademarks and service marks that are owned by their respective companies or organizations. The Publisher and the author disclaim any responsibility for consistently specifying which marks are owned by which companies or organizations.

LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS DISTRIBUTED WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, TECHNICAL, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HERE FROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.

Revision History
Revision $Revision: 429 $ $Date: 2017-10-23 12:15:29 +0200 (Mon, 23 Oct 2017) $

Table of Contents

1. Introduction
What is Rax?
2. Getting started
3. Basic types
? (Boolean)
# (Number)
& (Real)
$ (String)
4. Temporal types
@ (Time)
^ (Absolute)
~ (Relative)
| (Interval)
Magic tags for temporal types
5. Tuples
6. Type-Of Operators
7. Functions
8. Ordered sets
Set operators
Relational operators
Projection
Selection
Natural join
Cross join and ϴ-join
Natural outer joins
Fold (aggregation or reduction)
Partitioning
Temporal relational operators
@&@ (Temporal and)
@<:@ (Temporal element-of)
@?@ (Temporal touch)
@? (Temporal semi-touch)
@!? (Temporal anti-touch)
@\/ (Temporal union)
Set ordering
![] (Order-by operator)
Resulting order
.#0 (Row number)
9. Regex (Regular Expression)
Regex Basics
More Regex
Regex Tips and Tricks
Unsupported regex features
10. More about types
Type conversions
11. Getting data in and out of Rax
Processing data in files
Capturing data from external sources
Processing data in database tables
12. Missing values
Uninitialized Variables
Out-Of-Bounds Indexing
Outer Joins
Empty Functions
Operator Failures
Data Import
13. Modules
14. Rax output
15. The graphical library
Basic procedures
Higher-level procedures
16. Plotting
Bar plots
Scatter plots
17. Math library
18. Random values
19. Meta instructions and macros
Meta instructions
%help
%csv
%epsilon
%digits
%raxpath
%include
%logfile
%missing
%order
%outfile
%remove
%sql
%symtab
%time
%tree
%warn
Macros
20. Extending Rax
21. Rax SQL back ends
Lazy execution
Handling differences in SQL dialects
Client-side processing
A. Using Rax with Notepad++
Obtaining Notepad++
Rax syntax highlighting in Notepad++
Running Rax scripts in Notepad++
Associating Rax files with Notepad++
B. Using Rax with Textadept and other editors
Textadept
Other editors
C. Rax external functions API
e_rax_base_t
u_rax_value_t
rax_value_new
rax_value_link
rax_value_drop
rax_value_cmp
rax_type_new_1
rax_type_new_2
rax_type_link
rax_type_drop
rax_type_cmp
rax_type_new_from_string
rax_type_is_varsize
rax_type_is_compound
rax_type_get_base
rax_type_oset_element_type_ref
rax_tfield_new
rax_tfield_link
rax_tfield_drop
rax_tfield_cmp
rax_tfield_get_label_ref
rax_tfield_get_type_ref
rax_type_tuple_n_tfield
rax_type_tuple_a_tfield_ref
rax_type_tuple_get_tfield_label_ref
rax_type_tuple_get_tfield_type_ref
rax_type_tuple_get_index_by_label
rax_type_tuple_get_index_by_label_nr
rax_type_tuple_add_tfield
rax_type_tuple_add_tfield_type
rax_type_tuple_add_tfield_base
rax_type_tuple_new_cat
rax_type_tuple_new_natural_cat
rax_type_function_get_in_type_ref
rax_type_function_get_out_type_ref
rax_variable_new
rax_variable_link
rax_variable_drop
rax_variable_cmp
rax_variable_get_type_ref
rax_variable_get_value_ref
rax_value_eq_false
rax_value_null
rax_string_cmp
rax_string_new
rax_string_link
rax_string_drop
rax_string_cat
rax_string_catf
rax_string_n_cat
rax_value_oset_cmp
rax_value_oset_contains
rax_value_oset_get_enum_sorted
rax_value_oset_get_enum_un_sorted
rax_value_oset_next_value_new
rax_value_oset_drop_enum
rax_value_oset_get_size
rax_value_oset_write_new
rax_value_oset_write_value
rax_value_oset_write_close
rax_value_tuple_cmp
rax_value_time_cmp
rax_value_relative_cmp
rax_value_interval_cmp
rax_value_interval_new_tand
rax_value_interval_do_touch
rax_value_tuple_new_vararg
rax_value_tuple_new_from_a
rax_value_tuple_new_simplex
rax_value_tuple_link_simplex
rax_value_tuple_drop_simplex
rax_value_tuple_array_ref
rax_value_tuple_ref_by_index
rax_value_function_call
rax_value_time_add_relative
rax_value_time_add_absolute
rax_value_time_sub_relative
rax_value_time_sub_absolute
rax_value_time_absolute_diff
rax_warn_runtime
rax_fatal_runtime
rax_type_to_new_string
rax_value_to_new_string
rax_condef_put
rax_condef_get_ref
D. Hierarchical clustering plugin (beta)
Data Types
API
scConstruct
scGetClusters
scGetMedoids
scGetBestNClusters
scDrillDown
scUndrill
scGetDistanceTab
scDestruct
Constants
Distance functions
Levenshtein distance
Damerau distance
Journey distance
Event histogram distance
Examples
String clustering
Path clustering
E. Third Party Copyright

List of Figures

16.1. A bar plot generated by Rax
16.2. A scatter plot generated by Rax
A.1. User Defined Language dialog in Notepad++
A.2. List of supported languages in Notepad++
A.3. The NppExec plugin in Notepad++
A.4. Running a Rax file in Notepad++
A.5. Notepad++ with the Rax console and Rax syntax highlighting
A.6. .rax in the file extensions list
A.7. Selecting Notepad++ as the default editor for .rax files

List of Tables

3.1. Operators defined on ?
3.2. Operators defined on #
3.3. Operators defined on &
3.4. Operators defined on $
3.5. Escape Sequences for Double Quoted Literal Strings
4.1. Operators defined on @
4.2. Operators defined on ^
4.3. Operators defined on ~
4.4. Operators defined on |
4.5. Magic tags defined on @
4.6. Magic tags defined on ^
4.7. Magic tags defined on ~
4.8. Magic tags defined on |
8.1. Rax set operators
8.2. Set operators in classical set theory and Rax
8.3. Aggregate functions in fold
8.4. Resulting order
9.1. PCRE2/Perl regex features not supported in Rax
10.1. Type conversions in Rax
11.1. Mapping between Rax and SQL Server types for import and `export
12.1. Initial Missing Values for Rax Types
15.1. Basic graphical procedures.
15.2. Higher-level graphical procedures.
17.1. Built-in math constants in Rax
17.2. Built-in math functions in Rax
18.1. Random operators and their ranges