|
HappyHippo posted:But lazy evaluation...?
|
# ? Dec 28, 2016 18:48 |
|
|
# ? Jun 9, 2024 02:46 |
|
Internet Janitor posted:If there's anything conducting interviews has taught me, it's that a shocking number of people with years of development experience on their resume have an extremely tenuous grasp of how to use loops in any language. Stuff like this is likely the product of trying random perturbations until the code seemed to be doing the right thing. Amen brother.
|
# ? Dec 28, 2016 19:08 |
|
leper khan posted:lol computer engineering is circuit design and vhdl and stuff. No that's Applied Physics (Actual Masters Degree my father has.)
|
# ? Dec 28, 2016 19:46 |
|
Joda posted:Even then, wouldn't splitting your vector up into multiple vectors be preferable? Linked lists are absolute murder on the dcache. This is basically a deque, which is a common enough data structure to be in many standard libraries. Good locality in practice, appends are bounded in cost, random access and iteration have a bit more overhead than an array but are still pretty efficient. Anyway, on the broader point, don't listen to SD. Formalizing the performance of an algorithm on a specific architecture would be a worthless exercise. Even if somehow it gave you a perfect cycle count, it would necessarily assume exclusive and uninterrupted use of all resources, and so you would still have to validate optimizations on a real machine+OS, just like you do today. It is important to remember that theoretical asymptotic improvements don't always map to real performance, but they certainly can, especially when they're implemented appropriately, i.e. with the same realistic understanding of locality, branch prediction, etc. that have been brought to bear on the asymptotically-worse algorithm.
|
# ? Dec 28, 2016 19:50 |
|
Joda posted:Even then, wouldn't splitting your vector up into multiple vectors be preferable? Linked lists are absolute murder on the dcache. IIRC the thing was accessed like one time after creation, and this represented a tiny fraction of the program's running time, so just switching STL containers was a much better use of my time than rolling something fancy.
|
# ? Dec 28, 2016 19:56 |
|
HappyHippo posted:But lazy evaluation...? Actually, F# is an eagerly-evaluated functional lang, so that code is indeed doing a bunch of unnecessary checks. (Not that it matters for a compile-to-Javascript browser-based Pong, of course) HardDiskD posted:I can see that it looks like poo poo, and it might be wrong as well, but can you show a fixed version of this? I don't know functional languages. Personally, since the boolean vars are just a repetition of the possible outcomes, I would KISS and just use an if-else chain, with indentation to make it legible. And as raminasi pointed out, a discriminated union that exists only to be the return type of a single function can be dropped by writing that function as an active pattern: code:
NihilCredo fucked around with this message at 21:53 on Dec 28, 2016 |
# ? Dec 28, 2016 21:49 |
|
You could even do it with partial active patterns, which might be more readable in this case.
|
# ? Dec 29, 2016 04:37 |
|
raminasi posted:You could even do it with partial active patterns, which might be more readable in this case. Or with single-case active patterns, yeah. But I think this way is cleaner, in part because you don't have to repeat the parameters over and over for each case definition, but mostly because having only one active pattern expresses the fact that all the collision types are mutually exclusive and comprehensive.
|
# ? Dec 29, 2016 16:29 |
|
One of my peeves about F# is that your active pattern cases can be easily each split into their own function, or the compiler can confirm they're exhaustive, but never both.
|
# ? Dec 29, 2016 16:48 |
|
hackbunny posted:To top it off, font issues add that little bit of spice: Japanese fonts show the backslash character as a Yen sign. It works as a backslash in all aspects, except the user believes it's a Yen sign. I believe it's visually indistinguishable from the real Yen sign character, which must be fun to handle Just read this very cool post, time to put my anecdote in: On the balkans, our backslash character was Đ or rarely even Ž until windows 2000 (I never figured out the pattern back then, same locale produced different results in different versions of microsoft OSes, but backslashes are finally \ with a balkan locale set since then). When I had to switch to Japanese windows, way back when, I wasn't even surprised by the yen sign. In fact, all the \ in your posts show as yen signs to me in firefox on windows. Yes, fixed width fonts that come with windows replace the backslash with a yen symbol if you switch to the japanese locale, and used to be changed to other random characters, I guess back when everyone still tried to cram all text symbols into 8 bits. Now, here's the kicker. These characters seemingly don't have anything in common right? Backslash is just one character, one that's used as a fairly important thing, surely they could've ejected something less useful from ASCII (like one of those special snowflake picture characters nobody ever used anywhere) to make space in the codepage for local snowflake characters? No. They actually do have something in common: they all sit on the same keyboard key. \, ¥ and Ž sit on the same key, depending on which layout I switch to. I think that's the logic behind the seemingly random path separator changes between locales. Ok so that's one mistery solved. But what's with Đ and Ž in different DOS versions?. Well, Ž on my keyboard isn't where Đ is, but typing Ž into DOS or win9x prompt produces Đ in most versions. Ž, however, works correctly outside the command line. Yes, even on DOS. No, I don't know how, or why, or for what purpose.
|
# ? Dec 29, 2016 18:50 |
|
It's weird old DOS/Windows code page crap that stuck around in the Unicode era. Part of the reason from my understanding for the weirdness is because the backslash didn't exist before the ASCII standard was developed, and its origin was for writing out full-height logical AND and logical OR operators for ALGOL. More fun: forward slash has been a valid path separator since paths were introduced to DOS in 2.0. All the developers were UNIX guys, but backslashes were used as the default at IBM's insistence because CP/M and the CP/M-like tools used forward slashes for switches. You could pass paths with forward slashes to the DOS API and it'd be totally fine with it, but COMMAND.COM and the CP/M-like environment used forward slashes for switches and backslashes for path separators because everything had to feel like CP/M. The UX developers for DOS 2.0 then snuck in a system call and a corresponding CONFIG.SYS flag called SWITCHAR that let you set the switch character used by the option parsing API to a dash instead of a slash.
|
# ? Dec 29, 2016 19:34 |
|
https://github.com/facebooknuclide/atom-in-orbit Now you can run your web app inside a desktop app inside a web app
|
# ? Dec 29, 2016 22:16 |
|
Now? I've had a c9.io account for a few years now. Haven't done anything with it but use it for scratch space, but it's been pretty impressive for a while.
|
# ? Dec 29, 2016 22:37 |
|
Munkeymon posted:Now? That's literally completely different
|
# ? Dec 30, 2016 01:14 |
|
xtal posted:https://github.com/facebooknuclide/atom-in-orbit I'm sorely disappointed that this wasn't referring to an intel atom SoC running on a cube sat.
|
# ? Dec 30, 2016 01:21 |
|
xtal posted:That's literally completely different Is it? c9 is an in-browser IDE and this aims to bring Atom into the browser, and their fs replacement doesn't hit the real filesystem from what I can tell.
|
# ? Dec 30, 2016 03:05 |
|
necrotic posted:Is it? c9 is an in-browser IDE and this aims to bring Atom into the browser, and their fs replacement doesn't hit the real filesystem from what I can tell. c9 isn't a webapp desktopapp webapp, just a webapp
|
# ? Dec 30, 2016 09:26 |
|
xtal posted:That's literally completely different The end goal is to have an IDE running in browser tab, but saving to the local filesystem (I think? the ~almighty cloud~ is mentioned, too) instead of a remote one. The other difference being that one is going through a compatibility shim to run on a more restrictive browser and one is purpose-built. It's dumb because if you can't get to the web to just fuckin' download Electron, you can't get to this thing, either.
|
# ? Dec 30, 2016 15:15 |
|
http://nymag.com/selectall/2016/12/kid-gets-amazon-echo-dot-alexa-to-play-porn.htmlquote:Apparently, “play digger digger” is to a little redheaded kid what “No. 1 Funny Ringtones for Android Best New Annoying Comedy Parody Alerts Alarms Message Tones Tone Alert & Messages — Porn Detected! (Porno Ringtone Hot Chick Amateur Girl Calling Sexy gently caress oval office poo poo Sex Cock Pussy Anal Dildo Ringtones for Android” is to Alexa
|
# ? Dec 31, 2016 13:30 |
|
OMFG i just found this. Now anyone in the industry knows one of the standard tests you are given for a job is convert Decimal to Roman Numerals, I just came across this painful code... note that 99 = 90 (XC) + 9 (IX) XCIX rather than IC code:
|
# ? Jan 1, 2017 10:15 |
|
99 is XCIX in roman numerals since you're not supposed to have more than 2 levels of difference between letters. IC, while shorter, breaks that rule since you have 4 levels between I and C.
|
# ? Jan 1, 2017 17:34 |
|
XCIX is correct because you're not supposed to subtract a number from another that is more than ten times it. The rest of it, though... E:fb
|
# ? Jan 1, 2017 17:35 |
|
I will never understand how things like this happen. How do you (arguably) know how to write code, and not go "this is loving stupid, there has to be a better way" by the time you're at, like, case 8.
|
# ? Jan 1, 2017 17:49 |
|
Nuevo posted:I will never understand how things like this happen. It's pretty easy. You start with the table for 1 to 100, CBA to figure out the 10x rule, and just transform the CSV table into the switch with s/// modifications.
|
# ? Jan 1, 2017 17:54 |
|
IIII, XXXX, CCCC etc are acceptable and there's no roman numeral standard~~~~~~~~~~~~
|
# ? Jan 1, 2017 18:12 |
|
I sat down to write a Roman numeral thing once and looked up how to do it right and then added the first 20 numbers as unit tests and then I threw out all my code because I realized I just need the 20 first numbers and a lookup works just fine. :|
|
# ? Jan 1, 2017 18:30 |
|
Nuevo posted:I will never understand how things like this happen. They should've just gone whole hog on the lut method and thrown that all into a global const char ** table. Its how you do a ton of stuff on a weak microcontroller.
|
# ? Jan 1, 2017 19:27 |
|
Malcolm XML posted:IIII, XXXX, CCCC etc are acceptable Lisp even lets you pick: code:
|
# ? Jan 1, 2017 20:26 |
|
A reminder for either myself or my colleague to post the snack overflow post of an incorrect arabic2roman numeral function which involved bitmasking e: or was it this? http://stackoverflow.com/q/9073150 Westie fucked around with this message at 21:16 on Jan 1, 2017 |
# ? Jan 1, 2017 21:13 |
|
Weekend Bridges posted:Lisp even lets you pick: What the gently caress
|
# ? Jan 1, 2017 22:17 |
|
Westie posted:A reminder for either myself or my colleague to post the snack overflow post of an incorrect arabic2roman numeral function which involved bitmasking Yea, though I think it did pop up in this thread already. As for content - http://stackoverflow.com/questions/21448544/converting-a-roman-numeral-to-integer/21452867
|
# ? Jan 1, 2017 22:26 |
|
Westie posted:A reminder for either myself or my colleague to post the snack overflow Best Typo of the Year.
|
# ? Jan 1, 2017 22:45 |
|
Absurd Alhazred posted:Best Typo of the Year. yospos discusses Jeff Fatwood's Snack Overflow all the time
|
# ? Jan 1, 2017 22:57 |
|
JawnV6 posted:It's pretty easy. You start with the table for 1 to 100, CBA to figure out the 10x rule, and just transform the CSV table into the switch with s/// modifications. Yeah this would actually only take like a minute to code up, including the google search to get roman numerals 1-100. It's still bad but it probably didn't take long to write
|
# ? Jan 2, 2017 02:10 |
|
I wrote a program to find the longest way to express a positive integer as the sum of two Roman numbers, doing it in a 'clever' way. Then out of curiosity I tried to rewrite it in a functional language. The code was terrible, but I knew it, and it was a good learning experience. It was a bit of a shame when I thought about it a few months later and realised there was a mistake in the clever part in both versions, spent a fraction of the original time writing a brute-force version to test it, and still got accurate results instantly. IIRC, somewhat obviously in hindsight, the longest under 4000 is 3776 = MMDCCCLXXXVIII + DCCCLXXXVIII, swapping an M over for the equally-long alternative.
|
# ? Jan 2, 2017 02:38 |
|
xtal posted:What the gently caress Common Lisp's format as might as well be its own language: Wikipedia posted:
Coding wonder or horror? That's up to you.
|
# ? Jan 2, 2017 04:55 |
|
The Laplace Demon posted:Coding wonder or horror? That's up to you. That's the Common Lisp motto, right?
|
# ? Jan 2, 2017 05:19 |
|
Malcolm XML posted:IIII, XXXX, CCCC etc are acceptable and there's no roman numeral standard~~~~~~~~~~~~ Yeah, actual romans wrote numbers all sorts of ways and the rules people have made up for "roman numerals" don't really have any basis in reality.
|
# ? Jan 2, 2017 16:01 |
|
More important than what the Romans did 2000 years ago is the fact that there's basically a de facto standard for Roman numerals now, which you should probably follow if you for some dumbass reason have to write code that outputs Roman numerals. I guess I can see how a function that outputs Roman numerals could find some uses in the real world, but I'd love to see an example of production code in a non-toy app that has to take Roman numerals as input.
|
# ? Jan 2, 2017 16:40 |
|
|
# ? Jun 9, 2024 02:46 |
|
raminasi posted:That's the Common Lisp motto, right? (Defmacro wonder () (`,horror))
|
# ? Jan 2, 2017 16:45 |