Go Back   CodingForums.com > Search Forums

Before you post, read our: Rules & Posting Guidelines

Showing results 1 to 25 of 500
Search took 5.46 seconds.
Search: Posts Made By: jkd
Forum: Ajax and Design 08-14-2009, 09:29 PM
Replies: 2
Views: 1,013
Posted By jkd
I guess I should actually answer your question...

I guess I should actually answer your question too. Using the set class:


var set = new Set();
array1.forEach(function(el) { set.add(el) });
array2.forEach(function(el) { set.add(el) });

...
Forum: Ajax and Design 08-14-2009, 06:34 PM
Replies: 2
Views: 1,013
Posted By jkd
The issue is on how you store the data in the...

The issue is on how you store the data in the array. If you store it sorted, then you can determine the presence of an element in log(n) time. Javascript objects already have the overhead of using a...
Forum: Computer Programming 07-23-2009, 12:48 AM
Replies: 10
Views: 111,623
Posted By jkd
WTF? Thread digging an ancient thread to rant...

WTF? Thread digging an ancient thread to rant about intelligence? Thread closed.
Forum: JavaScript programming 07-18-2009, 04:52 AM
Replies: 5
Views: 1,145
Posted By jkd
Still no distinction. Recall that the global...

Still no distinction. Recall that the global object (in a browser context) is window. So it is only natural that unprefixed function calls default to window, since of course, that *is* the implied...
Forum: JavaScript programming 07-18-2009, 04:45 AM
Replies: 5
Views: 3,272
Posted By jkd
Well, just multiply by 16 and round to the...

Well, just multiply by 16 and round to the nearest integer. That gives you the numerator. 16 would, of course, be the denominator.
Forum: JavaScript programming 07-16-2009, 04:48 PM
Replies: 5
Views: 1,145
Posted By jkd
If the object exists solely to package the...

If the object exists solely to package the function in as a method (no real distinction between the two in javascript), then it is wasteful. Just pass the function directly.
Forum: Geek News and Humour 05-29-2009, 11:03 PM
Replies: 4
Views: 1,417
Posted By jkd
Closed alpha I assume?

Closed alpha I assume?
Forum: Geek News and Humour 05-29-2009, 09:52 PM
Replies: 4
Views: 1,417
Posted By jkd
Why no BlackBerry support? :( Opera Mini is awful...

Why no BlackBerry support? :( Opera Mini is awful on the BlackBerry, and the default browser is just better than so-so on the 8900.
Forum: JavaScript programming 05-21-2009, 02:21 AM
Replies: 6
Views: 2,264
Posted By jkd
Consider using the below script: ...

Consider using the below script:
http://codingforums.com/showpost.php?p=789245&postcount=24

Since it takes a simple nested object structure to populate the lists, instead of returning XML you...
Forum: Other server side languages/ issues 05-16-2009, 09:07 AM
Replies: 0
Views: 777
Posted By jkd
Single instance across requests

Hello,

I'm not much of a server-side person, but my limited experience with PHP and its ilk seem to suggest that variables and functions exist on a per-request basis. E.g. I hit page.php and every...
Forum: Java and JSP 04-06-2009, 12:35 AM
Replies: 2
Views: 4,148
Posted By jkd
Still not sure why you can't use Math.pow()... of...

Still not sure why you can't use Math.pow()... of course, you could always do Math.exp(y*Math.log(x)) for x^y. :-D
Forum: JavaScript programming 03-29-2009, 09:08 PM
Replies: 22
Views: 2,966
Posted By jkd
I don't know what you're testing Philip, but...

I don't know what you're testing Philip, but clearly there is approximately an order of magnitude difference in the numbers here:
http://www.jasonkarldavis.com/random/merge-bench.html
(And the...
Forum: JavaScript programming 03-29-2009, 06:20 PM
Replies: 22
Views: 2,966
Posted By jkd
And, if you're interested in how to turn that...

And, if you're interested in how to turn that into a sorting algorithm:

function mergesort(a) {
switch (a.length) {
case 0:
case 1:
return a;
default:
return...
Forum: JavaScript programming 03-29-2009, 06:13 PM
Replies: 22
Views: 2,966
Posted By jkd
The reason you are seeing this is because shift()...

The reason you are seeing this is because shift() and push() reallocate memory every-time you are using them, thus you are incurring serious algorithmic cost. Furthermore, different sorting...
Forum: JavaScript programming 03-29-2009, 03:10 PM
Replies: 22
Views: 2,966
Posted By jkd
Mergesort is first-year undergraduate computer...

Mergesort is first-year undergraduate computer science. And yes, what you posted as "bad way" was actually the algorithmically faster way of doing it! Now, you make an excellent point which is often...
Forum: JavaScript programming 03-29-2009, 12:55 AM
Replies: 22
Views: 2,966
Posted By jkd
If the initial arrays are unsorted, then split...

If the initial arrays are unsorted, then split them in smaller arrays, sort them, and merge them. ;)

The point is, this is obviously a homework assignment. The professor is hinting at what is...
Forum: JavaScript programming 03-28-2009, 08:55 PM
Replies: 22
Views: 2,966
Posted By jkd
The whole point of this is to implement a merge...

The whole point of this is to implement a merge sort, which is O(N log N), versus a naive sort, which is O(N^2).

If you have two already sorted arrays, of length M and N respectively, merging them...
Forum: DOM and JSON scripting 03-26-2009, 10:14 PM
Replies: 4
Views: 6,108
Posted By jkd
Now you're talking: var range =...

Now you're talking:

var range = window.getSelection().getRangeAt(0);
var dummy = document.createElement("span");
range.insertNode(dummy);
var box = document.getBoxObjectFor(dummy);
var x =...
Forum: JavaScript programming 03-24-2009, 07:17 PM
Replies: 8
Views: 9,983
Posted By jkd
Why don't you post the code in question and we...

Why don't you post the code in question and we can help fix the actual problem? Rendering engines can be incredibly inconsistent, but Javascript (read: not DOM) tends to be fairly consistent across...
Forum: DOM and JSON scripting 03-24-2009, 11:21 AM
Replies: 4
Views: 6,108
Posted By jkd
var range = window.getSelection().getRangeAt(0); ...

var range = window.getSelection().getRangeAt(0);
alert(range.startOffset);
Forum: Computer Programming 03-06-2009, 11:42 PM
Replies: 11
Views: 2,039
Posted By jkd
Math makes everyone a better whatever-they-are....

Math makes everyone a better whatever-they-are. It's true.
Forum: JavaScript programming 03-05-2009, 01:16 AM
Replies: 24
Views: 4,148
Posted By jkd
Try this: <html...

Try this:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Polycombo</title>
<script type="text/javascript">


// polycombo, by Jason Davis, www.jasonkarldavis.com ((C)...
Forum: JavaScript programming 03-02-2009, 10:13 PM
Replies: 24
Views: 4,148
Posted By jkd
Okay, my personal website seems to be down, but...

Okay, my personal website seems to be down, but here is something I whipped together just now:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Polycombo</title>
<script...
Forum: JavaScript programming 02-26-2009, 01:13 AM
Replies: 16
Views: 2,941
Posted By jkd
Math.random() is supposed to act as though it is...

Math.random() is supposed to act as though it is distributed uniformly on (0,1). Really, [0,1], (0,1], [0,1), doesn't matter, as it is a beautiful consequence of continuous probability distributions...
Forum: Computer Programming 02-25-2009, 12:37 AM
Replies: 3
Views: 1,776
Posted By jkd
A lot of the older, interesting ones can be...

A lot of the older, interesting ones can be brute-forced nowadays, so you can get away without so much math, but they are still lots of fun. (It's a great way to learn a computer language...)
Showing results 1 to 25 of 500

 
Forum Jump

All times are GMT +1. The time now is 09:06 AM.