« first day (986 days earlier)      last day (3969 days later) » 

3:00 PM
in jsfiddle
iirc it doesn't do that if you run whiletrue from console
 
Recursive func has killed me a number of times.
Not terminating when it should.
 
if it's not FFT or Post order in depth traversal, just use loops :P
 
@Zirak Nice
 
prntscr.com/1cf2ym <- design feedbacks please :-> // though i shamelessly stole some of it from google ;D
 
When writing a recursive function, always start with the exit strategy
 
3:04 PM
yeah the simple case where you just return
and always make sure you are not being a douche and that recursion is actually warranted
 
Recursion is always warranted
 
@Darkyen Not sure about it. It's nice
@Esailija Of course there is.
 
:-)
 
@BenjaminGruenbaum NAH
 
@Esailija Y U WRONG?
 
3:07 PM
name one reason
 
Recursion is fun(tional)
 
not a reason
 
Dammit
 
Recursion constantly pops up in algorithms and is often the cleaner way to do things.
 
programming is not for fun and games
 
3:08 PM
Then you're doing it wrong
 
Says you
 
lol
@Zirak not tail recursion... that pops up in douchey iteration forced into recursion cases
 
!!s/is not/is/
 
like recursive fibonacci or factorial
 
@Darkyen Doubtfully
@Darkyen programming is for fun and games (source)
 
3:09 PM
those are completely douchey in language with loop constructs
 
I've used tail recursion many times, especially when you have mutual recursion
 
ie> window.__proto__
 
@Darkyen That didn't make much sense. Maybe you meant: ie
@Darkyen "ReferenceError: window is not defined"
 
@Zirak Aw it was a really short game
 
The perspective levels were fun
 
3:12 PM
@Zirak because you artificially set up it that way
 
@Esailija No, because it came out of recursive reasoning
You probably could extract some tail-recursion into loops, but that'd be backwards
 
I use recursion any time I work with hierarchical data structures
 
if it's not just as easily, if not more, expressible in a loop it's not tail recursion
you expect that transformation to be automatically done in javascript
it better be anything you could easily do yourself
 
I'd rather design my algorithms so they make more sense to the programmer. Sure, you can find a parent node matching a condition in a loop, but the way we think of it, it's a recursive function
function parentMatching(el, fun) {
    if (fun(el)) return el;
    return parentMatching(el.parentNode, fun);
}
You can certainly make it a loop. But the algorithm is recursive.
 
@Loktar tinker.io/d2967/1 am I getting any closer? or further away now :P
 
3:18 PM
And I usually write recursive algorithms using recursion.
 
@Zirak whoat!? NO WAI!
 
how is that recursive algorithm, you are really pushing it
that's iterative
 
@Esailija me? yea I changed it
my old way wasn't working
 
that's why you have tail recursion - because you are expression iteration in recursion
and you have language with loops
so you should use those
only in language without loops would you write something like that
 
Recursion is often simpler than loops.
 
3:19 PM
It's more elegant.
 
yes in complicated divide and conquer algorithms
 
that is like 30 minutes of hacking around
 
not in iteration expressed as recursion
 
so the r() function is stupid yes.
 
How come? It matches the definition of recursion. The function is described as:
- Return the element if it matches, or the matching ancestor.
 
3:19 PM
You can write any recursive algorithm as an iterative algorithm, but that doesn't mean you should.
 
but the algorithm is not recursive there
it's clearly iteration expressed in recursion for douchiness
 
It can be displayed iteratively, but that doesn't mean it is
 
It looks closer @rlemon but you have some really big outliers
 
@Esailija Does the function call itself again?
 
3:21 PM
which function?
 
better?
 
And it's not for douchiness, it's for making sense algorithmically. Yes, a loop could be used, but the algorithm's description is recursive.
 
@Esailija Zirak's.
 
looks better.. but I dont understand those outliers still
the peaks should be more gradual
 
@Zirak yes it is
here's the loop
function closest( el, fn ) {
    while( el ) {
        if( fn( el ) ) {
            return el;
        }
        el = el.parentNode;
    }

}
I didn't even have to introduce a variable
 
3:23 PM
//maybe this related example (so we don't just return the argument):
function ancestryMatches(el, fun) {
    return fun(el) || ancestryMatches(el.parentNode, fun);
}
 
if you go and look at the loop I gave and go "hmm that should be written in recursion" and go ahead and do so, you are being a huge douche
 
From yours? I wouldn't make it recursive. But if I just thought about the idea, then I would write it recursively.
 
and these kind of loops expressed as recursion hit stackoverflow really easily because they are not dividing and conquering
 
Not if you have TCO
 
Not with tail optimization.
Yeah, exactly
It's a lot easier to think of an algorithm recursively.
 
3:25 PM
You see a lot of these with recursive structures. Because they're, surprise, recursive.
 
well you don't have TCO because you have loop constructs
 
No, you will have TCO, they talked about it.
 
well that's just a waste of time
 
Hello, I was curious if anybody had some awesome tutorials on manipulating CSS using Javascript? I'm hoping to practice over the weekend.
 
@ShannonStrutz elem.style.whatEverCssPropertyInCamelCase = value tada
 
3:26 PM
I have a bit of html that looks like this <div id="text_1_2"><div class="theText><p>stuff</p></div></div> and i'm trying to use jQueries .children to get at the text of the "theText" div but it returns an empty string. $("#text_1_2").children(".theText").text();
 
@Esailija How would you describe how you find the closest ancestor that matches a function?
 
@BenjaminGruenbaum oh wow, that was easy. Hm, then I guess I should be asking if anybody knows of any CSS tutorials? You know becoming framilier with it
 
with the obvious loop
I put the code above
 
No, in words, in your mind.
 
@Esailija Your description would be: while there is still an element, if the element matches the function then the result is the element, otherwise, the element is now its parent, repeat?
 
3:28 PM
why waste time thinking of it in like that when you can just write the simple expressive code as it is
 
@Esailija Because mine would be: Either it's the element if it matches the function, or it's the closest matching the function on its parent.
 
Why waste time thinking about algorithms?
Why waste time expressing your thoughts in code?
 
why not write code in english then
the loop construct is very expressive for this
 
Because English is ambiguous and lengthy
 
3:29 PM
They've all been written
 
@Esailija A lot less than recursion.
 
All natural languages are. Otherwise they'd be boring.
 
it's recursion used for the sake of using recursion
 
factorial = (n) ->
    n if n is 0 else factorial(n-1)+factorial(n-2);
How is that not expresive?
 
there is nothing hard to understand about the loop
 
3:31 PM
No, it's not. Because that's how we thought of it.
 
Some problems are just... surprise surprise... recursive in nature!
 
It's not about which is better, it's which one explained precicely our thought.
 
@Esailija The two main reasons to avoid recursion is: 1)It's expensive, 2)Bad programmers have a hard time understanding recursion
 
Also, it doesn't really matter if it solves an iterative problem, if the function calls itself, it is by definition recursive.
 
@OctavianDamiean What is an iterative problem?
 
3:32 PM
@BenjaminGruenbaum Ask him.
 
@BenjaminGruenbaum yes I'm of course aware of the actual recursive divide & conquer problems. But here is obviously just a loop converted to recursion because someone needs an ego boost or something.
 
We don't think in iterative, we think in problem solving.
 
1
Q: How should modules access data outside their scope?

JoeI run into this same problem quite often. First, I create a namespace and then add modules to this namespace. Then issue I always run into is how best to initialize the application? Naturally, each module has it's own startup procedure so should this data(not code in some cases, just a list of it...

 
@Esailija No! We did not convert anything to anything, that's what we're saying!
 
user1125394
@BenjaminGruenbaum what kind of factorial is it? I just know factorial = (n) -> n if n is 0 else n*factorial(n-1);
 
3:32 PM
@Esailija I find Zirak's version of ancestryMatches minus the usage of || over an if statement a lot more readable than yours.
That's just me.
 
We thought of it recursively, so we wrote it recursively.
 
readable or expressive?
 
If we'd have thought of it iteratively and wrote it recursively for the hell of it, then we'd be douchebags.
 
When I say readable, I mean I read it and quickly understand what it does.
 
@Esailija A recursion is just as expressive.
They're not mutually exclusive.
It can be readable and expressive.
 
3:34 PM
We always think recursively, we just have a hard time expressing ourselves. Iterative constructs help express ourselves without having to understand how code works.
@cx Oh, that's fibonacci, forgot I meant to do factorial :P
 
user1125394
ok..
 
user1125394
close to binomial law though
 
They're related :)
 
@BenjaminGruenbaum I don't think that's the majority. Majority think in "linear execution" or whatever you can call it
do a, do b, do c
 
4 mins ago, by Benjamin Gruenbaum
@Esailija The two main reasons to avoid recursion is: 1)It's expensive, 2)Bad programmers have a hard time understanding recursion
 
3:36 PM
boss: Hey, so I have a program written 20 years ago I want you to re-write because it only runs on win95
me: ok.. got the source code?
boss: no
me: ok.. know what it does?
boss: no
me: ok..
boss: Here is a sample input and output from the old program.
me: ..
 
@mikedidthis Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
So when you conjured in your mind the above closest function, you thought about the instructions it'll execute, you told yourself that it's a loop, instead of saying the simpler definition?
 
!!"Animate with jQuery" or "Animate without jQuery"
 
@eazimmerman "Animate without jQuery"
 
while element doesn't match function, traverse to parent
that's what I would think
 
3:38 PM
@eazimmerman You don't need the quotes. ;)
 
The quotes are comforting
 
Hey all
 
it's like they are hugging the text.
text likes to be hugged
 
I would not think "hmm how can I put this in recursive form and show off my lisp skills"
 
@Esailija That's not the result though, the result of the function is the element
 
3:39 PM
Neither did we. Have you listened to what we said?
 
If the element matches the selector, return it, otherwise, do the same with its parent
 
yes apparently the recursive thought is something that came first to you
 
It's not that either solution is wrong
 
@Esailija But that's what you did.
 
but this is linear iteration
 
3:40 PM
We didn't re-think anything. We thought about the requirement, and the recursion was apparent.
 
!!"Hug text" or Don't hug the text :(
 
@eazimmerman Don't hug the text :(
 
user1125394
tail recursion is not really expensive more than a loop no?
 
If we wrote it iteratively, we'd have thought "hmm how can I put this in linear form and show off my iterative skills to Esailija?"
 
if recursion is apparent for you in linear iterative problem, then I don't know what to say
 
3:40 PM
What's being linear got to do with anything?
 
@Zirak :D
 
@NagaJolokia quit changing your name
 
@NagaJolokia there is no divide and conquer I mean
like
 
@cx In supporting languages.
@Esailija You keep using that term...
 
here's the real recursive solution to reversing a string, and then a douchey recursive solution that just expresses iteration in recursion
(now give me a sec)
 
3:42 PM
sigh
 
@Shmiddty Well, I like to think of it as changing my hat. Besides, @Darkyen complained about the last one.
 
function ifor= (function for(from,to,fn){

        if(from < to){
                fn(from);
                for(from+1,to,fn);
        }
    });
 
function reverse(str) {
    if (!str) return '';
    return reverse(str.slice(1)) + str[0];
}
 
@NagaJolokia lol
 
user1125394
!!> function reverse(str) { if (!str) return ''; return reverse(str.slice(1)) + str[0];} reverse('zirak')
 
3:44 PM
It's not tail-recursion though, there's an op after the recursive call.
 
@cx "InternalError: too much recursion"
 
You didn't write the stop condition
 
user1125394
hehe
 
wonders if splitting the string character by character, pushing it into an array and then reversing the array wouldn't be cheaper
 
@cx "kariz"
 
3:44 PM
@Darkyen :-) I said I would when SO let me.
 
He wanted a recursive-solution, and that follows the recursive definition of reversing
To reverse a string, reverse the string after the first character, and add the first character.
 
yes that's exactly the douchey iterative expressed forcefully in recursion solution
 
I'd probably write reverse iteratively, that's just because I conceptually think about it as taking each character and sticking it in the n-i'th place matching it.
 
here's what I would expect if I asked for recursive solution
 
@Esailija Do you insist on not accepting that some people think differently than you?
 
3:46 PM
function revstr( str ) {
    var len = str.length;
    if( len <= 1 ) {
        return str;
    }
    var half = len /2 |0
    var left = str.substr(half);
    var right = str.substr(0, half);
    return revstr(left) + revstr(right)

}
 
@NagaJolokia It's more like changing your phone number.
 
@Esailija That's not the slightest faster and is just more complicated.
Just because you break it in half rather than consume a single character doesn't mean you have any less work
 
that's really not the point, I mean the point is divide & conquer
if there is no divide and conquer, go loop
 
That's just qsort where the pivot is always the middle?
 
unless you are in lisp
 
3:47 PM
@Shmiddty Maybe. Still got the same email and avatar though.
 
you don't have loops there
 
binary search is divide and conquer
 
@Shmiddty yes it is, so?
 
No thank you, I'll continue writing code as I think of it
 
that's probably a better example.
 
3:48 PM
Or merge sort
 
merge sort is good example because it's so simple in recursion
 
FFT is a good example too
 
but when I don't even have to define a new variable to do your stuff iterativelythen you are just being a douche for using recursion
@BenjaminGruenbaum fft is perfect too
but yes I go now :) bye
 
@Esailija The naming isn't quite right, left and right should be swapped throughout.
 
Also, it's clever because it uses maths
Well, imaginary numbers, that's the first time a CS grad sees they're useful
 
3:49 PM
@NagaJolokia probably yes
 
I'm off to dinner with my family, bye
 
it's the morning
 
@Esailija No, it's not being a douche. Either that or our brain is so douchey and filled with want to impress our fellow lispers, that we think of recursive problems recursively.
 
ie> new Date()
 
So my only hope is that you've just ignored what we said
 
3:50 PM
@BenjaminGruenbaum "2013-06-28T15:48:53.374Z"
 
Huh, that vm's time is broken
It's 7pm here
bye
 
That's GMT, not local time.
 
@John Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
evening ladies
 
@John Hi.
 
3:52 PM
puts on a blonde wig @John Hi
 
ie> "bananagram".replace(h=/./g,a => h[a]?'':h[a]=a)
 
@Shmiddty SyntaxError: Syntax error
 
eh?
 
@BadgerGirl mmm...mushrooooooms?..:p
 
lambdas not in IE11?
 
3:53 PM
How do I assign css to a div with the class(es): <div class="view view-home">
where .view has its own properties that .view-home inherits?
 
What about array comprehensions?
 
@BenjaminGruenbaum what about FFT?
 
@NagaJolokia no i laughed
because you still remember me failing and qouted it
 
0
Q: HTML Canvas: Should my app x, y values be global?

JoeI have a large file of functions. Each of these functions is responsible for drawing a particular part of the application. My app has x and y parameters that I use in the setup function to move the whole app around in order to try different placements. So, naturally, I need to use these x and y v...

0
Q: Jquery function not taking value from input

user2094139I have the following code for my application. <div class="btn-group radioButtons amountButtons" data-toggle="buttons-radio"> @if (Model.PresetValues.Count > 0){ foreach (int value in Model.PresetValues) { <button type="button" onClick="captureAmo...

 
@Darkyen Heh. Well it wasn't just you either.
 
3:56 PM
@Shannon it's an example of divide and conquer.
 
:-(
 
@BenjaminGruenbaum ahhh, Yes yes. FFT rules.
 
@BenjaminGruenbaum FFT as example of divide and conquer ? i believe there are simpler ones
ps fft is damn awesome once you understand what you are doing... otherwise...
 
It's an example, and it's not trivial
 
!!/ie [i for(i of [1,2,3])]
 
4:00 PM
ie> [i for(i of [1,2,3])]
 
Fixed! Somebody try it, please!
 
user1125394
!!c> [i for i in [1,2,3]]
 
@cx [[1,2,3]]
 
:-/
 
@established82 Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
4:05 PM
Is anyone aware of a charting lib that does charts like google analytics visitor flow?
 
@Incognito Some d3 examples showed graphs like that
 
I just came from D3's page, I didn't see anything exactly like it, maybe I missed it?
 
Something like bost.ocks.org/mike/sankey ?
 
The streamgraph is the closest I could find bl.ocks.org/mbostock/4060954
 
user1125394
@Incognito it's interactive (in js?)
 
4:08 PM
THAT is cool. Thanks @Zirak !
@cx yes.
 
You wanted impact and magnitude between nodes, right?
 
user1125394
zirak is the man
 
Another example of a Sankey: csclub.uwaterloo.ca/~n2iskand/?page_id=13
(a bit less impressive)
 
@Zirak Yeah, and tracking flow is cool too. Now I just have to source the data. 150k records aggregated into 75k individual streams.
 
ouch
 
4:10 PM
Oh, interesting, they're based on the old Napoleon map.
Sankey diagrams are a specific type of flow diagram, in which the width of the arrows is shown proportionally to the flow quantity. They are typically used to visualize energy or material or cost transfers between processes. Application They are also commonly used to visualize the energy accounts or material flow accounts on a regional or national level. Sankey diagrams put a visual emphasis on the major transfers or flows within a system. They are helpful in locating dominant contributions to an overall flow. Often, Sankey diagrams show conserved quantities within defined system bounda...
Anyway, back to the code. Cheers!
 
That looks suspiciously like a penis.
 
That's not what yo mama said last night!
:(
 
?
 
user1125394
technically there is a small chance of anyone traversing wall
 
user1125394
4:15 PM
you need the chance that molecules pass
 
to get the joke, it's a "cell wall"
 
@nderscore I didn't know peni look suspiciously.
 
hey @simonsarris coworker just downloaded your book from the kindle store
 
oh his book is out?
!!/google filetype:pdf html5 unleashed
:D
 
4:19 PM
in Room for John and Badger Girl, 36 secs ago, by John
and looking good at it too i bet :p
 
he himself said 22 July
:-/ thats ambigous @FlorianMargaine
!!/google Amazon Html5 Unleashed
 
the physical copy isnt, but the digital one is I guess
 
user1125394
 
holy jesus
 
4:23 PM
@BadgerGirl Do these kind of things happen often?
 
@Zirak Not too often.
 
Not that you're told you look good, but having random internet people be creepy on you.
 
I'm usually creepier than them.
 
ie> 'banana'
who's in control of dr. eval?
@BenjaminGruenbaum ?
 
Before I start working on it: RFC github.com/Zirak/SO-ChatBot/issues/70
Did `/inhistory` even get year support?
!!/inhistory 1989
 
4:35 PM
@Loktar ok, so i've been starting with a finite number of points - I think this is wrong? I should start with two points and splice in points as I calculate midpoints?
 
@Zirak January 2 – Prime Minister Ranasinghe Premadasa takes office as the third President of Sri Lanka
 
oh yeah
 
WTF, git runs git gc automatically after a big rebase
 
hi bestie
 
while someone doing a large rebase without his previous HEAD being saved somewhere is stupid that's kind of nasty - if someone did not back it up he'd have no way to undo the rebase ...
 
4:58 PM
Hello,
I am stucked into a problem
 
who here is good at finite?
 
When I change the JSON.
 
16 columns, 3 end 'values' to be equated from the columns, the equation of which is unknown. I'm just curious how many possible equations I can test?
 
and click the button.. the container does not get reloaded.
 

« first day (986 days earlier)      last day (3969 days later) »