[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 325
Thread images: 33

File: haskell.png (786KB, 1000x1300px) Image search: [Google]
haskell.png
786KB, 1000x1300px
What are you working on, /g/?

Previous thread: >>60958621
>>
File: 7f79017e53065cc1a88c08face1a2095.jpg (206KB, 1024x903px) Image search: [Google]
7f79017e53065cc1a88c08face1a2095.jpg
206KB, 1024x903px
Re-writing Idris in MaD.
>>
sugoi hasukeru
>>
File: moonicon32.png (295B, 32x32px) Image search: [Google]
moonicon32.png
295B, 32x32px
>>60965940
/g/ is making a web browser >>60965920
>>
>>60965940
Rewriting trash in garbage.
>>
>>60965940
I'm gonna FUCK Haskell
>>
Haskell is garbage lol.
Have fun Iterating though a list twnty times just to get anything done.
>>
File: vehico.png (8KB, 353x168px) Image search: [Google]
vehico.png
8KB, 353x168px
Detroit has 228% more people in it, yet the vehico call only only gets called 1 more time per minute than cincinnati.
Wew.
>>
File: ARDUINO_HARDMODE(ish).jpg (82KB, 936x641px) Image search: [Google]
ARDUINO_HARDMODE(ish).jpg
82KB, 936x641px
A-Anon you program your own µc libraries r-right?
>>
>>60966032
Official statistics say 680k, and dividing numbers is easy.
I am wondering why there's a billboard near Detroit, though.
>>
>>60965960
thank you anon, i ALWAYS wanted a slower latex
>>
>>60965940
How do I write this in a non retarded way in C?

https://pastebin.com/g5GQ5pPA
>>
>>60966292
Dios mio
>>
>>60966292
>pastebin
hahahha i'm not clicking that you think i'm stupid or something????
>>
File: A simple minded person.jpg (583KB, 849x565px) Image search: [Google]
A simple minded person.jpg
583KB, 849x565px
>>60966292
C programmers are incredibly "simple minded"
>>
>>60966292
>system("pause");

kys
>>
File: 1488823411353.jpg (157KB, 884x902px) Image search: [Google]
1488823411353.jpg
157KB, 884x902px
>>60966318
>>60966324
>>60966329
>>60966370
>>
>>60966292
l = x+'0'
if(x > 57)
x += 39;

should be correct.
>>60966105
>>60966126
3/5 compromise :^)
>>
>>60966292

Well, here's a rewrite of your convert function:
char convert(int x)
{
if (x >= 0 && x <= 9) { return '0' + x; }
else if (x >= 10 && x <= 17) { return x - 10 + 'a'; }
else if (x >= 18 && x <= 36) { return x - 11 + 'a'; }
else return '\0';
}


You will note that I retain the bug you made wherein 'h' is returned for both 17 and 18.
>>
>>60966565
Lookup table would be faster.
>>
>>60966565
Use pattern matching
>>
>>60966565
You forgot the bug where l is undefined if it's not between 0 and 36
>>
>>60965960
Replacing TeX with mylisp.
>>
>>60966392
>>60966565
This assumes ascii, something that the standard does not guarantee.
>>
>>60966292
char convert(int x) {
return (x >= 0 && x <= 9) ? (x + '0') : (x + 87);
}
>>
>>60966674
>>60966565

Thank you!
>>
>>60966292
What does your function do?
>>
File: 1491611665608.png (273KB, 469x480px) Image search: [Google]
1491611665608.png
273KB, 469x480px
give me algorithm problems
>>
>>60966673
Most C programs would be fundamentally broken if ASCII wasn't available everywhere.
>>
>>60966674
Assumes ascii, don't do it.

>>60966730
This is false, I am aware of no program for which this holds true.
>>
>>60966727
implement a self balanced binary search tree
>>
File: rust-utf8.png (276KB, 485x723px) Image search: [Google]
rust-utf8.png
276KB, 485x723px
>>
>>60966620
Possibly.

>>60966628
This is C, not Rust.

>>60966651
Hrm... I thought there was an implicit return 0 as part of the standard, but it seems that's only the case for main. Fair enough, last return statement should be removed.

>>60966673
Anon used a system("pause"), implying that the platform will be restricted to Microsoft Windows.
>>
>>60966762
This
Rust was made by people who just wanted to be hipster and had no idea on how to properly design a language on top of mathematical foundations.
>>
>>60966798
Stop samefagging. It's embarrassing.
>>
Can someone help me out with this? In the following code block:
for z in x, y:
print(z)


What exactly is z? Is it a tuple, a list, what? type(z) just gives the type for each component x and y. But what is z's type?
>>
>>60966802
Forgot to specify that this is Python 3.6
>>
File: qtmeme.png (206KB, 2724x2200px) Image search: [Google]
qtmeme.png
206KB, 2724x2200px
>>60966292
S-sorry, if you're a beginner.
>>
File: A simple minded person.jpg (31KB, 600x399px) Image search: [Google]
A simple minded person.jpg
31KB, 600x399px
>>60966796
>Doesn't have pattern matching
As I said. C programmers are really "simple minded".
>>
>>60966401
like what language
>>
>>60966762

If you know your choice of string only contains ASCII characters, you can trivially convert to Vec<u8> and access characters in constant time. If you need more than ASCII characters, you will have to use UTF-8. The only encoding that allows for constant time access of unicode characters is UTF-32, which is quite simply not practical.
>>
>>60966801
>h-h-he made me feel bad for the time I wasted learning rust! he must be a samefag!
>>
>>60966755
>t. MIT professor
>>
>>60966854
Or just storing the unicode codes directly (21 bits)
And if you remove useless scripts it becomes even less. The \alpha things from (la)tex should have been the standard.
>>
>>60966849
some sort of events? i don't get it im too retarded
>>
>>60966827

It is not that C programmers are simple minded, it is that C is a simple language.

>>60966909

>21 bits
And then you will have values spanning word boundaries, which is time inefficient in the general case.

UTF-8 is considered one of the best encoding formats for good reason. Rust isn't being revolutionary in choosing it for the default encoding of strings, plenty of other languages do the same damn thing. If you need constant time access to unicode characters, you convert to UTF-32. If you need constant time access to ASCII characters, you convert to a vector of bytes. If you don't need arbitrary access to characters, you use iterators over UTF-8 which is the best for space utilization.
>>
>>60966755
>>60966900
i'm doing this btw
>>
File: raymarch.webm (3MB, 800x550px) Image search: [Google]
raymarch.webm
3MB, 800x550px
>>60965940

I added some simple surface displacement and bumpmapping to my raymarcher.
>>
>>60966900
I wish, that being said, in my uni we had to implement heap trees, hash tables and other similar fun stuff.

>>60967033
Good luck! Are you going with AVL, RBtrees or something else?
>>
File: A simple minded person.jpg (69KB, 1280x800px) Image search: [Google]
A simple minded person.jpg
69KB, 1280x800px
>>60966966
>it is that C is a simple language.
Designed for "simple minded people"
>>
>>60966909
>Or just storing the unicode codes directly (21 bits)
Which would still work out to 32 bits per code unit, under normal padding and alignment rules. You could theoretically pack it down to 24 bits (or 21, if packing across byte boundaries), but you'd have to unpack it again to do indexing, so it's pointless.
>>
>>60967308
>byte
my byte size is 21 bits, fight me
>>
>>60967268
Wrong. Making complex things out of simple parts takes much more effort and skill than making complex things out of complex parts. A "simple minded person" would think the following code is perfectly reasonable:
char *s1 = "foo";
char *s2 = "bar";
printf(s1 + s2);
>>
>>60967323
Let me guess, you're middle-endian as well?
>>
>>60965940
>>60965966
>>60965980
Since I've basically cheated my way through Haskell without learning monads by solving project Euler problems instead of real world situations, I decided to take the dude's challenge from a few days ago and actually list a directory's files with sizes.

fileSizes :: FilePath -> IO [(FilePath,FileOffset)]
fileSizes path = do
ls <- listDirectory path
files <- filterM doesFileExist
$ map (path </>) ls
sizes <- mapM getFileSize files
return $ zip files sizes

getFileSize :: FilePath -> IO FileOffset
getFileSize path =
getFileStatus path >>= return . fileSize

Learned a lot in the process.

>>60966007
That's not how it works...
>>
>>60967338
>A "simple minded person" would think the following code is perfectly reasonable:
Of course they will, however a normal human being with active brain would find that disgusting.

let (a, b) = ("abc", "def");
print!("{}{}", a, b);
>>
>>60967070
AVL. so far i've got heights updating correctly and adding functional. gotta go to bed bc i have to lift tomorrow morning. nite
>>
>>60967440
>let (a, b) = ("abc", "def");
This is pretty nice actually.
>>
File: wow-slob.jpg (47KB, 512x384px) Image search: [Google]
wow-slob.jpg
47KB, 512x384px
/dpt/ what to program to distract myself from misery and self loathing?
pic related: me, except unlike this man i'm agonizingly aware this is what i am and the only reason i make no effort to improve my life is because i'm sick and tired of making an effort at things in general
can software help something like me /dpt/? or should i go for the suicide
>>
>>60967573

Get into programming real-time computer graphics!
>>
is MATLAB difficult to learn if you know Python?
>>
>>60967573
Starve yourself and become a trap
>>
File: r_u_srs.png (147KB, 1053x637px) Image search: [Google]
r_u_srs.png
147KB, 1053x637px
>>60966292
the horror
>>
>>60967653
Matlab is for people that can't program that still want to program.
>>
>>60967677
So is Python.
>>
>>60967573
>whine whine whine
>"durrr i'm such a fat piece of shit"
You do realize the harder you think this about yourself, the longer it will stay true, right?
Believing you're a disgusting slob is an unspeakable kind of pain. You probably are one, but even disgusting slobs don't deserve to believe they're disgusting slobs. That's too much grief to saddle anyone with, it's suffocating, and it keeps you stagnant.
You have two options as far as I can tell:
1) Write another fizzbuzz and drown your sorrows in another cheeseburger, you fat fuck. Then remember them tomorrow and start over again.
2) Practice pretending you're not what you are. If you practice hard enough, maybe one day you'll feel enough like something worth exercising for to actually get up and exercise.
You sicken me.
>>
>>60967686

ebin
>>
>>60967686
oh fugggg :---DDD
>>
>>60967440
don't respond to heretics
>>
>>60967686
I agree but Matlab is even easier than python
>>
76th for go
>>
Looking to further my career in embedded systems, any programming languages you guys would recommend picking up to do so?
>>
>>60967787
C O B O L
>>
>>60967787
You can't be fucking serious, there's literally zero probability this isn't another Rust versus C++ troll
>>
>>6096778
is there embedded work outside of C/Python?
>>
>>60967787
Golang is probably your best choice
>>
>>60967828
>Embedded
>Python
Nani?!
>>
>>60967828
>embedded
>python
>>
>>60967828
kek
>>
>>60967832
>wanting to work at google
>>
I have 'kind of' learned a bit of java, c# and python, but very superficial. I want to actually learn programming this time, I have gone through those "programming logic" and was wondering, is it even worth going through SICP anymore or should I just go with Programming Principles and Practice Using C++?
>>
>>60967902
>Python is fine for embedded stuff.
In what fucking world?
>>
>>60967902
The Python runtime is like 2 MB. Embedded environments don't always have that kind of space to spare. A particularly bloated C runtime is like a quarter of that.
>>
File: DCIksnCVwAAPl90.jpg (668KB, 4096x2919px) Image search: [Google]
DCIksnCVwAAPl90.jpg
668KB, 4096x2919px
>>60967573
make tools for mobile/pc games
>>
>>60966802
x, y is treated as a list of lists, so z is a list within that list.
>>
/dpt/ on a scale of 1-10 how gay is it to want to make an action adventure vidya whose artistic message is "dear player, please don't kill yourself, i know i'm just a video game but i love you"?
>>
>>60968260

Sounds like Nier.
>>
>>60968260
Pretty gay
>>
>>60968260

has been done/10
>>
>>60968280
You mean automata right?
Cause the original nier's message is pretty fucking depressing.
>>
>>60968291

Yeah
>>
>>60968307
Automata's message is more like a lonely existence is suffering but with the help of others we can give meaning to our lives.
>>
>>60968395
>trap posting is /dpt/ but video games is not despite video games being written by programmers.
>>
>>60968260
sounds like undertale
>>
>>60968395
>Wanting actual tech discussions on 4chan.
Try >>>/reddit/
>>
>>60968452
>>>/trash/
>>
>this autistic manchild sperging this hard
>>
Where's the best place for a programmer to go on vacation?
>>
>>60968435

If the discussion were about playing video games, it would belong on /v/. What Anon asked was related to the creation of video games, which involves programming. Hence, it belongs either here in /dpt/, or in the /agdg/ thread on /vg/. It is important to note that this is the Daily Programming Thread, which encompasses all forms of programing, including but not limited to programming which already has a specialized thread. So even if web development and game development both have their own dedicated threads, they can still be discussed here in /dpt/.
>>
>>60968856
A chill dark room with high internet speed and easy access to traps.
>>
>>60968990
I was considering going somewhere in Texas or Arizona
>>
>>60968996
>Texas or Arizona
If you want to see unintelligent baboons you can visit your nearest zoo
>>
>>60969003
For the scenery and weather, anon
>>
File: fuck.png (66KB, 680x525px) Image search: [Google]
fuck.png
66KB, 680x525px
where's the gun
>>
>>60969006

Read the rest of the post, you fucking mong.
>>
>>60967735
I would disagree. Matlab has some unusual syntax and oddities that surprise you, albeit perhaps less so if you've never learned a programming language before. Maybe you could call it signs of age. Python has "not surprising learners" as a design characteristic (which obviously it can't be perfect at, but it does a decent job)

>>60969006
Can you fucking learn to reply to posts already, you goddamn retard? How many days has it been with you still replying using @ and copy pasting post numbers?

Learn to use the website before telling people how
>>
Markus Persson just randomly asked me what I think of him.

What do I reply back?
>>
>>60967653
Do you know linear algebra? Matlab is basically just that.

It is easy to learn for the things that are worth doing in it (basic linalg and plotting). It is very difficult to use for anything that you should not do in it (i.e. writing actual software in it, which is ALWAYS a terrible idea regardless of the situation).
>>
>>60969433

Markus Persson is a programmer.
>>
>>60969433
It was in a programming-related context though, not a vidya one.
>>
>>60969470
see >>60969391
>>
>>60969416
Tell him you used to really look up to him but these days you're kind of somber and disappointed in him. Plenty of talented people who live comfortable lives still drive themselves to be productive through self-diligence, but you don't consider him to be in that category anymore.

You'd explain it'd not a difficult trap to fall into, sure, but it disconnects his personal utility function from the rest of the world. Whether that makes his life meaningless is up to him, of course, but it sure could otherwise be meaningful to a lot of people.
>>
>>60969416
Tell him to install Gentoo.
>>
>>60969470

Not once did I mention gaming in that post, retard.
>>
>>60969608

Read the posts you are responding to, idiot. You can't just keyword search and assume that's the topic of the post.
>>
>>60966084
He said he's rewriting Ha**el in LaTeX, not the other way around.
>>
>>60966727
The traveling autist.
>>
>>60969748
The post you are referencing does not contain the quotation you ascribe to it. Your behavior is becoming increasingly erratic and uncoordinated. It has become clear that you are no longer capable of contributing to this thread in good faith.
>>
>>60966762
I agree with this, but if you wanted to support Unicode, UTF-8 is the way to go. Just saying.
>>
>>60969748

No part of my post contains that word. If you keep this shit up, you will be reported for spamming.

>>60969810

What if I told you that you could construct a vector of 8-bit unsigned integers in Rust from a string without performing any copying of buffers. And that furthermore, from this vector, you could access ASCII characters in O(1) time. Thus, you have all of the benefits of a C string when all of the characters are ASCII, but have easy to use UTF-8 strings when at least one character is Unicode. Rust literally gives you the best of both worlds.
>>
should I read code for extensive amounts of time?
>>
>>60969515
Not that I believe your story, but perhaps what I said is a little harsh. I'm still a fan of his, I guess you could say. Just a bit of venting

>>60969901
It's a skill you'll need once you work in the real world, for certain. You might as well start early, if you have the chance
>>
>>60966827
It should be a rule that if you're gonna make fun of a language or it's users, you have to post what's your favorite language, so we can tell you why it sucks.
>>
>>60969416
Hi Notch.
>>
>>60969991
>@60969881
Sorry, but you seem to be misusing this site's quoting mechanism. You have to put a “greater than” sign before the post number you want to quote, not an “at” sign.
There is a site where they do that, it's here: twitter.com
>>
>>60969976
I'm a fan of this idea. We should try to make it an informal thing here. If you can't justify your own preferences you shouldn't be discussing them

>>60969993
Keep in mind it would be a stereotypically Notch-like thing to post that, but the number of people who aren't Notch multiplied by whatever tiny probability they'd post pretending to be him dwarfs the probability of the real Notch
>>
You gus seem feisty. Maybe golang will calm you down.
>>
What's a good complementary language for C#, Perl or Python?
>>
B was a better language than C is
B-lang-chan is the best language, she's beyond fucking dead but who cares
>>
>>60970115
I bet you don't even know how to write a hello world program in it without looking it up.

Also, you can't run your hello world program on your machine even if you wrote it.
>>
looking to make a cross platform app, its not a game but more a servicing app. what tools can i use to do this? the app needs to connect to a data base and also handle money (is there a visa plugin or something?). i want to use the native ui for each platform too. also i have a modern android but the only iPhone i have is a 4s, is that an issue?
>>
>>60966762
>he thinks accessing unicode codepoints have any connection to the characters themselves
>>
>>60966841
Two I know are Elm and Haskell with Reactive Banana. I took a look at Elm and I think it's comfy for web dev, but rather for front-end. Also, I don't into web dev so I'm not that sure.
>>
>>60969976
What if the language I'm making fun of is my favorite language?
>>
For a relatively experienced programmer who's a novice at Haskell, what's a good project to learn proper use of monads, type declarations, and other higher level concepts? Like a game or something

>>60970441
Well then your complaints better have a really high standard
>>
>>60970441
Say that, there is no shame in it.
>>
>>60970452
LISP interpreter
>>
>>60966730
>most programs deal with text on opaque binary basis
>somehow breaking due to encoding

0/10
>>
>>60970976
No need to bum, this is a daily thread. If it 404s, someone will post a new thread.
>>
>>60971048
no thread left behind
>>
>>60966762
>2017
>not understanding character encodings

god damn it dpt.
>>
>>60966818
Is this supposed to be bad? I can easily see something like that being generated by a too--

>system("pause")

yeah
>>
>>60971073
What about
char a, b, c, d, e /* ... */;

and then not really needing more than one variable?
And the 100+ return statements that could be merged into one if they were put outside the ifs?
>>
>>60971087
Dude nobody actually cares how bad generated code looks. The compiler deals with it just as well. If those 500 return statements made the tool easier to write/maintain, it'd be no big deal.

What really killed me a little inside is the notion that some retard wrote that
>>
>>60970566
Hm, I think I might do that. Thanks
>>
>>60971105
>If those 500 return statements made the tool easier to write/maintain, it'd be no big deal.
That's the thing, it doesn't make it any easier to write or to maintain.
That system("pause"); thing is what Winbabies do so that when they run their program, the terminal doesn't quit instantly after the program terminates.
It would be easier to just do getchar() or something.
>>
is it more important to write readable code or efficient code?
>>
>>60971271
If you really need to ask that question then maybe you shouldn't be here.
>>
>>60971271
Depends. If you can't write readable code in python, you need to KYS. Then there is shit like COBOL where it is impossible to write readable or efficient code unless you are some grand wizard or something.
>>
>>60971271
>>60971271
For yourself?
>Efficiency always
For others and/or large projects?
>Readability always even if it costs efficiency

There's lots of other shit to consider, like maintainability, will your project be a one time use or dealing with something that will not change then efficiency could be used otherwise for the sake of maintenance, readability.
>>
Is there a way to calculate the real metric size of entities in a .dxf file?
All of my entities are between X=1.6-1.8 and Y= 1.6-1.7 when they're actually supposed to sit at the origin and span about 2x1.5 meters.
>>
I don't understand.
If I get int values as the RGB colors, then what for do we use double/float as a number to multiply it by?
As an example, we have luminocity:
A technique to create colors which are weighted to create pleasant visuals for the sensitive human eyes.
0.2126*red
0.7152*green
0.0722*blue
=1 (the resulting luminescence to be easily appreciated by the human eyes) *rgb
Why is it so, that the float/double numbers are needed if rgb is an int value?
>>
>>60971377
Because images are stored as 8 bit or 16 bit and if you just use int to multiple, you run the risk of an overflow.
>>
>>60971400

Hmm, I see.
Thanks for clarifying
>>
>>60971271

While you should always write readable code, you should never sacrifice efficiency for readability. If the algorithm used to make your code more efficient is confusing, then document how it works. Don't just go ahead and use a less efficient algorithm. If I see a sort procedure that uses Bubble Sort as an algorithm, I'll be able to tell how it works and what it does a lot faster than if I were to see Intro Sort or Tim Sort, but that doesn't mean that Bubble Sort is ever okay to use.
>>
>>60971576 (girl)
>>
>>60971271
But Anon, these things are not mutually exclusive.
>>
>>60971271
Sometimes performance isn't a concern. Then it's readable code that takes priority (though people fail at that without any type of constraint all the time).

But regardless high performance code isn't hard to read most of the time because programmers who do high performance code are experienced programmers who know how to write good api. So their internals may be complex, but it's often readable given the situation.
Ignoring C++ and oop situations. C++ can be made impossible to read because the people that use it may think using C++ features to achieve their goals is a good idea. While they sacrifice so much. Happens regardless of level of programmer.
OOP (in the most loose sense of the word) can be fast but it's also a mess.
>>
>>60966292
Start of by putting all the number and letter strings 0-9, A-Z in an array and then let x be the index of that array. l = array[x]

There, now you've just removed 200 lines of code
>>
File: jWWPolf.jpg (138KB, 702x768px) Image search: [Google]
jWWPolf.jpg
138KB, 702x768px
>>60971576
>While you should always write readable code, you should never sacrifice efficiency for readability.

Programs must be written for people to read, and only incidentally for machines to execute.
>>
>>60971727
Documentation must be written for people to read, programs should be written for machines to execute.
>>
>>60971751
No, a computer language is not just a way of getting a computer to perform operations but firstly a novel formal medium for expressing ideas about methodology.
>>
>>60971727

You misinterpret me. I am not saying to write unreadable code, I am saying that if the efficient solution is unreadable, you should find a way to make it readable, rather than to use a less efficient solution.
>>
>>60965940

What is the best language and why is it JavaScript?


[...Array(3).keys()]
.map(x => 'v' + x)
.forEach((x,i) => eval(x + '=' + i + ';'));

console.log(v0, v1, v2);



Based JavaScript, why u so based?
>>
Reminder that there are people ITT who kode without wearing programming socks.
>>
Can anyone help me with this shit language called Java.

I want to use Map to return a new arraylist, however Map in Java returns nothing.

[Code] ArrayList<Statement> r = statements.stream().map(s -> s.eval()); [/code]

My god I hate this language.
>>
>>60971961

I'm retarded for messing up the code tags.

ArrayList<Statement> r = statements.stream().map(s -> s.eval());
>>
In C++, in what situation would this be used?


ing GetFactorial(int number)
{
int sum;
if(number == 1) sum = 1;
else sum = GetFactorial(number - 1) * number);
return sum;
}

>>
>>60971999
In the situation that you don't want your code to compile
>>
>>60971961
You need to collect the elements in that stream into a list with the .collect() method. Collectors class has some collectors that you can use.
>>
>>60972009
Sick burn /b/ro
>>
>>60972039
Thanks.
>>
>>60972040
>awful implementation of awful implementation in awful language
>even named awfully

>is so awful at mathematics that she doesn't understand what the use of factorial is
>>
>4 projects and 5 finals in the next 15 days
i-it's fine i-im fine
>>
>>60971999
>GetFactorial
>sum
Why are C++ developers so fucking dumb? jesus christ!
>>
>>60972086
>>60972068

>asking for knowledge
>"lol you're retarded"
>>
>>60972134
Don't forget that /dpt/ is a Designated Pajeet Thread.
>>
https://github.com/Quasilyte/goism

goism is Emacs package that makes it possible to use Go programming language instead of Emacs Lisp inside Emacs.

>goism
>>
>>60972134
>asking when someone would use a ghastly bit of code that calculates a basic mathematical function whose use is well known to anyone with wikipedia
I guess that is asking for knowledge in the same way that asking how to wipe your botty is.
>>
>>60971999
Is this more efficient than a for loop?
Seems convoluted from my brain's standpoint
>>
>>60972184
Factorial is a good example for learning algorithms because it can show the power of an algorithm from a naive implementation to dynamic programming. It has nothing to do with C++ or any other language. If you're a pajeet, you're a pajeet regardless to writing it in C or Haskell or any other language you're memeing here.
>>
>>60972134
>asking for knowledge
No, you were demanding knowledge.
>>
I decided to run valgrind on my program to check if there any serious leaks.

it reports some amount of bytes lost, only 24 of which are direct and rest indirect. Strangely, it's a new statment something like
new std::vector<std::vector<thing *> > > *vv = std::vector<std::vector<thing *> > >();


Where vv is just a stack variable, It doesn't have anything assigned to it until that line. I later resize those vectors and the reported indirectly lost bytes change in amount according to the resizing.
>>
>>60972263
His only mistake was to ask anything in a /dpt/, Designated Pajeet Thread. People here are memeing languages instead of doing engineering.
>>
>>60972276
Forgot the "new" keyword there.
>>
File: 02_penis-sizes.w1200.h630.jpg (147KB, 1024x537px) Image search: [Google]
02_penis-sizes.w1200.h630.jpg
147KB, 1024x537px
Why would one prefix pointers with "p" if the rest doesn't follow hung notation?
>>
>What are you working on, /g/?

a complete general purpose programming language for the sole purpose of making a very bad pun with its name
>>
>>60972302
what the fuck? I thought I was quite a bit under average, yes, but I also thought the average was 12cm... cock
>>
>>60972313
fellow țigan?
>>
>>60972305
Because engineering is about building mathematical models, not about C. You can integrate with operation amplifiers built on capacitors, it doesn't matter as long as you have a proper model.

Any programming language is a computational model, a syntax sugar for a typed lambda calculus, boolean algebra and set theory and other algebras.

All you do here is exchanging pajeet tricks and memeing one languages above others, that's why /dpt/ is not about programming but about shitting on streets.
>>
>>60971999
Never. I think it's the worst factorial I've ever seen, it won't even compile and it wouldn't work for 0 even if you corrected that 'ing'.
>>
>>60972259
not exactly sure what your point is here
hello world is a good example of a basic program but asking in what situation it can be used is a bit daft. it has no uses beyond being a demonstration of a basic program.
>>
>>60972079
I hate it but it's such a rush trying to complete everything while time is running out. I wonder if drugs feel this good.
>>
>>60972384
yes, you are, in fact, very smart. now please get the fuck out
>>
In Haskell, in what situation would this be used?

import Data.IORef
import Data.Function
import Data.Bool

getFactorial :: Int -> IO Int
getFactorial number = do
sum <- newIORef 1
current <- newIORef number

while ((>0) <$> readIORef current) $ do
modifyIORef sum . (*) =<< readIORef current
modifyIORef current pred

readIORef sum

while :: Monad m => m Bool -> m () -> m ()
while cond x = fix $ \r -> cond >>= bool (pure ()) (x >> r)
>>
whats the difference between these (lua)
if obj then
--code
end


if obj ~= nil then
--code
end
>>
>>60972562
we don't do lua in this thread.
>>
>>60972594
don't reply if you have nothing constructive to say
>>
>>60972562
'false' won't match the first, but will match the second.
>>
>>60972313
That's in inches, dicklet.
>>
>>60972384
why are you posting this stream of bullox at some innocent cunt?
and saying a programming language is a computational model is like saying a microchip is sillicon: utterly pointless and no one cares.

>exchanging pajeet tricks
tricks that make you a better programmer. you know how I know you'll never be a good one? because you're wanking off to abstractions like lambda calculus instead of writing actual software
>>
>get a job
>now all want to do in my free time is drink, fuck and sleep like a weak-minded pleb
>my side projects are dusty
>books are sitting at my shelf
fug ;_;
wageslaving kills all the fun in life
>>
>>60972718
can't wait 2bh, hope I get the job today
>>
>>60972546
factorial = product . enumFromTo 1
>>
File: file.png (285KB, 920x650px) Image search: [Google]
file.png
285KB, 920x650px
is this the perfect display for coding?
>>
>>60972653
fuck imperial, it's actually meters
>>
>>60972663
>a microchip is sillicon
I agree, that's just silli
>>
>>60972746
vertical is superior
>>
In powershell, in what situation would this be used?

function factorial([int]$n)
{
if($n -lt 0)
{
$res = 0
}
elseif($n -le 1)
{
$res = 1
}
else
{
$res = $n * (factorial($n - 1))
}
return $res
}

>>
>>60972743
> factorial 1.5 = 2.0
What a shit language.
>>
>>60972799
SHOULDN'T BE ENUM
>>
Not going to lie, I'm missing strong typing right now.
Danm it Lisp.
>>
>>60972792
>Powershell
>>
>>60973109
>can't into spelling
lithp*
>>
>>60972743
Meme language.
>>
>>60973140
meme opinion
>>
File: nicememe.webm (435KB, 420x300px) Image search: [Google]
nicememe.webm
435KB, 420x300px
>>60973109
>strong typing
>strong
>>
File: 2017-06-19.png (35KB, 832x293px) Image search: [Google]
2017-06-19.png
35KB, 832x293px
>>60970011
Naw, I'm just a Quora user and I saw this in my feed:
>>
In C++11, in what situation would this be used?
template<typename Creator, typename Destructor, typename... Arguments>
auto make_resource(Creator c, Destructor d, Arguments&&... args)
-> std::unique_ptr<typename std::decay<decltype(*c(std::forward<Arguments>(args)...))>::type, void(*)(typename std::decay<decltype(*c(std::forward<Arguments(args)...))>::type*)>
{
typedef std::decay<decltype(*c(std::forward<Arguments>(args)...))>::type ReturnType;
return std::unique_ptr<ReturnType, void(*)(ReturnType*)>(c(std::forward<Arguments>(args)...), d);
}
>>
>>60973218
lmao
>>
>>60973253

In C++17, with template auto, you could just be able to write my_make_unique<fclose>, which is great:

template <auto deleter, typename P>
auto my_make_unique(P* ptr)
{
struct Deleter {
void operator()(P* ptr) {
deleter(ptr);
}
};
return std::unique_ptr<P, Deleter>(ptr);
}
>>
>>60973109
Don't blame Lisp for your inadequacies.
>>
>>60973395
If wanting a decent type system is an inadequacy, I'll gladly be inadequate
>>
>>60973253
Did Satan himself write this piece of code?
>>
>>60973456
It has a complete type hierarchy + plenty of facilities to define and use types in your code, so again, don't blame Lisp for your inadequacies.
>>
What's a good way to keep code clean when you want to parse input commands?
I mean like a shell or anything with a keyword and then parameters.

I know the switch statement but it seems very unstructured.
>>
>>60973553
lookup table or switch
>>
>>60973580
>>I know the switch statement but it seems very unstructured.

What do you mean with table? An Array with linked functions or something?
>>
>>60973604
yeah, something like that.
>>
>>60973109
Fact: there is no formal distinction between weak and strong typing.
>>
>>60973553
boost::program_options
>>
>>60973654
Fact: you are weak and I am strong
>>
>>60973654
I know, Pierce, weak typing is just a strong typing with a single type.
>>
>>60973661
I think you're misinterpreting what I meant:
As the program itself, running in an endless loop, not when you launch it, like a shell.
>>
>>60973654
https://www.cs.cmu.edu/~kw/scans/hurkens95tlca.pdf
>>
>>60973694
So basically, you're making a REPL?
>>
>>60973724
Yeah, pretty much.
>>
>>60973735
(loop (print (eval (read))))

Here you go, be sure to credit me for this.
>>
>>60973745
How should I credit you in my code?
>>
>>60973755
John McCarthy, God
>>
I have a Base.dll and another User.dll that uses that Base.dll.

When compiled, I can change the contents of the header Base.dll and User.dll use in the User.dll project. Since this header contains members that are assigned data, which header files' members are used?
>>
>>60973745
didn't specify a language, besides I need to define the keywords myself, not use the language's feature.
>>
>>60973836
too late your project is lisp now
>>
>>60972327
Who do you call țigan, pula?
>>
>>60972653
Light-years it is.
>>
File: monkey2.png (429KB, 530x471px) Image search: [Google]
monkey2.png
429KB, 530x471px
I asked this in sqt thread with no response. Maybe someone here can help (even though SQL isn't strictly programming).

I have an SQL (mySQL) question.

Say I have a company table and I want to count all the companies based on a status. Companies are placed in groups (1, 2, etc)

select
c.status as description,
count(*) as companyCount
from group_companies gc
join company c on gc.company_id = c.company_id
where gc.group_id = 2
group by c.status;

This will display something like (CSV):

description, companyCount
status1, 45
status2, 56
status3, 78

and so forth.

Inside each company, is a number of products. These products exist in another table that is linked to the company table.

How do I do the join and display the data as below (CSV):

description, companyCount, productCount
status1, 45, 125
status2, 56, 235
status3, 78, 369

Any help appreciated. Still getting a hang of SQL.
>>
>>60972746
It says "gaming monitor", so I think it is bad for coding.
>>
Whatre the advantages of the different C* languages? Im learning Java atm but would like to know if i should learn one of these.
>>
>>60974024
C#: employment
>>
>>60974024
> C* languages
What did she mean by this?
>>
>>60973829
nvm figured it out
>>
Where can I learn how to write modern, best practicey C++?
>>
>>60966762
Good thing Rust has both.
>>
>>60974076
In modern books.
>>
>>60974039
I don't C the problem anon

>she
wat
>>
>>60973957
It's been a while since I used SQL, but maybe:
SELECT
c.status AS description
COUNT(*) AS companyCount
SUM(numberProducts)
FROM group_companies gc
JOIN company c ON gc.company_id = c.company_id
JOIN products p ON c.company_id = p.company_id
WHERE gc.group_id = 2
GROUP BY c.status;
>>
>>60974024
>C
Most languages allow you to call C functions quite easily. You do that for performance reasons quite often. So that's why I think programmers in general should know the language.
It's not a big language to learn so why not?
>>
>>60970160
React native
>>
>>60972594
Lua doesn't do threads anyway.
>>
>>60974286
automatic garbo
>>
>>60974104
>>60974076
In modern b̶o̶o̶k̶s̶ languages
>>
/g/ why do haskell girl(male)s make "moan ads" where they advertise themselves to potential bfs by recording themselves moaning? they say it is for "fucktional programming" in which one programs a computer by being fucked but i am skeptical???
>>
File: file.png (207KB, 1280x1024px) Image search: [Google]
file.png
207KB, 1280x1024px
I have a bit of spare time at work so I'm trying to do something useful. I've worked through some Python tutorial and now I'm trying to scrape some info off of a website to write a program that does similiar things but offline.
I'd like to know why I'm getting things like "(×&lt;%monster.hp_mult_low%&gt;)" instead of the value listed in the table. I can see the values in the source code using firefox or chrome so I'm guessing it should be available to the program, too?
Pls help
t. retard
>>
is it just me or is syntax highlighted code harder to look at
>>
>>60974320
Don't shill Haskell. >>>/trash/
>>
>>60974347
look everyone he can't read
>>
>>60974354
Mentioning the name H*skell is shilling it. Please refrain from doing so.
>>
>>60974365
Haskell
>>
File: tumblr_inline_niiamgxftd1rnnsez.png (117KB, 372x351px) Image search: [Google]
tumblr_inline_niiamgxftd1rnnsez.png
117KB, 372x351px
>>60974365
>Mentioning the name H*skell is shilling it.
look everyone he is tunnel visioned extremist garbage
>>
>>60974147
Thanks for responding.

Close I think. Except it pushes the product count to the right where the company count previously is and adds values for the product count that I assume is every product in the DB.

Had a similar problem before. Have a feeling I need to nest SELECT statements.

Feel like I am missing something very basic.
>>
>>60974411
Do I understand you right, SUM doesn't work properly, adding all products instead of products with the same group_id?
>>
>>60974467
It appears to push the amount of products into the company column and give a huge number in the product count. I'd need to do some analysis to work it out but it's definitely incorrect.

Am I meant to enter the table name in sum() or a primary id column from the product table? I know it's hard without knowing the schema.
>>
File: 1494459298153.jpg (72KB, 553x746px) Image search: [Google]
1494459298153.jpg
72KB, 553x746px
>>60974404
>tumblr_inline
>extremist
>>
>>60974535
This is strange. There must be commas between selected columns in my code. Did you put them?
>>
>>60974535
You must use column name or * in SUM()
>>
>>60973674
you are confusing weak typing with dynamic typing. and even that, you are still wrong.
>>
>Haskell project with wreq
>simple HTTP GET
>enable profiling
Guess how large the binary ends up
>>
>>60974724
>you are confusing weak typing with dynamic typing
Does it really matter if he's doing that? Both are nonexistent.
>>
>>60974587
>>60974600

Ok maybe this will make more sense in regards to what I am trying to do.

I want these two columns from this query:

select c.status, count(*)
from group_companies gc
join company c on gc.company_id = c.company_id
where gc.batch_id = 77
group by c.status;

with this column at the end, that has a relation to the company:

select count(*)
from group_companies bc
join company c on gc.company_id = c.company_id
join product d on c.company_id = d.company_id
where gc.batch_id = 77
group by c.status;

so instead of having two separate queries, it displays the counts in the row, based on the company status.

Hope this makes sense. And thank you for responding.
>>
>>60974331
pls help me /g/ ;_;
>>
>>60974755
then explain how something like python where the typing is done in the dynamic environment is non existent? are you gonna say that all python programs unreal?
>>
>>60974331
>>60974789

&lt; is < but html escaped, you can decode them with

>>> from HTMLParser import HTMLParser
>>> HTMLParser().unescape("&lt;%monster.hp_mult_high%&gt;")
u'<%monster.hp_mult_high%>'
>>
>>60974754
50 MB
>>
>>60973957
SELECT status AS description, SUM(tmp) AS productCount, COUNT(company_id) AS companyCount
FROM (
SELECT C.company_id, status, COUNT(*) AS tmp
FROM group_companies GC
LEFT JOIN company C ON GC.company_id = C.company_id
LEFT JOIN product P ON C.company_id = P.company_id
WHERE GC.batch_id = 77
GROUP BY C.company_id
)
GROUP BY status
>>
How do I do things many ok?
>>
>>60974912
90 :D
Feels like I'm using Common Lisp! haha :D
>>
>>60974950
thicc
>>
>>60974813
"typing is done in the ""dynamic environment"" is a meaningless phrase.
>>
>>60974930
by doing them not bad
>>
>>60974813
Python programmers use voice recognition instead.
>>
File: 1b2.png (72KB, 200x222px) Image search: [Google]
1b2.png
72KB, 200x222px
>>60974536
>he implies this weakens my argument
>he is this much of a dumb anime poster
>mfw
>>
>>60975024
I don't program in python because it is a gross bat.
If the bat face was gone, I would do.
But the bat face is there so it's not.
>>
>>60974950
>>60974975
don't tease lispchan for being chubby
it's not her fault you guys, she eats to forget the pain :^(
>>
>>60975035
Who are you quoting?
>>
>>60975062
ECL exists anyway, so it's really not that big a deal if you're hurting for space.
>>
File: 12659860.jpg (7KB, 186x208px) Image search: [Google]
12659860.jpg
7KB, 186x208px
I need some ideas for creating a text editor. What approach should I take? Here is my approach:
1. When asked, the program is to open a temp file in /tmp
2. As the user presses "enter", each line gets appended to the temp file

Now my problem is, if a user needs to go navigate back to a certain word in a certain line, there should be a cursor that which is able to do so.

Do I need to track my cursor?
>>
>>60975099
Yes
>>
>>60975077
Nobody uses ECl lol.
>>
>An OS written in javascript where everything is DOM
Friendly reminder that this is the future of computing
>>
Should I learn Perl if I already know C#?
>>
>>60975203
Why?
>>
>>60974877
See the screenshot of the website in the background, I'm expecting to get 480, not that reference. Do you know why that is?
>>
>>60974991
have you ever studied PLT at all? static environment is everything know before the execution. dynamic environment is everything know during execution. a programming language like C has type checking done only in the static environment due to type erasure. a programming language like python does the type checking only in the dynamic environment.
>>
>>60975188
And one day they'll realize how much they hate everything being so slow, and rather than rewriting it in C, they'll invent a computer that mechanically implements lambda calculus instead of Turing logic and uses mechanically associative and linked storage rather than serial. It will be a huge overhaul of all known computing technology and the result will look like nothing we've ever seen, but the important thing is, it'll be able to run javascript at C speeds.
A guy can dream, right?
>>
>>60975279
>implying they won't just offload everything into DA CLOUD and make your computer just a dumb terminal that needs to be connected to the internet 24/7 to just open a calculator
>>
>>60975278
>have you ever studied PLT at all?
Yes.
>type checking
When did I ever mention type checking in my posts?
>>
>>60975288
>server
>side
>graphics
>>
File: wow anon.jpg (78KB, 884x574px) Image search: [Google]
wow anon.jpg
78KB, 884x574px
>>60975290
dynamic typing; type checking done in the dynamic environment
static typing; type checking done in the static environment
gradual typing: both

>>60975290
>Yes.
then you got it all wrong. sorry.
>>
>>60971933
this is inefficient as fuck and i hope you get fired for trying to appear smarter than you are. also not a legit use case for eval. kill urself my man
>>
new thread when? :3
>>
>>60975240
Yeah these placeholders get replaced with javascript. The easiest way to get the information is to extract the data from window.js_vars.

Then you can do something like this:

>>> import json
>>> monsterdata = json.loads(js_string)
>>> monsterdata["monster"]["base_hp"]
u'2000'
>>
File: 1429667276968.png (162KB, 453x435px) Image search: [Google]
1429667276968.png
162KB, 453x435px
>>60975348
>dynamic typing; type checking done in the dynamic environment
Wrong.
>static typing; type checking done in the static environment
Also wrong.
>then you got it all wrong. sorry.
Wrong yet again. You could say I helped "invent" the field.
>>
>arguing about definitions of things again

Unless you can point to a source of authority, don't claim you're right or wrong on contested definitions of terms.
>>
>>60975421
>Unless you can point to a source of authority
Invalid argument. Please refrain from posting here.
>>
>>60975432
You're an invalid argument.
>>
File: 1493978984658.png (235KB, 700x500px) Image search: [Google]
1493978984658.png
235KB, 700x500px
>>60975453
Please shut up.
>>
>>60975363
*unzips newthread*
>>
where's you're ted talk?
https://www.youtube.com/watch?v=Fkd9TWUtFm0
>>
>>60975170
*Lisp
>>
>>60973920
You, coae
>>
>>60975501
I don't see it.
>>
>>60975557

How does he use the tablet with that in his other hand?
>>
coders roll out
>>60975777
>>60975777
>>
>>60972218
Definitely not. There's a function overhead with recursion that would cause it to be slower
>>
>>60977394
>There's a function overhead with recursion
Is C++ really that shit?
Thread posts: 325
Thread images: 33


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.