[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[QUIZ] Object Query Language for Ruby?

Victor 'Zverok' Shepelev

3/25/2006 7:05:00 AM

Hello.

Today I've stubled upon an interesting article at CodeProject:

Karmencita: an object query language for .NET
http://www.codeproject.com/csharp/Karm...

The do something like

-----
// initialize the data source
// (in this case a Stack of Customers)
Stack<Customer> customers = .....

// initialize Karmencita with
// the type of object to be queries
ObjectQuery<Customer> oq =
new ObjectQuery<Customer>();

// write the query
string query = "Name = [Thor the Mighty]" +
" and IsMale = true and BirthDate" +
" < [1,1,1910]";

//run the query
Customer[] processes = (Customer[]) oq.Select(customers, query);
-------


I have no idea about when and how can be it useful, but it can be intersting
to do the trick for Ruby, ha?

Victor.



5 Answers

Dave Burt

3/25/2006 7:19:00 AM

0

Victor Shepelev wrote:
> Today I've stubled upon an interesting article at CodeProject:
>
> Karmencita: an object query language for .NET
> ...
> // initialize the data source
> // (in this case a Stack of Customers)
> Stack<Customer> customers = .....

customers = ...

> // initialize Karmencita with
> // the type of object to be queries
> ObjectQuery<Customer> oq =
> new ObjectQuery<Customer>();
>
> // write the query
> string query = "Name = [Thor the Mighty]" +
> " and IsMale = true and BirthDate" +
> " < [1,1,1910]";

oq = proc {|cust| cust.name == "Thor the Mighty" &&
cust.male? && cust.birth_date < Date.new(1910) }

> //run the query
> Customer[] processes = (Customer[]) oq.Select(customers, query);

processes = customers.select(&oq)

> I have no idea about when and how can be it useful, but it can be
> intersting
> to do the trick for Ruby, ha?

It's already there!

Cheers,
Dave


Victor 'Zverok' Shepelev

3/25/2006 7:25:00 AM

0

> Victor Shepelev wrote:
> > Today I've stubled upon an interesting article at CodeProject:
> >
> > Karmencita: an object query language for .NET
> > ...
> > // initialize the data source
> > // (in this case a Stack of Customers)
> > Stack<Customer> customers = .....
>
> customers = ...
>
> > // initialize Karmencita with
> > // the type of object to be queries
> > ObjectQuery<Customer> oq =
> > new ObjectQuery<Customer>();
> >
> > // write the query
> > string query = "Name = [Thor the Mighty]" +
> > " and IsMale = true and BirthDate" +
> > " < [1,1,1910]";
>
> oq = proc {|cust| cust.name == "Thor the Mighty" &&
> cust.male? && cust.birth_date < Date.new(1910) }
>
> > //run the query
> > Customer[] processes = (Customer[]) oq.Select(customers, query);
>
> processes = customers.select(&oq)
>
> > I have no idea about when and how can be it useful, but it can be
> > intersting
> > to do the trick for Ruby, ha?
>
> It's already there!
>

Hmmm... Really :) I'm not an idiot, usually.

I must say, Ruby solution seems to be much prettier and "in a spirit of a
languages", yes?

Victor.



Robert Klemme

3/25/2006 10:08:00 AM

0

Victor Shepelev wrote:
>> Victor Shepelev wrote:
>>> Today I've stubled upon an interesting article at CodeProject:
>>>
>>> Karmencita: an object query language for .NET
>>> ...
>>> // initialize the data source
>>> // (in this case a Stack of Customers)
>>> Stack<Customer> customers = .....
>> customers = ...
>>
>>> // initialize Karmencita with
>>> // the type of object to be queries
>>> ObjectQuery<Customer> oq =
>>> new ObjectQuery<Customer>();
>>>
>>> // write the query
>>> string query = "Name = [Thor the Mighty]" +
>>> " and IsMale = true and BirthDate" +
>>> " < [1,1,1910]";
>> oq = proc {|cust| cust.name == "Thor the Mighty" &&
>> cust.male? && cust.birth_date < Date.new(1910) }
>>
>>> //run the query
>>> Customer[] processes = (Customer[]) oq.Select(customers, query);
>> processes = customers.select(&oq)
>>
>>> I have no idea about when and how can be it useful, but it can be
>>> intersting
>>> to do the trick for Ruby, ha?
>> It's already there!
>>
>
> Hmmm... Really :) I'm not an idiot, usually.
>
> I must say, Ruby solution seems to be much prettier and "in a spirit of a
> languages", yes?

The longer I use Ruby the more apparent it seems to me that lambdas /
procs / blocks are one of the core features - if not *the* core feature
- that set it apart from P* languages and make these things so easy and
well looking (= easy to read and understand).

Kind regards

robert

James Gray

3/25/2006 4:27:00 PM

0

On Mar 25, 2006, at 4:08 AM, Robert Klemme wrote:

> The longer I use Ruby the more apparent it seems to me that
> lambdas / procs / blocks are one of the core features - if not
> *the* core feature - that set it apart from P* languages and make
> these things so easy and well looking (= easy to read and understand).

I so agree. When I first came to Ruby, blocks were probably my
biggest stumbling block. I got them down just enough not to think
they were weird every time I used one, but then didn't pay much
attention to them. Much later, when I wanted to move down the path
of enlightenment, I found myself back at blocks. I really believe
they are the key to great Ruby.

James Edward Gray II


usenet

10/1/2012 11:35:00 PM

0

Dr. Jai Maharaj posted:
> > [
> > [ Thorium holds key to India?s energy security
> > [
> > [ By Sandhya Jain
> > [ Editorial
> > [ The Pioneer
> > [ Tuesday, September 11, 2012
> > [
> > [ The Government has allowed private companies to develop
> > [ virtual monopolies in the mining of minerals. And as in
> > [ the telecom and the coal sectors, no auctions were held
> > [ to distribute these valuable national resources
> > [
> > [ As Diwan of Travancore, Sir CP Ramaswami Iyer struggled
> > [ desperately with the departing colonial rulers to prevent
> > [ the kingdom?s riches, including its thorium deposits,
> > [ from falling into the hands of the Congress, whose
> > [ leadership he did not trust. Thorium?s importance has
> > [ been known since the early 20th century when a German
> > [ chemist scouted it for the gas mantles industry. The
> > [ French also knew its worth and bought beach sand from
> > [ Kerala.
> > [
> > [ In fairness, Prime Minister Jawaharlal Nehru banned the
> > [ export of thorium after setting up the Department of
> > [ Atomic Energy. Since then, many rare minerals have been
> > [ found in Indian beach sands ? ilmenite, rutile, garnet,
> > [ zircon and sillimanite. Thorium is critical to our
> > [ nuclear energy security and strategic deterrence policy.
> > [ India?s huge reserves are in the form of placer sand
> > [ complexes along both southern coasts. Manavalakurichi at
> > [ Kanyakumari has 30 per cent of the world?s known
> > [ reserves. Other important sites are Aluva and Chavara
> > [ (Kerala), Sand Complex (Odisha), Vishakhapatnam and
> > [ Bhimunipatnam.
> > [
> > [ Continues here:
> > [
> > [ http://dailypioneer.com/columnists/item/52434-thorium-holds-key-to-india%E2%80%99s-energy-sec...
> >
> > Forwarded post:
> >
> > Dear Editor,
> >
> > I appreciate the analytical article by Sandhaya Jain.
> >
> > Actually, she is one of the great Indian nationalist who
> > is always trying to expose the greatness of Indian
> > traditional culture, Hindu religion, India's prestige. I
> > always praise the strong energetic analyst Sandhya Jain.
> >
> > Thank you.
> > Dirgha Raj Prasai
> > Nepal
> >
> > End of forwarded post.
>
> How far off is thorium energy? It is producing energy
> already -- in many reactors of India...
>
> Friday, September 28, 2012
>
> http://bharatkalyan97.blogspot.com/2012/09/how-far-off-is-thorium-energy-it-is.htm...

UPA's Thoriumgate? Toyota Tsusho enters the scene.

Thursday, September 6, 2012

http://bharatkalyan97.blogspot.com/2012/09/upas-thoriumgate-toyota-tsusho-enters_6.htm...

Jai Maharaj, Jyotishi
Om Shanti