Tumblelog by Soup.io
Newer posts are loading.
You are at the newest post.
Click here to check if anything new just came in.

March 19 2010

leobm
leobm
leobm
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

leobm

May 31 2009

leobm
Andrew Sorenson is doing some beautiful live "Lisp coding as art" with synthesized sound and OpenGL.

May 29 2009

leobm

May 07 2009

leobm

May 06 2009

leobm
Play fullscreen

Samba Time Babe!

April 27 2009

leobm
leobm

April 20 2009

leobm
leobm

April 16 2009

leobm
5959_7165_500
Reposted fromclarice clarice viatypography typography
leobm

April 12 2009

leobm
leobm

March 30 2009

leobm
6733_10bf
SimplyNoise is a white, pink, and brown noise generator in the form of a web page.
Reposted fromminima minima

February 18 2009

leobm
leobm

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
Reposted bymuhqu muhqu

February 06 2009

leobm
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...
Just a second, loading more posts...
You've reached the end.