Open Side Menu Go to the Top

12-04-2017 , 12:24 PM
If you are using a language with first class functions, you can likely have:

Code:
new_list = map((f x), (filter cond old_list))
# not a real programming language
I often prefer to go with a more declarative style, but it depends.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
12-04-2017 , 01:24 PM
That effectively iterates twice though, right? I think he was asking if there was a solution that is both clear and iterates once.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-04-2017 , 02:13 PM
You’re effectively doing two things to list though so until you have performance problems trying to do those separate things in the same method seems like premature optimization.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-04-2017 , 02:23 PM
Quote:
Originally Posted by saw7988
That effectively iterates twice though, right? I think he was asking if there was a solution that is both clear and iterates once.
It depends. It's still O(n) with worst-case 2x space. If your programming language has delayed evaluation, then the compilation will optimize it appropriately.

I think that going through the list twice is faster than going through it once with if / else statements due to branching, but premature optimization.

There's no way that I can think of that isn't going to have some sort of cost associated with it. Reducing the space with filter is already going to give a benefit, so I'd do that before operating on each element.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-04-2017 , 04:03 PM
Quote:
Originally Posted by ChrisV
Got a really general coding question. This question may garner responses of "LOLCHRISV", not too sure, but here goes:

Lets say I have a list of thingies that I want to iterate over in a method. The method builds some return value while iterating over them, but also, if they don't meet some criterion, I want to remove them from the list.

I never know how to handle this sort of thing because it seems like I have a dilemma. I don't really want to mutate a method parameter in a non-obvious way, that seems like bad coding style that increases the difficulty of reasoning about the code. But I don't know how else to do both things without iterating over the list twice and that seems wasteful in performance terms. Is there any good general solution for this sort of thing? Maybe iterating over the list twice isn't a big deal?
Like everyone else said, iterating twice isn't a big deal but why can't you do something like:

Code:
let filteredList = [];
let result;

originaList.forEach((k) => {
  if (isOk(k)) {
    filteredList.push(k);
    result = computeResult(result, k);
  }
});

return {
  filteredList,
  result
};
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-04-2017 , 08:11 PM


4chan
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-04-2017 , 09:34 PM
Quote:
Originally Posted by candybar
Like everyone else said, iterating twice isn't a big deal but why can't you do something like:
I can but it would be an abomination in Java (like most things). I can't create an anonymous type like that, I'd have to explicitly create a type that contained the list and the result, which is pretty unclear code imo.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-04-2017 , 10:21 PM
Had a web interview today with a serious company.

The good news is I nailed every react/redux question, but they also asked me backend stuff and performance stuff which I was super rusty on.

At first I felt like it didn't go so great, but in retrospect I literally was 100% on react/redux and that's 90% of the role so maybe I did better than I think.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-04-2017 , 10:43 PM
What's a web interview? I had one too for a lead UI role, 3 hours, 1 room, no breaks, 5 different sets of people, same questions over and over, completely drained at the end of this dunno why I bother. There was almost 200 people on my site though so that's cool. Referenced a bunch. Meh if I get it great but its gonna be a lot harder than my current crap which is super easy. Not sure what is better.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-04-2017 , 10:53 PM
I had Google hangout interview first but didn't want people to think that meant google.

Makes me really want the role because I wanna do full stack and not just front end
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-05-2017 , 01:37 AM
Thinking of the next language I want to learn...

Lisp / Clojure / Scheme = A ;

SQL / PostgreSQL / PL/pgSQL = A ;

(MySQL = , but it's a necessary evil)

Python = A ;

C = B- ;

Ruby = C ; I have no love for this language or any of the ecosystem.

Thinking of doing a project in NodeJS. I've had questions about one of my projects in particular, asking if NodeJS version would ever come out (can't you just use the API?). I've also been asked for an ORM to integrate with "other databases," but that's a negative.

Could also go for GoLang as I get a few calls about it, but honestly, I'm not that plussed by it. Lots of strange things with it.

Another possibility is Erlang / Elixir, but not sure about it. Really, it's between Erlang or NodeJS.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-05-2017 , 07:13 AM
Node is probably the safe bet.

Personally, I would go with golang because it feels more and more like Node isn't that great for back-ends at scale (fine for front end though), and golang has a nice K.I.S.S. vibe going for it. Maybe goofy can weigh in here.

Erlang is cool but seems too ivory-tower-y for its own good to be a serious contender for businesses.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-05-2017 , 07:38 AM
Funny (maybe intentionally), given its history as an industrial language (Ericsson).
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-05-2017 , 08:45 AM
hmmm, I might be confusing erlang with haskell
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-05-2017 , 01:19 PM
More adventures with mysql. Queries not obfuscated so I don't mess them up.

Code:
select indicator from indicators where indicator_id='458959'; 
result: cfdcb8408bb8b026ba9f5d5625f0e4c1323289a9
Takes 0.9ms
Code:
select dash_sample_id from dash_samples where sha1='cfdcb8408bb8b026ba9f5d5625f0e4c1323289a9';
result: 4669620
Takes 1.1ms
Code:
SELECT dash_sample_id from dash_samples where sha1=(select indicator from indicators where indicator_id=458959);
result: 4669620
Takes 1.8 *seconds*
explain looks fine...
Code:
1	PRIMARY	dash_samples	NULL	index	NULL	dash_samples_sha1	41	NULL	2031629	100.00	Using where; Using index
2	SUBQUERY	indicators	NULL	const	PRIMARY	PRIMARY	4	const	1	100.00	NULL
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-05-2017 , 01:26 PM
Well, I probably should have guessed. The column "indicator" is a utf8 varchar, and sha1 is obviously ascii fixed length char. WHY that makes it suck so bad, I do not know. But changing it to

Code:
SELECT dash_sample_id from dash_samples where sha1=(select cast(indicator as char) from indicators where indicator_id=458959);
brings it back down to 1ms
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-05-2017 , 01:46 PM
Quote:
Originally Posted by daveT
Thinking of the next language I want to learn...

Lisp / Clojure / Scheme = A ;

SQL / PostgreSQL / PL/pgSQL = A ;

(MySQL = , but it's a necessary evil)

Python = A ;

C = B- ;

Ruby = C ; I have no love for this language or any of the ecosystem.

Thinking of doing a project in NodeJS. I've had questions about one of my projects in particular, asking if NodeJS version would ever come out (can't you just use the API?). I've also been asked for an ORM to integrate with "other databases," but that's a negative.

Could also go for GoLang as I get a few calls about it, but honestly, I'm not that plussed by it. Lots of strange things with it.

Another possibility is Erlang / Elixir, but not sure about it. Really, it's between Erlang or NodeJS.

I'm doing my project, a multiplayer game, with phaser and node.js on cloud9. If you do something like that I can ask you for help.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-05-2017 , 02:42 PM
Quote:
Originally Posted by RustyBrooks
Well, I probably should have guessed. The column "indicator" is a utf8 varchar, and sha1 is obviously ascii fixed length char. WHY that makes it suck so bad, I do not know. But changing it to

Code:
SELECT dash_sample_id from dash_samples where sha1=(select cast(indicator as char) from indicators where indicator_id=458959);
brings it back down to 1ms
https://dev.mysql.com/doc/refman/5.7...lications.html

Please please please tune your dev database. What is going to happen when you send this to prod (which is presumably tuned)? I'm asking more about the insertions here.

Quote:
Originally Posted by microbet
I'm doing my project, a multiplayer game, with phaser and node.js on cloud9. If you do something like that I can ask you for help.
I'm leaning a bit towards NodeJS because there seems to be more work (and calls) about that tech. I may rewrite my old poker bot in it, as that takes a lot of algorithmic stuff and deals with a lot of trade-offs in design, plus it would let me "learn" the language in about a week or so.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-05-2017 , 02:48 PM
Quote:
Originally Posted by Larry Legend
I had Google hangout interview first but didn't want people to think that meant google.

Makes me really want the role because I wanna do full stack and not just front end
thought you just got a job. ready to move on already?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-05-2017 , 04:45 PM
Quote:
Originally Posted by Wolfram
hmmm, I might be confusing erlang with haskell
I am learning Haskell at the moment, for no particular reason other than that I like category theory. (I am simultaneously trying to teach myself homotopy type theory.)

Haskell has some interesting features. I suspect it will never become very mainstream, though.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-05-2017 , 04:59 PM
Quote:
Originally Posted by Victor
thought you just got a job. ready to move on already?
I've been here for 5-6 months so figured I would poke my head out a bit.

Also just seems good to practice interviewing every so often to stay fresh.

It's unlikely I end up going anywhere tho.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-05-2017 , 05:12 PM
So about 1000 people got laid off at my company. I'm sure the overwhelming majority did not volunteer for it like I did.

Anyway, there's a chat room and it's kinda hilarious/depressing. A bunch of people in their late 40s or 50s with 20+ years of service talking about stuff like someone heard you need to have 500+ linkedin connections or recruiters will think you're bad at networking. They're comparing trying to get jobs and glassdoor vs. linkedin vs. some other site I can't remember (which was deemed best of course).

Imagine that job interview. "So... you worked 37 years for one company and got laid off..."
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-05-2017 , 05:17 PM
Quote:
Originally Posted by river_tilt
I am learning Haskell at the moment, for no particular reason other than that I like category theory. (I am simultaneously trying to teach myself homotopy type theory.)

Haskell has some interesting features. I suspect it will never become very mainstream, though.
Not many Haskell jobs available. What few I've spoken to sort of prefers people with PhD level backgrounds.

They also all say they don't like the way I write code, which I take to mean they don't like secure, fast, and transaction safe.

I think Haskell programmers take themselves a little too seriously. They are sort of all the cliches one would find in the Lisp community, though Lisp programmers are tongue in cheek where I'm not sure if the Haskell community understands that or why Lispers are.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-05-2017 , 05:23 PM
Suzzer, that sucks. I suppose they were talking about Indeed? Really, none of the websites are any good. Indeed has the benefit of being more direct with the company and generally isn't a recruiter portal.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-05-2017 , 05:27 PM
Yeah it was Indeed.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

      
m