![]() |
Associative Arrays
Will we ever get them? :(
|
Oooh, yeah. Good idea.
|
We already have hashes, associative arrays would just be the same thing with different syntax.
|
Quote:
|
Quote:
Hashes are the most common way associative arrays are implemented, so we have associative arrays, just without the conventional syntax one would see in for example in PHP. |
At some point you would think people would just want to plob javascript into the engine.
|
Quote:
|
Quote:
|
Quote:
|
Quote:
I would not even know where to begin to write an associate array in haskell that has any better than O(n) lookups. |
Quote:
If you do it on a list like [("a", "1"), ("b", "2"), ("c", "3")] it'll return in O(n). However, if you do it on a Data.Map which are represented as immutable balanced binary trees, it'll give you a O(log(n)). Those would be the preferred methods since they both provide a purely functional interface, but you can use hash tables as well with an imperative interface in the IO Monad (with a data HashTable) giving you the O(1). |
Keep your inferior languages to yourself, obviously Python would be the better choice, its popularity speaks for itself. Utilizing Boost::Python makes it much easier to wrap C++.
Python implements hash tables (associative array) as the 'dict' object. You can specify dict literals using angle brackets. e = {'key1': 'value1', 'key2': 'value2'} print(e['key2']) Python allows you to define many functions called by the interpreter, in this case, e['key2'] = 3 maps to e.__setitem__('key2', 3). You can quite easily take control of item or attribute lookup or other things. One of the major points in favor of Python is readability, which is obviously important in Graal considering the programming experience and amount of people that would be looking at one script. Thanks for thread URL Ziro. |
Quote:
Lua is designed for embedding to begin with and there are plenty of ways to wrap C++ into lua. What makes boost.python superior to third-party lua binding libraries? Quote:
Quote:
|
Quote:
Quote:
Quote:
Quote:
|
Hey, let's find a thread where Inverness DOESN'T start arguing that Python is better than all other languages when he actually hasn't used most of the other ones people are talking about!
|
Quote:
I'm saying Python is better for Graal's needs, which are: clear and readable syntax, extensive documentation, and rich object-oriented capabilities, among other things. |
Quote:
Quote:
|
Quote:
And I await your response to the second half of my previous post. |
Quote:
2. Lua has extensive documentation. 3. Lua is richly MULTI-paradigm! Check it out, you can be imperative, functional, prototypal, and object-oriented! Amazing! 1. Haskell has concise syntax. 2. Haskell has extensive documentation. 3. Haskell is a functional programming language! Sweet! Check it out, everything is a function! |
Quote:
Of course, the better means of comparison would be to solve Graal problems in the language. And I think I'm bored enough to do that. |
Quote:
|
Quote:
|
| All times are GMT +2. The time now is 05:16 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.