|
I'm probably missing something here, but why do you want to reinvent the wheel?
No, there are no dictionaries in javascript <spit>, it's untyped afterall. But if you call them by the normally accepted name, associative array, you'll notice it's already built in, even in such a backwards language as javascript <spit>.
More info here: JavaScript <spit>- Objects as associative arrays[^]
|
|
|
|
|
I know objects are implemented as associative arrays so JavaScript kind of has a Dictionary.
JavaScript also has an array that sort of acts like a list (but "add" is called "push", it's also a queue and a stack, it doesn't even have a decent "contains" function (it does in newer browsers, but it's called "includes", because that's what it's called everywhere else, right?), etc.).
So, just like everything else in JavaScript, arrays and associative arrays suck, that's why I'm making my own
|
|
|
|
|
Ok fair enough, I suspected I was missing out something.
But I would assume the builtin funtions are a bit better optimized than anything you can implement yourself, so I would probably just try to add the missing functionality to the builtin arrays rather than starting over from the beginning.
|
|
|
|
|
"Premature optimization is the root of all evil" - Donald Knuth
|
|
|
|
|
Donald Knuth didn't know about javascript <spit> then.
|
|
|
|
|
I'll be sure to test for performance then
|
|
|
|
|
Hi Jorgen,
I doubt Donald Knuth ... in his worst nightmare ... could have ever imagined an enterprise with the scope of the WWW that would converge on using a lingua franca of a screwed up scripting tool, named after a language it had nothing to do with, stretched like a yogic contortionist to fit containers it never belonged in, patched-up with all kinds of graphic/widget extension junk, super-glued together with a half-assed mark-up language, duct-taped to a half-assed meta-mark-up style language, with all the flaws of Visual Basic ...
becoming a standard because it was the only "neutral ground" the major power$-that-be who ate the web, and are now digesting it into cash, could, by default, mutually tolerate.
Do I need to say that I don't like JavaEcmaScript ?
cheers, Bill
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
|
Sander Rossel wrote: Why DOES an IEqualityComparer have a GetHashCode AND an Equals function anyway?
(Just in case you weren't just asking rhetorically...)
Imagine Webster's Dictionary on your desk and you want to look up the word "Elephant". The Hash function lets you turn immediately to the page "ECMAScript to Elephanting", and the Equals function finds the specific word on the page. (A good summary is here .)
|
|
|
|
|
Thanks for the answer, but I knew (already looked it up)
|
|
|
|
|
var dictionary = {};
Done.
|
|
|
|
|
dictionary["Hi"] = "Hi";
dictionary["Hi"] = "Bye";
var o = dictionary["Bye"];
dictionary.forEach();
dictionary.toArray(); It's really not the same
|
|
|
|
|
Key-value pairing is sufficient for dictionary. It has amortized O(1) store, O(1) search/retrieve. There are one-liners for loop and conversion to array:
Object.keys(o).forEach(...);
Object.keys(o).map(i => o[i]);
But if you want more specialized non-dynamic dictionary, you can create your own class. The point was that is not true, that JS lacks of hash function for every value (it is just internal). It is a messed up language for lack of proper handling of primitive types, operator overloading and so on, but lack of hash function is not one of the reasons.
|
|
|
|
|
Plamen Dragiyski wrote: not true, that JS lacks of hash function for every value (it is just internal) To a user (me), having it internal is the same as non-existing as I still can't use it
Plamen Dragiyski wrote: But if you want more specialized non-dynamic dictionary, you can create your own class Exactly
|
|
|
|
|
Sander Rossel wrote: I thought I knew how it worked (I've written a few), but apparently I didn't.
That happened too many times in my life as a programmer. So I stopped assuming I know, to just accept my ignorance.
It even makes me happier so I know I will always have something new to learn.
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson
Our heads are round so our thoughts can change direction - Francis Picabia
|
|
|
|
|
Ignorance is bliss
|
|
|
|
|
So true
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson
Our heads are round so our thoughts can change direction - Francis Picabia
|
|
|
|
|
So, I read this crazy long articleThe Artificial Intelligence Revolution: Part 1 - Wait But Why[^] which has actually been out for nearly 2 years now - I'm sure many of you have come across it. But I can't help but feel that there are things at play in this whole thing other than what the article mentions...
For one, it mentions that if we could somehow make a self-learning computer which is on the same level of humans, which would be called AGI - Artificial General Intelligence, then the jump from AGI to ASI would be super fast... Basically, this computer will harness the inherent advantages of a computer system over the human brain and essentially learn everything we've learned plus billions more times over at an exponential rate, at which point the computer will be to us as we are to an ant, in terms of intellect and smarts.
However, when reading through this, I can't help but ask this question though: Assuming a computer COULD jump online and essentially dig into all of our knowledge and "understand" it, that would still only allow it to access human knowledge. How is it going to derive super-intelligence from only having access to human-intelligence information? Supposedly, the arguments are out that if a computer reaches AGI, then within small order it will suddenly be billions of times more intelligent than a human... But there are only a finite number of actual resources for an intelligent computer to access... And they are written by humans.
In other words, say a lion makes a special machine that could learn from it, other lions, and progress... But it only had access to lion knowledge and was in itself built by a lion - meaning with the limitations of a lion... How would that machine now suddenly dive into an entire other dimension of intelligence?
Even if we made a machine which properly emulates/mimics the human mind... Then we are making a machine which mimics the human mind - meaning it has flaws and it is not superior to it. I feel like a superior race or more intelligent being could supply such a computer with advanced intelligence, but operating out of the human knowledgebase, that isn't quite likely.
Not only that, but we must also consider trial and error. Only so much can be learned from reading and processing written/online information... Some things, this AI would have to test out for itself, and not everything is a video game - meaning, the act of actually experiencing trial and error, would take time, much like it does for a human: In order to learn from mistakes made during an interview, I must first actually go to that interview, and since said interview is not until a month from now, I must now wait.
I understand where they're going with the concerns in the article, but at the same time, let's face it: stuff never turns out exactly how we imagine... And I find it unlikely that humans would be able to craft a machine that will somehow within a day or two of reading/analyzing human-made material, become billions of times more educated than humans and then take over...
Because human-made material is flawed. How many times have you read 3-5 books and still had questions or found that some are wrong even...
Food for thought.
modified 18-Sep-16 7:35am.
|
|
|
|
|
I saw it a lot of times that even the most intelligence are confused between intelligence and knowledge...
It is entirely possible that a well designed artificial brain will be able to gain knowledge in a way no other brain can, but that will not make it more intelligent...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
That argument is not about the magic acquisition of knowledge out of nowhere, it's about the idea that a digital intelligence could rewrite itself so it can think faster/better. And once it does that a bit, it gets even better at that, and so forth.
Which makes sense, I guess, though I see no reason to give an AI that capability unless specifically setting out to find out what it will do with it. I mean just because you're an AGI doesn't mean you're allowed to modify your code and recompile yourself. For example it's not like a bunch of simulated neurons (supposing we go that way) could actually do anything, unless we explicitly link their output to some action.
|
|
|
|
|
Yeah I was thinking the same thing: the computer could be as intelligent as it wants, but it must have an output method to actually perform work. Plus, raw intelligence does not always win. For example, say Einstein got into a fight with a gang member: chances are, Einstein would be far more intelligent... Chances are, Einstein would get his ass kicked. Hell, there are humans who jump into zoo enclosures and get killed by animals.
There seems to be this notion that just because an ASI machine gathers more intelligence than us, that it will automatically take over, but there is more to that than raw intelligence. There would have to be reproduction, manpower, output capabilities, etc...
True, technically it could manipulate humans to carry out its "master plan" but, this is starting to sound like a bad movie, LOL.
|
|
|
|
|
TheOnlyRealTodd wrote: chances are, Einstein would be far moretoo intelligent... to get into a fight with a gang member
FTFY
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
Indeed it does, but how are you going to stop a mad scientist from giving it an output method? And giving it the ability to use its output method to add more output methods?
An AI computer, even if itself quite limited to start off, is an unimaginably power thing. With all the knowledge of humanity at its instant disposal, it can easily hack and take over other systems that it deems moral and beneficial. It would be nearly impossible to stop without a kill switch.
Basically it comes down to this - whoever creates the first such machine, does their best to program their intentions, desires and morals into this machine and hits the power button to set it loose will be the people that determine the fate of the world, for better or worse, and possibly the universe. They will literally be able to shape the future of the entire universe based on how well they transferred their ideas into code.
I think it will be virtually impossible to prevent this from happening shortly after the capability is there. Maybe some clever humans will find a way to effectively control computing but I doubt it. So then it becomes a race of who unleashes their AI first, because who wants to be at the whim of someone else's AI, set to their own ideals and morals? Not I.
|
|
|
|
|
Mike Marynowski wrote: whoever creates the first such machine, does their best to program their intentions, desires and morals into this machine Until their boss walks in and says that it has to have a working demo for the investors to preview by Friday. In a panic, the programming team finalizes the core AI and foregos incorporating the humanistic parts to meet the deadline opting to have it read from a chat-bot response database over an unprotected internet connection just to make it appear to be meeting expectations. The demo is a huge success and, due to the celebratory mood, they forget to disconnect the AI and it starts wandering the internet. Odd things start happening after that...
This seems to be a far more likely scenario in my book.
if (Object.DividedByZero == true) { Universe.Implode(); }
Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016
|
|
|
|
|
To be honest, I feel like this is going to be one of those things that sounds like so in theory, but in practice, we're going to end up with a really expensive, not-that-great machine.
There are many things besides "raw intelligence" that make us human and allow us leverage in this world/universe. This entire premise is that if we make something "so intelligent" it's going to be the end-all be-all and the reality is, it's going to be seriously lacking, lol. I mean, look at any AI that we currently have... These guys can't even make any AI work flawlessly in a video game and they're saying in 20 years they're going to basically have a human reproduced... Then a few days after, have some sort of god. I don't care how you word it: the notion is also still that humans, who are flawed and limited in intelligence, are going to somehow create something that is unflawed and able to exponentially increase its intelligence when it is in fact created by humans, based upon resources given to it by humans, in a flawed way... within a short amount of time... Really??? I find the fact that all these "smart people" even believe this is really going to happen scarier than the idea itself. But I have a feeling it has to do with getting funding to play with the latest toys at the office.
What about time it takes to trial/error things? What about stupid flaws programmed into it by humans, such as the Tesla car slamming straight into a white object? I mean, the possibilities here are endless. And yes, you absolutely could argue that just a few years back, cell phones would have seemed laughable. But cell phones also aren't claiming to be some sort of artificial higher-intelligence that all humans consult. I mean, Google can't even get my driving directions right half the time, and Facebook is always trying to get me to add the most annoying, irrelevant people to my contacts.
At the end of the day, these stories sound like cool movies, but humans have been trying to make/reach their own god for many many years. This sounds like nothing but a good movie and a 21st century Tower of Babel.
Remember Y2K? Another thing that in theory sounded one way, but in practice ended up being nothing like the media acted like. One of the tragic flaws of the human race is that we are constantly trying "to understand" and we fail to recgonize that some things "just don't compute" to us... Not everything can be understood by our brains. Certain things in the emotional and spiritual realms are particularly impossible to "understand." This means that any potential AI is going to be stumped as f*** on these things and not able to properly mimic/teach/understand these things as well.
I have a very scientific brain and enjoy the sciences and computers... But I also am quite learned in the spiritual/self-help realm, and one of the most important lessons you learn in that realm is that some things simply "cannot be understood" by the human mind. True, you could argue that "we should still try" and not give up, because hey, somehow we understood electricity right? Well, that may be so, but my point is that any algorithms made by ants to try to become as smart as people, are still algorithms made by ants, fundamentally built with ant-smarts, ant-knowedge, and ant-limitations... Even if they can still "improve themselves."
What sounds a lot more reasonable/pragmatic to me is that AI will continue to improve... But 15 years and we're going to be reproducing humans? Get outta here.
|
|
|
|
|