Skip to content

Instantly share code, notes, and snippets.

Created April 28, 2015 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5f2067cfa0753aea0d94 to your computer and use it in GitHub Desktop.
Save anonymous/5f2067cfa0753aea0d94 to your computer and use it in GitHub Desktop.
TryCF Gist
<cfscript>
// credit: Adam Cameron via http://blog.adamcameron.me/2014/02/coldfusion-11-member-functions.html (with a few tweaks)
s = "The";
s = s.listAppend("quick brown fox", " ")
.listAppend("jumps over the lazy dog", " ")
.ucase()
.reverse();
writeOutput(s);
// credit: Adam Cameron via http://blog.adamcameron.me/2014/02/coldfusion-11-map-and-reduce.html
a = [1];
a[3] = 3;
writeDump(a);
result = a.map(function(v,i,a){
if (structKeyExists(arguments, "v")){
return v^2;
}
});
writeDump(result);
result = a.map(function(v=0,i,a){
return v^2;
});
writeDump(result);
//....
original = {"one"={1="tahi"},"two"={2="rua"},"three"={3="toru"},"four"={4="wha"}};
fixed = structMap(original, function(k,v){
return v[v.keyList().listFirst()];
});
writeDump([original,fixed]);
fixed = original.map(function(k,v){
return v.keyList().listFirst();
});
writeDump([original,fixed]);
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment