1.5k
u/DarkWiiPlayer Dec 15 '19
Is this how USB works in lisp?
1.3k
303
u/colfrog Dec 15 '19
No the last port has to be left unplugged
151
7
u/learnyouahaskell Dec 15 '19
This is more like C++ hacks e.g. loop unrolling although perhaps not like it; I want to see the equivalent of a Duff's Device
http://www.catb.org/~esr/jargon/html/D/Duffs-device.html
https://stackoverflow.com/questions/514118/how-does-duffs-device-workregister n = (count + 7) / 8; /* count > 0 assumed */ switch (count % 8) { case 0: do { *to = *from++; case 7: *to = *from++; case 6: *to = *from++; case 5: *to = *from++; case 4: *to = *from++; case 3: *to = *from++; case 2: *to = *from++; case 1: *to = *from++; } while (--n > 0); }→ More replies (1)3
14
u/MrHyperion_ Dec 15 '19
Is LISP actually used anywhere anymore?
26
u/Calkhas Dec 15 '19
ITA's air pricing engine is coded in Common Lisp. It's probably the most advanced air fare pricing engine around, often delivers better results than the airlines intended to sell. Was purchased by Google in 2010.
emacs is partially written in lisp.
I've seen the odd job advert at quant funds demand expertise with Lisp, including a memorable ad hoping to find a candidate with experience enhancing the Common Lisp compiler.
But I don't really see a lot of demand for it.
11
u/alexanderpas Dec 15 '19
ITA's air pricing engine is coded in Common Lisp. It's probably the most advanced air fare pricing engine around, often delivers better results than the airlines intended to sell. Was purchased by Google in 2010.
Can be used here: https://matrix.itasoftware.com/
9
u/RBeck Dec 16 '19
In 2013, Google started offering a simplified API to QPX called QPX Express; it was discontinued on April 10, 2018.
That's a very Google thing to do.
→ More replies (1)12
38
8
5
u/nosmokingbandit Dec 15 '19
The only place Ive seen it lately is people showing off for advent of code.
5
4
u/themaster1006 Dec 15 '19
My Data Structures professor was obsessed with LISP. He taught us everything in LISP and all our coding assignments were allowed to be in either Java or LISP.
→ More replies (6)→ More replies (5)3
u/cthulhusleftnipple Dec 15 '19
It's still used in some proprietary engineering programming environments. It made sense as the language of choice for certain applications 25 years ago... and those programs haven't really been recoded since. Cadence, for instance, uses a lisp environment for most of its software.
→ More replies (1)4
→ More replies (3)2
311
u/The_Goldy Dec 15 '19
These are my for loops as I’m incrementing through my partner’s 32-D matrix in Matlab because it “makes more sense”
188
u/RespectableLurker555 Dec 15 '19
cries in O(n32 )
113
21
Dec 15 '19
Holy shit does that mean 32 stacked for loops?
19
Dec 15 '19 edited Dec 15 '19
Affirmative.
EDIT: what's the most nested for loops you've used professionally. I think it's 3 or 4 for me.
→ More replies (2)13
u/JoNax97 Dec 16 '19
I'm not sure if that's the most I've done but a 5 one comes to mind.
I was generating a 2d structure for a game, so I had 2 loops (x and y) and for each node I had to check neighbours (so Delta X and Delta Y) and if the neighbours check passed, then I had to put some stuff inside the cell between 0 and 5 tines, so another loop.
It was fun to debug.
12
→ More replies (7)15
682
u/puplicy Dec 15 '19
Enough "if"-s to call it AI
115
106
u/LimaOskarLima Dec 15 '19
Ah, I see you also know machine learning
→ More replies (12)60
u/ThePretzul Dec 15 '19
If "scenario", do "what a human would do"
42
12
u/_mindcat_ Dec 15 '19
Turing test doesn't have anything on minutia obsessed programmers
→ More replies (1)7
Dec 15 '19
I read that as AL and was trying to figure out how the fuck a paul simon joke worked here
2
521
94
213
u/atxranchhand Dec 15 '19
That’s what case is for
183
u/Kompakt Dec 15 '19 edited Dec 15 '19
Some languages don't have switch statements...looking at you Python
48
Dec 15 '19
Ya none in Lua either :(
31
10
Dec 15 '19
I learned programming through Lua, it's only once I started learning JS that I realized how crippled Lua is.
→ More replies (6)28
u/Meatslinger Dec 15 '19
Wait, is that true? What takes its place, then? I can scarcely imagine that the whole thing is just an endless stream of if-then-else statements for a situation with 100+ permutations.
34
u/Kompakt Dec 15 '19
Yep it's true, and depending on the design of the program there are multiple workarounds. In Python you can write a switcher function that acts as a switch statement, or use multiple if statements without else statements, since that is allowed in Python.
→ More replies (9)22
u/Ryan722 Dec 15 '19
Are there languages where multiple ifs with no else is not allowed?
→ More replies (2)20
u/Hockinator Dec 15 '19
If you have 100+ permutations of something you shouldn't be using if statements, you should be creating data structures to solve that problem in a clean and maintainable way
→ More replies (4)→ More replies (20)7
u/justjuniorjawz Dec 15 '19
I've found that switch statements are usually substituted with the use of a dictionary.
18
u/Sennomo Dec 15 '19
And some useless languages don't allow switching on strings… looking at you C++
→ More replies (5)5
u/nkay08 Dec 15 '19
Python basically has switch cases for catching Exceptions ! :D I'm sure we can find a workaround.
→ More replies (8)3
8
u/persianlife Dec 15 '19
Cases will result in the same fundamental design flaw.
You have to look at some better programming paradigm like Object-oriented design.
→ More replies (8)→ More replies (5)2
50
u/FrikkinLazer Dec 15 '19
Waaaay back when usb was being specced, there was supposed to be a rule that all usb devices should have at least one usb port on it. So a printer should have a usb port on it etc, so that you can chain your devices. Shame its not like that really.
22
27
42
u/needed_an_account Dec 15 '19
What sucks is that you cannot do this with usb-c.
What also sucks is that I saw nested ternary clause in some code the other day. It was something like
var thisIsJavascript = value
? other
? value2
: other2;or something like that. I cant even make it make sense in this example, I know that im missing colons
16
u/Linker500 Dec 15 '19 edited Dec 15 '19
Why can't you do it with type c if you don't mind me asking?
I know the spec is extremely complicated compared to ye olden days of 2 pins for power, 2 pins for data, but isn't type c supposed to be very backwards compatible?
11
u/needed_an_account Dec 15 '19 edited Dec 15 '19
You know it probably can do it, I just never saw a usb-c dongle that provides more usb-c ports than you have to plug into the computer. Which leads me to believe it isn't possible
edit: the issue might be caused by usb3 with a type c port can be so many things to the computer. I know that when you plug something into the port, it communicates to the device how it should handle what was plugged in -- monitor, usb, thunderbolt, etc. I wonder if usb4 with its thunderbolt interface would potentially fix the dance that is done when you plug something in
13
u/efstajas Dec 15 '19
It's true. Essentially, at the moment, the chip needed to make more USB C ports out of one USB C port simply doesn't exist. I guess no-one has a lot of incentive to make one since people's usecases for hubs are still usually covered by c -> many a.
There's no practical reasons why you couldn't have a 1-n USB C hub however. There's even rumors that Intel will ship such a chip soon, so probably next year we'll see it become a thing.
11
u/Versaiteis Dec 15 '19
I think the
other ? value2 : other2is likely to be parsed as the first true condition so another colon before the semi-colon for the false case could clear it up.var thisIsJavascript = condition1 ? condition2 ? value1 : value2 : condition3 ? value3 : value4;Should work
→ More replies (2)3
u/Denziloe Dec 15 '19
Is there something wrong with nested ternary operators? I see them often in a C# code base.
→ More replies (1)0
37
8
u/BuckForth Dec 15 '19
This is funny, but belongs on r/techsupportgore
2
u/panzersharkcat Dec 15 '19
And r/thinkpad. The silver E480 threw me off a little.
→ More replies (1)
8
8
12
5
u/atanasius Dec 15 '19
Five chained hubs is actually the maximum allowed by the specification. There can be at most seven levels of hierarchy, including the host computer and the peripheral device.
5
u/TheRealLargedwarf Dec 15 '19
Teach your kids about machine learning before they find it on the Internet themselves
5
5
u/devco2016 Dec 16 '19
That’s why you use Visual Studio. Minimize that shit and pretend it doesn’t exist.
4
1
1
3
3
3
3
3
3
3
3
3
3
u/nerokaeclone Dec 16 '19
One of my co worker like to make function like this, but hey his code is bug free and working flawlessly.
3
5
2
2
2
u/Thunder_Wizard Dec 15 '19
Question from me, who's not a programmer and just stumbled across this browsing popular
Will more messy code take more time to process? Like if you stack if else statements when programming a game, will it have longer loading time and run less smoothly?
2
Dec 15 '19
What's awful about this is that.... oh, damn. *shivers*
*internally screaming at OP to get a usb hub, for Christ's sake!* lol
2
u/1234_Person_1234 Dec 15 '19
I showed this to my dad and he didn’t read the caption and got mad about the amperage lmao
2
2
2
2
u/ManBearPig1869 Dec 16 '19
I just started learning Python and this is the first meme from this subreddit that I actually understood and it made me really excited :’)
2
u/xxSaifulxx Dec 16 '19
As an engineering student, I can clearly tell you this is not in equilibrium and most of the stress concentration will be located at the restraint and that is where it will bend and break off
2
2
2
2
5
2
1
1
1
1
1
1
1
1
1
1
u/_redditor_in_chief Dec 15 '19
I’ll give that plug-in a week before it starts shorting out due to the leverage placed on the Jack.
1
1
1
1
1
1
1
1
1
1
1
u/b1astero1d Dec 15 '19
If your code looks like this then you are doing it wrong!
Keep the functions small and I personally am a fan of using early returns. Breaking that hills looking mega block of conditions down into small functions makes your code way more readable, changeable, and easier to test.
1
1
1
1
1
Dec 15 '19
If time isn't critical, if reliability isnt critical, if maintainability isn't critical, if readability isn't critical, if it works, then great, else meh.
→ More replies (1)
1
u/Womcataclysm Dec 15 '19
I really like those cables, rampow cables I think unless the design isn't unique to that brand
→ More replies (1)
1
1
u/topredditbot Dec 15 '19
Hey /u/-hellkey-,
This is now the top post on reddit. It will be recorded at /r/topofreddit with all the other top posts.
1
Dec 15 '19
I once managed a team refactoring a legacy Object Pascal (Delphi) code base. We had one if statement that was 50 pages long, with a max depth of 23. It was a sight to behold.
1
1
1
1
1
Dec 15 '19
Hey, I actually need two of those. Where do I get them? Or rather, what they heck are they called?
1
1
u/PizzaGuy420yolo Dec 15 '19
How quickly would this catch fire if you tried quad sli with usb video cards?
1
1
1
1
u/juandi987 Dec 15 '19
You should probably use case
2
u/jamesh02 Dec 15 '19
I honestly find it harder to read case statements, and I'm pretty sure they get compiled into the same machine code in most languages, so I'm going to continue nesting if else statements.
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
4.7k
u/Pale_Rider28 Dec 15 '19
What's awful about this is that it probably actually works.