Build 353: Some New Functions for Kynetx Rule Language


Kynetx Logo

We released Build 353 of the Kynetx Rules Engine (KRE) this morning. Actually, I should point out that Wade Billings released it and I watched over his shoulder. This is the first time in the history of Kynetx that someone besides me released KRE code. Yeah!! This is an exciting thing in and of itself. Wade's job is to build a continuous integration environment for Kynetx so that code changes appear in production as quickly as possible. Until then, I've pushed the pain on him to ensure he's properly motivated.

The new release adds two new features to KRL:

  • The as operator provides a way to coerce primitive values. The most interesting ones are coercing strings and regular expressions. You can construct a string and then coerce the result to be a regular expression for use in a replace:
    my_str.replace(("/this/"+ e).as("regexp"),"do you want a")
    
  • You can use math:random to generate random numbers. The function takes an argument and generates a random number between 0 and the argument. For example, you could bind r to a random number between 0 and 9999999 with the following:
    pre {
      r = math:random(9999999)
    }
    notify("Randomness", "A new random number: " + r)
    
    Here's the result showing on my blog: Random numbers in KRL

Both of these features were the result of developers asking for something they needed. We can't promise same day turn around, but for small features like this we try to be as responsive as we can. On Monday we'll announce the new Kynetx Developer Exchange where you can ask questions, answer questions, and make feature requests. More on that later.


Please leave comments using the Hypothes.is sidebar.

Last modified: Thu Oct 10 12:47:19 2019.