« first day (381 days earlier)      last day (3630 days later) » 

8:00 PM
> Java has no goto statement 1 . Studies illustrated that goto is (mis)used more often than not simply "because it's there".
where's the smallprint 1??
 
I figure that document got rambled up in the Sun to Oracle transitition.
 
(C) 1997!
 
And in the end Java will have most features again...
Even pointer magic is available due to sun.misc.Unsafe, it's unsafe for a reason.
 
is there no delegates in Java?
 
2
Q: Python Dictionary Black Magic

Philip WalesI am defining a subclass of a the python dictionary object mpCmd where every item is converted to a lambda. The intended usage is that every item in the dictionary can be called with a single list argument (row) that will return a value based on row. Integers and optionally strings are consider...

 
8:04 PM
Delegates like...? The term sounds familiarish, but not outright familiar.
 
what's a lambda?
 
@CaptainObvious IT'S A WITCH!
 
@Mat'sMug In what sense? I need some context there
 
well in C# when you have x => x+2; you have a delegate to a function that takes x and returns x+2. Are Java lambdas something like that?
 
New trusted user: Morwenn!
 
8:07 PM
Congrats @Morwenn!
 
@Mat'sMug In Java you have IntFunction func = x -> x + 2 (if you treat it as an int)
On func you can call int y = func.applyAsInt(5) (= 7)
Lambda implementation is a bit of magic, they are most definately not full-fledged classes in the JVM
Hmm, I can't upload my newest code yet to github as it would then reference classes that are not finished (hence not uploaded) yet...
 
wait that would be more like var DoSomething = new Func<int, int>(x => x + 2);
 
Well Java uses the left hand side to infer the type on the right hand side, sacrificing var but gaining the that you don't need to supply the new Func<int, int>
What was with the delegates then?
 
well the above Func<int,int> is the same as a private delegate int DoSomething(int foo);
 
0
Q: Php White Screen of Death

user3356613Login.php: <?php /** * Created by PhpStorm. * User: Ali * Date: 5/18/14 * Time: 11:26 AM * script ekhet sharmoooooota */ ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); include("common/top.php"); $ip = $_SERVER['REMOTE_ADDR']; $msg = ''; $username = ...

 
8:17 PM
@Mat'sMug What sorcery is that... Though some implementation is missing, right?
As I don't see the x => x + 2
 
that's the body of the function, the delegate will match any method with that signature
 
Hmpf, I still don't understand
Can you show an example using that delegate?
 
        private delegate int DoSomething(int foo);

        private void Foo(DoSomething doSomething)
        {
            var x = doSomething(42);
        }
Foo can take any method as a parameter, that takes an int and returns and int ;)
 
So you basically promote the method to a first-class object?
 
and pass it around as any other parameter, yes
 
8:23 PM
I almost got it then
I still miss the implemetnation part though
I suppose you haven't shown the call of Foo
 
        private delegate int DoSomething(int foo);

        private void Foo(DoSomething doSomething)
        {
            var x = doSomething(42);
        }

        private void Goo()
        {
            Foo(Bar);
        }

        private int Bar(int x)
        {
            return x + 2;
        }
here
 
Java isn't that powerful I'm afraid, I can go this far:
Or it might be as powerfull actually
I'll use reference types for sake of ease
    private void foo(Function<Integer, Integer> doSomething) {
        int x = doSomething.apply(42);
    }

    private void goo() {
        foo(x -> x + 2);
    }
I may have cheated a bit there...
You can't reference a method directly
You can create a method reference though
 
well I've shown the very convoluted way of doing that; basically a Function<Integer, Integer> is some kind of a delegate.
 
    private Integer doSomething(Integer foo) { } //some concrete method

    Function<Integer, Integer> doSomething = this::doSomething;
 
I hardly ever define a delegate myself, C# has Func<TResult> and Action<T> ready-to-use already
 
8:29 PM
0
Q: Sort Words TalentBuddy (Java)

user3657891I'm posting on here after being redirected from StackOverflow. I didn't know that there were separate sites for different kinds of Q&A code reviews :P Anywho, I'm currently trying to solve something from TalentBuddy: "-Your task is to write a function that sorts all the words in the string alph...

 
The only constraint to Java 8's lambdas are that you cannot dynamically use them
You can on compile time create any functional interface you wish though
With a whole bunch predefined such as C# also does
 
@Mat'sMug Delegates sound like an interface with only one available method, and no need to implement the interface in specific classes as it can be automatically detected.
 
actually I don't even think I know what a lambda really is. it has to do with delegates, but there's expressions, too... going to have to re-read that chapter in details :)
 
In Java a lambda is a concrete instantiation of a SAM (single abstract method) interface
 
@skiwi What do you mean by "dynamically use them"?
@Mat'sMug Delegates and lambdas / functional interfaces sound very similar to me.
 
8:32 PM
the xml doc says it's a "data structure that refers to a static method or to a class instance and an instance method of that class"
 
@SimonAndréForsberg You can't create a lambda taking a varargs and then on runtime check all methods of a class via reflection and use that lambda
 
@Mat'sMug In other words, a method reference.
 
very simply put, yes
 
private void foo(IntUnaryOperator func);

int x = foo(new IntUnaryOperator() {
    @Override
    public int applyAsInt(int value) {
        return value + 2;
    }
});

//vs

int y = foo(x -> x + 2);
Note that I used Function the whole time there, but it should've been an UnaryOperator strictly spoken.
Well it depends I mean
 
@skiwi lol
 
8:35 PM
@Mat'sMug The Java version of what you wrote:
	@FunctionalInterface
    private interface DoSomething {
    	int doSomething(int foo);
    }

    private void foo(DoSomething something) {
        int x = something.doSomething(42);
    }

    private void goo() {
        foo(this::bar);
    }

    private int bar(int x) {
        return x + 2;
    }
 
A Function is typed from input to output, while an UnaryOperator is typed as input to output of the same time
 
@SimonAndréForsberg makes sense.
 
@SimonAndréForsberg He's correct
 
@Mat'sMug Pretty much exactly the same.
 
The delegate statement is actually nothing less than an interface (possibly private static interface) declaration
 
8:37 PM
Exactly
 
Hey anyone,
 
it's a keyword. you just define the signature
hey
 
It seems to be just a shorter way of creating a functional interface
@FrancisVeilleux-Gaboury Hey
 
@sim F5
 
@SimonAndréForsberg It's time for you to reload the chat
 
8:37 PM
reloading chat
@Phrancis Hey
 
I wrote a bunch of indented code in Notepad to paste into CR but when I hit Ctrl-K it removed all my indentation and justified all to the left... any clue?
 
6
Q: How can I replace tabs with spaces in code?

JamalThe code in my post appears to have improper indentation, but the indentation in the editor differs. There is usually a different amount of indentation between the two, which must be so because there are tabs used in the code. I'm afraid others will assume that I'm unaware of proper indentation...

 
Merci beaucoup!
 
@Phrancis Are you using tabs or spaces? To be formatted as code on SE sites, there has to be 4 spaces added in the front. Normally, that should be fine.
 
gotta run, catch y'all later!
 
8:39 PM
I still think it's an annoying requirement :(
 
I personally have never had to use any tabs-->spaces converter
 
laters @Mat'sMug
 
I personally hit [SPACE] frantically until everything falls into place
I also carve code in stone sometimes
2
 
I tab it out in the IDE and tab it back in after that
 
8:41 PM
That was my daily bunch of commits again.
It's almost remotely up to date now...
Alright, heading off, talk to you tomorrow
 
@skiwi Good work, I myself have implemented tons of features today (at least it feels like it). I only have one ignored test right now, and that's mostly because I'm not sure what the correct behavior is. All other tests are working fine
 
Nice one over there aswell
 
@Phrancis don't hit the keys on your keyboard, especially ctrl + k
@Mat'sMug I used butterflies
 
That sucker still won't indent after replacing all tabs with " " on that website Mat'sMug posted...
 
I am going to get enthusiast on SuperUser in a couple of hours
 
8:57 PM
0
Q: Escaping the prison - finding the shortest way

Erki M.I have given an assignment where I have to escape a labyrinth. The goal is to find the shortest way. I have done some research and there seem to be two strategies to solve the problem: the Depth-first search and Breadth-first search, where the first starts at the root (Starting point in maze) and...

 
Would use the <code> tag in my post cause issues with the indents perhaps?
 
@Phrancis you don't need to use <code> if you are using 4 spaces ahead of all the code
 
@Mat'sMug Thanks :)
 
Well it's still not taking it for some reason. Oh well. The OP used a bunch of back ticks in their code, that may have something to do with it...
http://codereview.stackexchange.com/questions/48528/delivery-geolocations-query/51255#51255
 
9:21 PM
@Phrancis you should get rid of all those new lines, and aliases should be on the same line as the column or object they are attached to.
 
@Malachi good advise let me edit.
 
@Phrancis don't forget indenting FROM blocks and WHERE blocks
 
@Malachi I tried to but it wouldn't let me.
 
I have never seen this anywhere, what is this?
> WHERE START_DATE = ?
@Phrancis like that?
 
= ? means equals any value. I could also have phrased WHERE START_DATE` IS NOT NULL OR START_DATE IS NULL` maybe that would perform better, what are your thoughts?
 
9:29 PM
@Phrancis I rolled it back. MySQL is weird with those backticks, some columns if they are a reserved words need the backticks. but I don't think that we need them there
Where Start date is anything including null? why have a Where statement say that, usually a where statement is for restricting the recordset
BTW.Work
 
9:42 PM
Figured as much, thank you @Malachi. That's a good point, make any edit you feel are warranted. TBH their CASE statement seemed so bizarre and convoluted that's probably why I wrote it like that, not thinking that SELECT would implicitely return NULL if the MAX() function was applied to a NULL record.
 
I haven't done much in MySQL since school over 2 years ago
sometimes in SQL Server you have to surround a table name or a column name in []
 
I use mostly MySQL because my home computer is a Mac but I'm learning SQL Server side-by-side.
 
when they start doing weird stuff like "WHERE ColumnName = ? " that is weird
most of the time SQL is SQL, there are differences in how the different engines run and also minor differences in Syntax and sometimes big differences in what you can and can't do on the different engines
I just tried to clean up your SE Post formatting
 
0
Q: adding 2 linked lists

LiondancerThe problem I have is to find the sum of 2 linked lists. Each linked list node contains 1 digit that represents a number. My algorithm works but I was wondering if there is a more efficient (speed and memory wise) to solve this problem OR maybe some minor tweaks I can do to reduce space and runt...

 
Cool, I removed the unnecessary WHERE clauses in the SELECT
Ah - Almost TTQW can't wait.
 
9:50 PM
^^^Catchng on fast.
 
why not Multi Dimensional Arrays?
TTQW
where you live @Phrancis
 
Southern Indiana, by Louisville KY. Originally from Québec but moved here about 9 years ago. What about you?
 
South Dakota
Right in the middle
later TTGH
 
0
Q: Sorting a flattened array

SnowbodyI'm using C# in .NET 4. The class holds a 2-D array of double that's required to be flattened (business requirements). I also know the dimensions of the array. I wish to sort the array by the (virtual) first column. Obviously I have to unflatten it, at least partially, in order to do this, right?...

 
Peace
Well this has been a good day, knocked out about 4 SQL zombies, rep went from 11 to 123 and earned 7 bronze badges. I'm going to celebrate with a cold beer - TTQW!
 
10:02 PM
Later!
 
(all in between doing real job work too lol)
 
10:50 PM
0
Q: Hide menu during user inactivity with jQuery, setInterval performance

XroadI created a script to hide a menu during user inactivity and when the position of my page is left < 2. I would like to know if I use a good method regarding the performances. It's not too heavy ? Should I optimize my code ? var interval = 1; setInterval(function(){ var posx=$("#page").offs...

0
Q: MV* Organization for a board game

EasilyBaffledI am trying to make a small game, while simultaneously learn about the ever so popular model view controller. The game is this, there are 3 players(green, purple, yellow) and they have to try and build a path of arrows to the blue square. The first player to make the path go to the blue square wi...

 
11:33 PM
0
Q: Sum(), ForEach() with Lambda in a hierarchical List Collection

Nigel JoyceI have to list the number of documents related to items in a hierarchical tree. The specification states: The tree will only ever be 2 levels deep. The higher level items will list not only the number of documents in it's folder, but also the total count of documents in the child folders. Th...

 

« first day (381 days earlier)      last day (3630 days later) »