About
+misc scripting-language
Accounts
Friends
-
Loading...typography about 4 hours ago -
Loading...meerschwein 25 days ago -
Loading...muhqu 8 days ago -
Loading...peaceman about 2 hours ago -
Loading...SaturnPolly 1 day ago
Newer posts are loading.
You are at the newest post.
Click here to check if anything new just came in.
Click here to check if anything new just came in.
March 19 2010
“ The discussion about which is the absolute best data base engine is the wrong one: you should choose the database system that fits the needs of the application, or to use more than one, such as MySQL together with Memcached or PostgreSQL with CouchDB.
http://brizoma.wordpress.com/2010/03/18/the-nosql-db-hype/ ”
June 25 2009
May 31 2009
Andrew Sorenson is doing some beautiful live "Lisp coding as art" with synthesized sound and OpenGL.
May 29 2009
May 07 2009
Reposted from
vaschtand via
typography
May 06 2009
Play fullscreen
Samba Time Babe!
April 27 2009
April 20 2009
April 16 2009
Reposted from
clarice via
typography
Reposted from
bbd via
SaturnPolly
April 12 2009
Rhino on Android
Reposted from
robi42
March 30 2009
SimplyNoise is a white, pink, and brown noise generator in the form of a web page.
Reposted from
minima
February 18 2009
Array/List comprehensions
When you read the great book "Programming Erlang" from Joe Armstrong
there is a chapter about Mnesia. Mnesia is a distributed, soft real-time database
management system written in the Erlang and included in the Erlang distribution.
One great thing, when you looking at the Mnesia queries, it is not SQL or a new exotic own query language.
No, It is pure Erlang and called list comprehension. You have to know only Erlang!
qlc:q([X#shop.item || X <- mnesia:table(shop),
X#shop.quantity < 250,
Y <- mnesia:table(cost),
X#shop.item =:= Y#cost.name,
Y#cost.price < 2
]).
%% SQL equivalent
%% SELECT shop.item, shop.quantity, cost.name, cost.price
%% FROM shop, cost
%% WHERE shop.item = cost.name
%% AND cost.price < 2
%% AND shop.quantity < 2
A list comprehension is a syntactic construct for creating a list based on existing lists.
It can be implemented using map and filter too. But list compressions provide you a simpler to use and more natural syntax.
Today, I realized that the same feature is already included in Javascript since version 1.7.
What a shame ! :)
It called array comprehensions but works similar like list comprehension in Erlang.
Here the equivalent full javascript code:
<script type="application/javascript;version=1.7">
var shop_table = [
{item:"apple", quantity: 20, cost:2.3},
{item:"orange", quantity: 100, cost:3.8},
{item:"pear", quantity: 200, cost:3.6},
{item:"banana", quantity: 420, cost:4.5},
{item:"potato", quantity: 2456, cost:1.2}
];
var cost_table = [
{name: "apple", price: 1.5},
{name: "orange", price: 2.4},
{name: "pear", price: 2.2},
{name: "banana", price: 1.5},
{name: "potato", price: 0.6}
];
var items = [s.item for each (s in shop_table)
for each (c in cost_table)
if (s.quantity < 250 && s.item==c.name && c.price<2)
];
console.log(items);
// Result: ["apple"]
</script>
[1] https://developer.mozilla.org/en/New_in_JavaScript_1.7#Array_comprehensions
[2] http://ecmascript4.com/doc/arraycomprehensions
[3] http://en.wikibooks.org/wiki/Erlang_Programming/List_Comprehensions
[4] http://www.scribd.com/doc/103818/MNESIA-Database-Management-System
there is a chapter about Mnesia. Mnesia is a distributed, soft real-time database
management system written in the Erlang and included in the Erlang distribution.
One great thing, when you looking at the Mnesia queries, it is not SQL or a new exotic own query language.
No, It is pure Erlang and called list comprehension. You have to know only Erlang!
qlc:q([X#shop.item || X <- mnesia:table(shop),
X#shop.quantity < 250,
Y <- mnesia:table(cost),
X#shop.item =:= Y#cost.name,
Y#cost.price < 2
]).
%% SQL equivalent
%% SELECT shop.item, shop.quantity, cost.name, cost.price
%% FROM shop, cost
%% WHERE shop.item = cost.name
%% AND cost.price < 2
%% AND shop.quantity < 2
A list comprehension is a syntactic construct for creating a list based on existing lists.
It can be implemented using map and filter too. But list compressions provide you a simpler to use and more natural syntax.
Today, I realized that the same feature is already included in Javascript since version 1.7.
What a shame ! :)
It called array comprehensions but works similar like list comprehension in Erlang.
Here the equivalent full javascript code:
<script type="application/javascript;version=1.7">
var shop_table = [
{item:"apple", quantity: 20, cost:2.3},
{item:"orange", quantity: 100, cost:3.8},
{item:"pear", quantity: 200, cost:3.6},
{item:"banana", quantity: 420, cost:4.5},
{item:"potato", quantity: 2456, cost:1.2}
];
var cost_table = [
{name: "apple", price: 1.5},
{name: "orange", price: 2.4},
{name: "pear", price: 2.2},
{name: "banana", price: 1.5},
{name: "potato", price: 0.6}
];
var items = [s.item for each (s in shop_table)
for each (c in cost_table)
if (s.quantity < 250 && s.item==c.name && c.price<2)
];
console.log(items);
// Result: ["apple"]
</script>
[1] https://developer.mozilla.org/en/New_in_JavaScript_1.7#Array_comprehensions
[2] http://ecmascript4.com/doc/arraycomprehensions
[3] http://en.wikibooks.org/wiki/Erlang_Programming/List_Comprehensions
[4] http://www.scribd.com/doc/103818/MNESIA-Database-Management-System
Reposted by
muhqu
February 06 2009
Older posts are this way
If this message doesn't go away, click anywhere on the page to continue loading posts.
Could not load more posts
Maybe Soup is currently being updated? I'll try again automatically in a few seconds...
Maybe Soup is currently being updated? I'll try again automatically in a few seconds...
Just a second, loading more posts...
You've reached the end.

