Created
April 7, 2011 18:09
-
-
Save rsbohn/908348 to your computer and use it in GitHub Desktop.
Trying some recursive actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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