Headlines


Recent Headlines
Build 424: Functions and Array Operators Technometria


The latest build of the Kynetx Rule Language (KRL) provides a significant upgrade in capability with the addition of functions. We've also added some new array operators that take advantage of functions to make using arrays easier.
KRL supports functions as first-class objects in the expression language. KRL supports only anonymous functions, but they can be given names by binding them to a variable in a declaration. Here's an example:
pre {
add5 = function(x) {
x + 5
};
}
Functions are evaluated statically (e.g. the environment they are defined in, not the environment they are executed in determines the binding of free-variables) and can be recursive. Here's an example of a recursive function in KRL:
pre {
fact = function(n) {
(n <= 0) => 1
| n * fact(n-1)
}
}
Functions are declared using the keyword function and contain optional declarations followed by a single expression that returns the result of the function when executed. To see this,
consider the following example which uses Newton's method to calculate square roots (taken from Section 1.1.8 of Structure and Interpretation of Computer Programs):
sqrt = function(x) {
average = function(x,y) { (x + y) / 2 };
good_enough = function(guess, x) {
v = (guess * guess) - x;
v < 0.01 && v > -0.01
};
improve = function(guess, x) {
average(guess, (x / guess))
}
sqrt_iter = function(guess, x) {
good_enough(guess, x) => guess
| sqrt_iter(improve(guess,x), x)
};
sqrt_iter(1.0, x)
}
Functions can return functions as values and functions can be passed as the arguments to other functions and operators in KRL. The following example defined a generalized summation function that sums the numbers from a to b incrementing using inc and applying the function f to each term:
sum = function(f, a, next, b) {
(a > b) => 0
| f(a) + sum(f, next(a), inc, b)
};
inc = function(x) { x + 1 };
cube = function(x) { x * x * x };
sum_cubes = function(a, b) {
sum(cube, a, inc, b)
}
We could define a function that creates incrementor functions. When given a number, it returns a function that increments by that value:
inc_generator = function(n) { function(x){ x + n } };
inc = inc_generator(1);
inc_by_2 = inc_generator(2);
inc_by_25 = inc_generator(25);
Being able to write functions adds significant power. More so with some of the other languages changes we have in mind for the next few months.
Weve also added several new array operators in recent builds. Most notably, array references now work as follows:
a = [1,4,3,6,5];
b = a[1]
This would bind the value 4 to the variable b. Note that array references only work for arrays of one-dimension, so c[1][2] is not allowed (presuming c is an array of arrays).
In addition, there are a number of new operators available for arrays.
The following array operators are now available (in addition to length which has been previously available):
sort - sorts the array. With no argument, sorting is done in ascending order. The argument "reverse" causes sorting to happen in descending order. The argument can also be a function that takes two argument and returns a boolean value which will be used as the comparison function for the sort.
filter - filters an array, producing a new array. The operator takes a function argument that takes a single parameter and returns a boolean value. The return array contains elements for which the function returns true.
map - modfies an array from mapping a function to each member of the array. The operator takes a function argument that takes a single parameter and returns any value. The array returned from map is the result of applying the function to each member of the original array in turn, collecting the results into a new array.
head - returns the first element of an array without modifying the array.
tail - returns an array that is identical to the orginal array except without the first member.
You could use these like so:
pre {
f = function(x) { x < 4 };
g = function(y) { y * 2 };
a = [1,4,3,6,5];
b = a.sort(); // returns [1,3,4,5,6]
c = a.filter(f); // returns [1,3]
d = a.head(); // d has the value 1
e = a.map(g); // e has the value [2,8,6,12,10]
}
Operators are fairly easy to add and handy to have, so if you have ideas for other operators, on arrays, strings, and so on, just let us know.
The Incredible Internet Answer Machine =Drummond
I know reams have been written about “are we all getting dumber because the Internet is getting smarter?”
But still, it does take my breath away, almost every day.
In another one for the “new heights of irony” file: I was using Gmail this morning and once again wondered about the little orange dot that appears next [...]
Avatar ? Ahhhhhhhh =Drummond
This may be the only blog post I ever write with no link in it. But, reading today that Avatar has finally knocked off Titanic as the #1 grossing movie of all time, one hardly needs to provide a link to either.
Given my passion for film, I just want to say: hats off to James [...]
Redirectionless OAuth Credentials Exchange Technometria

Image via CrunchBase
Am I missing something here? Twitter is working with select partners to test what is variously being called OAuth delegation or browserless OAuth credentials exchange method (not sure why browserless since it's not about the browser, it's about the redirection).
The bottom line is that in an effort to be more user friendly, this removes the redirection to the Twitter site where you authoirize access by letting the third-party site (the site being delegated to) collect and then pass along the user's username and password to get the OAuth credentials. Abraham Williams captured the POST headers from Seesmic Look and they clearly contain the username and password.
I don't see how this can be a step forward in secure third-party access to APIs like Twitter. Once users start being allowed--even required--to (again) enter usernames and passwords into third-party sites, they'll be ripe for phishing attacks. Maybe I'm misunderstanding this based on the scetchy information available, but it looks phishy to me.
Subscription Models are Chic Technometria

Image via CrunchBase
A recent blog post by Dave McClure, the investor in charge of the Founders Fund seed investment program makes the assertion that "subscription models are the new black" and we've lost a decade of innovation by people living off the table scraps of Google's $10B pay-per-click ad system. (Warning: the blog post is pretty raw.)

In a seeming non-sequiter, he moves on to talking about passwords. But pay attention, because what he's really doing is talking about friction in subscription models and the friction that they inpose. I think it's interesting that the iPhone app store, for example, still requires that I type a password when I purchase an app on my iPhone given that they have a good identification based on the device. Of course, what they're doing is using the password for authorization. Making sure it's me who's purchasing the app.
More unintended consequences of browser leakage Kim Cameron's Id Blog
Another example of digital fingerprinting - this time leveraging social networks to produce unique, real-world identification without the user's knowledge
33333 ID Commons
33333 33333 33333 33333
22222222222 ID Commons
222222222 2222222 2222222 222222
1111111111111111 ID Commons
111111111111111111111111111111111111111111111
Minimal disclosure for browsers Kim Cameron's Id Blog
The EFF research could help the industry evolve browsers to follow minimal disclosure principles
New EFF Research on Web Browser Tracking Kim Cameron's Id Blog
CTO Breakfast Tomorrow - Free Pizza Tonight Technometria
Fixing the Google Account problem =Drummond
Joe Andrieu Cuts the Gordian Data Ownership Knot =Drummond
Starting a High Tech Business: Do What's Important by Embra... Technometria
Your Own Personal Piece of the Cloud =Drummond
All the help we can get Kim Cameron's Id Blog
Using OAuth to Access Twitter from KRL Technometria
UtahPolitics.org All Over the Web: A Kynetx App Technometria
On Science, Society, and Democracy Technometria
The Age of Privacy is Over? =Drummond
Federation with ADFS in Windows Server 2008 Kim Cameron's Id Blog
VRM Rising =Drummond
Will Norris on Identity and (Non-Recyclable) Identifiers =Drummond
Bizzare customer journey at myPay? Kim Cameron's Id Blog
Build 384: Annotating Search Results with Large Datasets Technometria
Personal Data Stores ? The Time is Coming =Drummond
Quit Your Job and Get a PhD Technometria
OpenID and Information Cards at the NIH Kim Cameron's Id Blog
Identity Roadmap Presentation at PDC09 Kim Cameron's Id Blog
OpenID Security Discussion itickr.com
New prototype could really help OpenID Kim Cameron's Id Blog
Bob Blakley Gets Privacy Right =Drummond
John Fontana on SAML Interoperability Kim Cameron's Id Blog
OpenID BizDay #4 .Nat Zone
To Push or Not to Push: that is the question .Nat Zone
Difference between UMA and CX .Nat Zone
Open Identity for Open Government itickr.com
SXSW The Tao of XDI
What is an OpenID Extension? .Nat Zone
OpenID International Activities Updates .Nat Zone
Contract Exchange 1.0 Draft 1 .Nat Zone
What is Identity? .Nat Zone
Discussion Note on Contract Exchange .Nat Zone
Off topic ? Social media for a social cause itickr.com
identity as a commons ID Commons
Catalogs, Correlation, Privacy etc. itickr.com
XRD as of July 22. .Nat Zone
Accountability The Tao of XDI
Separating Discovery Service and Authentication Service .Nat Zone
Main Menu
Search
Who's Online
9 user(s) are online (3 user(s) are browsing Identity Blogs)

Members: 0
Guests: 9

more...
Waiting Contents