Skip to content

Instantly share code, notes, and snippets.

@rsbohn
Created April 7, 2011 18:09
Show Gist options
  • Save rsbohn/908348 to your computer and use it in GitHub Desktop.
Save rsbohn/908348 to your computer and use it in GitHub Desktop.
Trying some recursive actions
ruleset a421x45 {
meta {
name "Try Recursion"
description <<
Try some recursion
>>
author "Randall Bohn"
logging on
}
dispatch {
// Some example dispatch domains
// domain "example.com"
// domain "other.example.com"
}
global {
recursively_append = defaction(location, alist) {
item = alist.head();
alen = alist.length();
anext =
alen > 1 =>
defaction() {
{
append(location, "<li>#{item}</li>");
recursively_append(location, alist.tail());
}
} |
defaction() {
append(location, "<li>#{item}</li>");
}
anext();
}
listify = defaction(title, alist) {
{
notify(title, "<ul id='special'></ul>");
recursively_append('#special', alist);
}
}
}
rule test_browsers is active {
select when pageview ".*" setting ()
pre { b = ["red","blue","green"] }
listify("colors", b);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment