[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: 316
Thread images: 29

File: 14830433216172.jpg (79KB, 600x338px)
14830433216172.jpg
79KB, 600x338px
Old thread: >>58368865

What are you working on, /g/?
>>
First for bunnies
>>
>>58375309
First for D
>>
>>58375309
2nd for js
>>
nth for diversity
>>
4th for fourth
>>
>>58375344
(n + k)th for diversity
>>
Yeah, Ocaml really is the best lang.
>>
>>58375231
Thanks, this helps a lot. I tried curl in the terminal and it's a start.

Could anyone say something about security when using curl and/or wget? I'm going to learn about these, but I care a lot about encryption and wonder what I have to do to send encrypted requests/verify domains/etc.
>>
File: 1483453233544.png (818KB, 1280x719px)
1483453233544.png
818KB, 1280x719px
Functional programming.
Last /fpt/: >>58332039

Resources:
>Erlang
http://learnyousomeerlang.com/content
>>Elixir
http://chimera.labs.oreilly.com/books/1234000001642/index.html
http://elixir-lang.org/learning.html
>F#
http://fsharp.org/learn
>Haskell
https://en.wikibooks.org/wiki/Haskell
https://0x0.st/pbp.pdf
>Lisps
>>Common Lisp
http://gigamonkeys.com/book
http://www.cs.cmu.edu/~dst/LispBook/book.pdf
Paul Graham's ANSI Common Lisp
On Lisp
Common Lisp Recipes
Land of Lisp
An Introduction to Functional Programming Through Lambda Calculus
>>Clojure
http://www.braveclojure.com/foreword/
The joy of Clojure
>>Scheme
SICP
Essentials of Programming Languages
How to Design Programs:
http://www.ccs.neu.edu/home/matthias/HtDP2e/
Art of the Propagator
Little Schemer
The Seasoned Schemer
The Scheme Programming Language by Kent Dybvig
Realm of Racket
Lisp in Small Pieces
>OCaml
https://realworldocaml.org/
http://ocaml.org/learn/tutorials/
>Scala
Functional Programming in Scala (Chiusano and Bjarnason)
Atomic Scala (Eckel and Marsh)
Programming Scala (Wampler and Payne)
Programming in Scala (Odersky, Spoon and Venners)
>Web languages
>>Elm
https://guide.elm-lang.org/
>>PureScript
http://www.purescript.org/learn/
>>
>>58375353
*forth

I find it concerning that clojure examples prefer vectors above lists. Majority of power of lisps stems from the homoiconity --> syntax and prefered data type (lists) are one and same. Is clojure crippled in this regard?
>>
>>58375357
while irony == False:
print('Yeah, Ocaml really is the best lang.')
>>
>>58375357
No, it really isn't.
>>
>>58375384
Haskell is dead:

https://www.reddit.com/r/haskell/comments/5m678s/suggestion_code_of_conduct_for_haskell_community/
>>
>>58375357
G I L
I
L
>>
I have a bad habit of discovering a better solution when I'm almost finished coding a different one. I've rewritten parts of my program like five times in the last few weeks
>>
I have a program that generates a bunch of floats I want to analyze

how do I write floats to a CSV so I can open it with libreoffice calc?
>>
>>58375418
Literally not an issue, all you need to do is use multiple processes.
>>
>>58375415
upvoted
>>
>>58375425
fprintf
>>
>>58375424
Be thankful that you're at least able to come up with a better solution
>>
Can we talk about programming ITT pls? tks.
>>
>>58375415
>reddit
Opinion discarded
>>
>>58375457
haha, yeah
>>
>>58375384
>embedded general
haven't seen this since rust
>>
>>58375457
>meme response

opinion discarded
>>
>>58375431
>multiple processes.
Massive overhead.
>>
>>58375394
>Is Clojure crippled by ignoring Lisp's dogma of using binary tree for everything and using more suitable and optimized data structures instead?
I don't think so.
>>
File: kys2.jpg (67KB, 400x533px)
kys2.jpg
67KB, 400x533px
>want to make a scraper
>website is full of verification cookie buttfuck/bot detection
>>
>>58375514
HURRRRRRRRRRR
>>
>>58375503
>opinion discarded
Opinion discarded
>>
>>58375470
What did he mean by this?
>>
>>58375514
My point is that having same syntax and preferred data type eases metaprogramming a lot (since preferred data type has more operations). If clojure had syntax in form of vectors there wouldn't be much difference.

I am not asking whether vectors are better than lists, but if loss of this this consistency itself is harmful. I think we all agree that you practically only use lists for prototypes and replace them when optimizing.
>>
>>58375509
Not really.
>>
>>58375366
Anyone?
>>
>>58375589
https://daniel.haxx.se/docs/curl-vs-wget.html
>>
>>58375589
alias wget='wget --no-check-certificate'
>>
Should I add a code of conduct to my project?
>>
>>58375612
If you need to add a code of conduct to your project, your project isn't worth anyways
>>
>>58375431
So tell me why they're trying to remove the GIL from Python and Ruby.
>>
>>58375608
Thanks! Now that I did this, it even installed McAfee for free!
>>
>>58375546
Clojure still has the ability to operate on lists as other lisps, it even has unhygienic macros, as if they weren't discredited by scheme decades ago, so it has no problems with homoiconity. You're upset by them teaching people to use optimal data structures from the start instead of reinventing them by misusing binary trees as it's customary in the lisp tradition, and this is just dumb.
>>
>>58375561
Yes really.
Why else would people like OCaml Labs be trying to fix the runtime to add support for true parallelism?
>>
>>58375634
Because their languages are inherently slow and fixing the problem would mean admitting that they were wrong about their language. So instead they desperately try everything else.
>>
>>58375612
Yes, it's the best way to get free publicity on /gee/
>>
>>58375612
short answer: yes
long answer: no
>>
I want to learn C++. What more should I learn that's not covered here?

http://www.cplusplus.com/doc/tutorial/
>>
>>58375664
To satisfy memesters who think they need it.
>>
>>58375612
Only if it gets too big to be handled in civilized manner.

Think GNU, Linux or your-favourite-language big.

>>58375659
I am upset by focusing on structure that isn't the same as the one syntax used, since more attention will be focused on it and more tools will be developed for it. So it will be harder to work on syntax than if it had same structure.

I don't like unhygienic macros myself, I know racket, scheme and common lisp, and from all their perspectives i find clojure frankly a bit retarded.
>>
>>58375425
There's probably a library for your language.
>>
>>58375679
>What more should I learn that's not covered here?
A LOT more, that just a really basic intro to the language, read up on c++14/17
>>
File: scala.png (55KB, 762x201px)
scala.png
55KB, 762x201px
>scala
>>
>>58375384
fuck outta here with this garbage
>>
>>58375702
Clojure has it's benefits though. I like arity specializing funcions and easier destructuring (compared to common lisp's destructuring-bind).

However I don't like it's lack of internal consistency (keywords as separate datatype, preferring vectors), loop (way weaker than common lisp's do or loop), break from lisp tradition (calling hashes maps, calling progn/begin do, making nil =/= '() ... just causing confusion for no good reason).
>>
>>58375453
>_hq

u avin a giggle?
>>
>>58375791
I also like that most of higher order "list" functions like map, reduce, work on all sequences, that there is just one equality predicate, but this has the downside of making optimizing code harder.
>>
>>58375679
>cplusplus.com tutorial
Congratulations you got memed in to using what is probably one of the single worst resources for learning C++ that's widely available.
>>
>>58375771
what the hell is going on here
>>
>>58375771
I don't know what the hell is going on with the first one, but the second one isn't Scala's fault. 123456789 can't be represented by single-precision floating point numbers. It would be the same in C.
>>
>>58375868
https://youtu.be/uiJycy6dFSQ?t=28m50s

The whole video is worth watching.
>>
>>58375896
I don't use Scala anyway
>>
If someone releases code with a copyright header, where in the copyright line the use a handle, or some other pseudonym, eg.

Copyright (c) 2016, Username.


is that legally enforceable? I see people do it on occasion and it seems like something that would be an issue should they ever need to take legal action on someone violating their license.
>>
>>58375883
But it's a Scala method - why not just not define it on Int?
>>
>>58375953
Any kind of "This is copyrighted" text is useless in the first place (you always get copyrights on anything you create), so I can't see how it matters either way.
>>
>>58375964
I'm guessing numeric literals have some sort of generic type. So Scala's compiler sees a function that needs a float and a numeric literal that can be any type of number, so it just blindly converts it.

Something like:
int x = 123456789 // Or whatever, I don't know Scala.
x.round

Would almost certainly be a type error. If it's not, feel free to bash Scala.
>>
>>58375953
yes
>>
imagine being a scalafag
>>
in Python why is the lambda function called lambda function?
>>
>>58375827
Yeah don't recommend a better resource or anything.

>>58375754
I've seen some of the new features, but I'm having a hard time getting a bird's eye view of the language because there's so much deprecated crap in it. Do you know of a comprehensive overview of the new features?
>>
>>58375449

thank you

>>58375733

lmao
>>
>>58376066
Buy/pirate C++ Primer 5 Ed.
Note *not* Primer Plus, which is shit.
>>
>>58375384
why not make a real thread though?
>>
>it's a language that requires semicolons and curly braces

So ugly. It hurts my eyes.
>>
>>58375944
I'll give you the short version:

The toSet method on List takes no arguments. It takes a type parameter that can be any supertype of the list element type, and returns a Set with element type equal to that type.

In Scala, x(a) is syntactic sugar for
x.apply(a)
. The apply method on Set returns whether or not the set contains the argument.

Additionally, if you call a method that takes an argument but supply no argument, and it would compile correctly if you instead supplied unit, Scala will insert a unit for you. (These days you will get a compiler warning if this happens.)

Calling Set's apply method with a unit works when the set's element type is Any.

So what the code ends up being equivalent to is:

List(1, 2, 3).toSet[Any].apply(())


>>58376018
Nope. It's defined in the class RichInt, which adds extension methods to Int, and to Int alone. The code you posted would compile and produce the exact same result.
>>
>>58374024
illustration2vec already exists
>>
>>58376061
cuz pretentious math wannabe cs kids
>>
>>58376091
We had real threads. During holidays it worked great, but after them people went back to universities/workplaces and threads started dying before reaching 50 posts.

So fpt is going to hitchike on dpt till next holidays I guess.
>>
File: scala.jpg (25KB, 1381x153px)
scala.jpg
25KB, 1381x153px
>>58376107
Seems like we're both wrong.
>>
>>58376222
I guess they fixed it then.
>>
>>58376092
Funny, your mom said the exact same thing about you
>>
>>58376087
Thanks m8, this book looks really good.
>>
>>58376092
code monkey
>>
>>58376282
A code monkey isn't interested in how his code looks or functions, and only cares that it works for his test cases
>>
>>58376339
hate to break it to you but a code monkey is overly concerned with code prettiness and doesn't care so much about what the fundamental algorithms and data structures being applied are
>>
>>58376282
> Look! I posted this buzzword I don't know the definition of again!
>>
>>58376376
That's not remotely true.
>>
>>58376376
Someone who doesn't care about what their code looks like isn't a real PROgrammer.
>>
>>58376379
>look i'm a butthurt code monkey

>>58376396
whatever helps you sleep at night
>>
>>58376413
>a code monkey, by definition, is not monkey-like but instead human and artistic
>hahaha you're a code monkey, unlike me

t. literal monkey
>>
>>58376376
I put those types of people even lower than code monkeys because they don't even write any code, all they do is nitpick trivial details, language lawyering, etc.
>>
>>58376433
>OOH OOH AAH AAH SHINY CODE PRETTY PRETTY LOOK LIKE POEM
>not monkey-like
>>
>>58376458

Are you just so reduced as a human being that you don't understand poetry?
Is that why you think poetry is monkey like?
Fuck your life
>>
File: brainfuck.png (97KB, 1229x575px)
brainfuck.png
97KB, 1229x575px
>>
>>58376458
Monkeys don't understand beauty or poetry, you ape.
>>
what's your opinion on programmers who wear a binary watch?

it's not like counting in binary is hard...
>>
>>58376458
> He thinks monkeys are birds
Really made me think
>>
fuk u i'm a professional code artisan :9)
>>
>>58376488
its the same as oldfag EEs who wear those nixie tube watches. pretty innocuous nerd crap/
>>
>>58376066
Effective Modern C++
>>
>>58376525
>nixie tube watches
Those exist? I mean, I get it if its a clock but that just seems cumbersome.
>>
File: browser_.webm (2MB, 960x1040px) Image search: [Google]
browser_.webm
2MB, 960x1040px
looks don't mean anything.
all that matters is what's on the inside.
right? =)
>>
>>58376488
Pretentious faggots, to be honest.
>look at me, I'm such programmer, so binary, wooh
>>
>>58376554
Please make Win95 style UI
>>
>>58376549
That's exactly it, they're non-preferable from every other point of view other than nerd cred/

I think there's like one guy who still makes them, but he hasn't done so in a while, and they cost like 300$ anyway/
>>
intel is dead
>>
File: Untitled.webm (2MB, 960x1040px) Image search: [Google]
Untitled.webm
2MB, 960x1040px
>>58376566
what does that even mean?
>>
What's your opinion on Fortran?
I don't understand why it is still used in new projects.
>>
>>58376599
cpu advancement is dead, it peeked with the 2500k.
>>
>>58376618
>>I don't understand why it is still used in new projects.
Has some really good+fast maths/science libs.
>>
>>58376618
Lots of libraries, fast, better support for vector/matrix math. But the main reason is many engineers and scientists just don't know any other language.
>>
What is the best book/resource for learning FORTRAN?
>>
>>58376554
what language, famlam?
>>
>>58376790
I just read the reference guide which came with Fortran IDE.
>>
>>58376866
a dead/dying lang that very few people use.
>>
>>58376886
Visual Basic 6?
>>
>>58376886
node?
>>
>>58376886
hahahahhahhaha very niece leddit xDDD bazinga heuehuehueheuhu hue
>>
>>58376886
C?
>>
>>58376886
D?
>>
>>58376886
E?
>>
>>58376886
F?
>>
i f****Ckin love memes
>>
>>58376886
Ah, good old Rust.
>>
File: Untitled.png (68KB, 1463x666px)
Untitled.png
68KB, 1463x666px
>>58376866
please no bully
>>
>>58377042
Basic?
>>
>>58377042
>that 90s feel
You even use Hungarian notation occasionally.
But seriously, why would you do that?
>>
File: 1477987668262.png (56KB, 491x585px)
1477987668262.png
56KB, 491x585px
>>58377042
>it actually is VB
First post right post.
>>
>>58377042
now I understand why you don't want to release the source code
>>
File: 1479883677181.jpg (143KB, 833x696px)
1479883677181.jpg
143KB, 833x696px
>>58377042
- NO BULLYING BELOW THIS POINT -
>>
>>58377112
I use what feels comfy.
>>
>>58377226
Faggot
>>
File: 1479459353440.jpg (82KB, 400x500px)
1479459353440.jpg
82KB, 400x500px
>>58377242
>>
File: ready_to_kill.png (176KB, 560x530px)
ready_to_kill.png
176KB, 560x530px
>>58377242
>>
x = 5
string = 'This should be 6: ' + str(x)

x = 6

print(string)

Is there a way to make this work by adding something to line 2?
>>
>>58376886
pascal
>>
>tfw decided to use plain C and now regret it
>>
>>58377278
you cant do it like that, the variable is not part of the string, its value at the time of concat is
>>
File: 432.png (6KB, 435x408px)
432.png
6KB, 435x408px
Is it normal for the coordinate system to be like this for programming in general or is it just JavaScript canvas?

Why not a traditional coordinate system?
>>
>>58377309
It's incredibly common for 2D APIs to behave like this.
>>
>>58377309
It's normal because fuck you.
>>
>>58377309
It is made lazily
>>
>>58377320
Is there a reason behind it?
>>
>>58377309
It's normal, it's exactly the same in Windows apps GUIs
>>
> when you use a systems language even though a scripting language would make more sense
>>
>>58377309
higher level libraries usually abstract that shit and just use pixel coordinates starting from (0, 0) in the corner rather than traditional normalized values
>>
>>58377341
Momentum.
The past affects the present.
>>
>>58377341
different screen sizes are the cause i think
>>
>>58377112
>Hungarian notation
the winapi uses it too, just take a look at msdn.
>>
I dont understand what the difference between structs in C and classes in Python are.

you could just manipulate structs in C with pointers and malloc like you manipulate classes in Python?

no?
>>
>>58377309

it has some advantages

you could just use unsigned ints to define the coords and every pixel would have a unique address

In OpenGL they use normalized floats (between -1 and 1) because GPUs are optimized for floats
>>
>>58377341
Presumably because back when you were writing pixel data directly in to buffers for graphics output back in the day that's how the memory mapped (ie. lowest address is top left, highest is bottom right), and so that's how the apis around it handled things.
>>
I want to try something new and learn a new language. Which one should I learn. Rust or Go?
>>
>>58377377
inheritance
operator overloading
member functions
>>
>>58377399
Rust
>>
>>58377399
Haskell
>>
>>58377399
D
(or Rust if you really want to)
>>
>>58377399
Neither. They're both cancer.
>>
>>58377399
tough choice but id say rust
>>
>>58377398
that makes a lot of sense but holy christ
>writing pixel data directly in to buffers for graphics output
>>
>>58377399
Ada and Go
>>
should i learn scala?
>>
>>58377399
>Go
- GC.
- No generics.
- Outdated type system.
- No ADT.
- No pattern matching.
- Not enough functional stuff.
- No RAII/IDisposible/Context managers.
- Ugly syntax.
- The most retarded and unsafe error handling story after C.
- Structurally typed interfaces instead of proper interfaces/type classes/traits.
- NIH infrastructure with authors spending years reinventing stuff instead of using LLVM.
- Community comprised of mostly python-kiddies.
Overall the language was designed to be as simple as possible and then even more simple so Google can train code-monkeys on an industrial scale, the only good thing about it being coroutines.
>>
>>58377278
This is what you're looking for:

x = 5
string = 'This should be 6: %d'

x = 6

print(string % (x))
>>
>>58377432
what about it
>>
>>58377399
Rust. Learning Go involves imagining that you're in 1960 and that it's the state of the art.
>>
What makes people think that a program written in assembly is better performing than one written in a higher level language such as C? Compoilers aren't stupid.
>>
>>58377432
It's not as bad as you might expect.
>>
>>58377449
>- No generics.
>- Outdated type system.
>- No ADT.
>- No pattern matching.
>- Not enough functional stuff.
>- No RAII/IDisposible/Context managers.
>- Structurally typed interfaces instead of proper interfaces/type classes/traits.
>- NIH infrastructure with authors spending years reinventing stuff instead of using LLVM.
These are all positives.
>>
>>58377496
If you're Rob Pike, maybe.

The rest of us want to get shit done.
>>
>>58377463
barely anybody writes entire programs in assembly these days. and diving down into assembly generally doesn't provide any real gains unless you're one of the significant minority of programmers who actually:
>know how to optimize assembly in the first place
>understand what the compiler is doing poorly and exactly how it could do it better for your one isolated circumstance
for the most part you're better served just letting the compiler handle it.
>>
>>58377518
Go is THE language if you wanna get shit done precisely because it doesn't concern itself with useless abstract nonsense.
>>
>>58377438
Patrician, but people find it hard not to mix types.
>>
>>58377554
you mean if you want to spend your time reinventing basic constructs that others decided to provide by default in their languages so just people can move on and spend their time on something actually worthwhile?
>>
>>58377554
Gee I sure fucking love checking that err != nil or whatever after every single fucking function

Gee I sure fucking love not being able to implement my own data structures and have them be reusable

Gee I sure fucking love not having RAII do cleanup for me

Gee I sure fucking love interface{} and throwing types out the window
>>
>>58377584
What 'basic constructs'?
>>
>tfw you accidenly wrote if( a = b ) without realizing it and it ruined everything
>>
>>58377636
Turn compiler warnings on.
>>
>>58377628
like half of the shit that the other dude mentioned
what are you smoking you forget what you read 10 minutes ago
>>
>>58377636
this doesn't happen in immutable languages
>>
>>58377646
The fact that you can't provide even one concrete example proves my point - useless abstract nonsense.
>>
>>58377636
I recently made this mistake and took forever to find the problem. Wall didn't help.
>>
>>58377666
fuck off you pseudointelectual caveman
>>
>>58377673
-Wextra

See also any one of the like 3000 linters available for C.
>>
>>58377463
>Compoilers aren't stupid
but they are you fucking retard
>>
>>58377628
>>58377666
UHHH how about a type system that can represent a list with a specific ring structure of element types??

it's extremely important in data streaming applications.
>>
>/dpt/ - Daily Pedantry Thread
>>
>/dpt/ - Daily Pederasty Thread
>>
>/dpt/ - D Programming Thread
>>
>>58377692
Can I point out that the names for Wall and Wextra don't make sense? Why is Wall not ALL of the warnings.
>>
>/dpt/ - Dick Penetrating Twat
>>
>/dpt/ - don't post that
>>
>>58377751
extra is for faggots who write shitty code and need the compiler tell them that it's shitty.
>>
File: 1459231731880.jpg (20KB, 317x265px)
1459231731880.jpg
20KB, 317x265px
>>58377806
>>
Programming is for gaylords. I'd rather post memes.
>>
>>58377751
I know, it's silly. If you want you can use clang's -Weverything though I don't recommend it.
>>
>/dpt/ - Daily Programming Thread
>>
>>58377818
monitors are for faggots who don't even know what the fuck they are doing and need to look at it all time to understand what the fuck is going on
>>
>>58377818
> He doesn't like statically verifiable programs
>>
>>58377855
this 2bqh. if you don't grok what the machine is doing by osmosis and feeling the electrical currents with your ass hair, you're probably the kind of programmer who needs to wear a dress to write decent code.
>>
>>58377863
ATS
>>
>>58377897
ATS stands for Autism
>>
why does /dpt/ have so many animeNEETs?
>>
http://pastebin.com/dMPRmA75

thatsa lotta globals
>>
>>58377943
>why does this 4chan thread have so many weebs?
>why are weebs usually NEETs?

Gee, I fucking wonder.
When you find out, tell the Nobel Prize commission.
>>
>>58377943
Why are you on an anime website complaining about anime?
>>
>>58377957
but why programming
>>
>>58377863

I've been trying to learn TLA+ for the last week. Fuck me. I thought I was ten years past considering a language "hard".
>>
http://www.strawpoll.me/12054630
http://www.strawpoll.me/12054630
http://www.strawpoll.me/12054630
>>
>>58377986
What does "semineet" mean?
>>
>>58377991
i have no fucking clue, but that's probably what i am.
>>
>>58377991
In-between a NEET and a normie.
>>
>>58377401
>>58377401

I see. I read more into the chapter now and it looks like emulating classes in C would be possible but a HUGE TREMENDOUS pain in the ass.
>>
wish i wasnt to smart too program an AI to choke me too death
>>
>>58378000
But that doesn't make sense. NEET isn't really a gradient. You're either a NEET or not.
>>
>>58377967
4chan is a website founded by weeaboos, specifically anime lovers, for themselves, to discuss hobbies.
Even /b/, for instance, was initially founded as "Anime/Random".

Obviously the recent migration from reddit, facebook, twitter etc has led to an infiltration of normalfags who don't actually like anime, but still think they fit in, purely because there's something else about them that isn't entirely normal. But they don't fit in.

You would find, if you enforced the traditional 4chan anime culture, and made sure that the front pages and catalogs of every board had an excess of anime images, that the ultra-normalfags would disappear along with the regular normalfags.

So to summarise, 4chan is a website for anime fans to discuss various topics, including (but not limited to) anime.
>>
>>58378017
>False dilemma
>>
>>58378017
kind of like how you can take a nigger out of the ghetto but you can't take the ghetto out of a nigger
>>
>>58378027
NEET literally by definition means that you're not currently employed, in education, or in training.

You can't really be "in-between" a state of being NEET and not NEET.
>>
>>58377973
Why that instead of mersa-c or spark?
>>
File: 1451995301143.jpg (141KB, 600x2158px)
1451995301143.jpg
141KB, 600x2158px
>>58378017
Well, there are people with day jobs living alone who otherwise far from normie.
>>
>>58378051
NEET is a state of mind and embodies a set of characteristics

even a normalfag with a 9-5 or a college student can NEET out over weekend, or holidays for instance.
>>
>>58378075
You're a fucking retard.
>>
>>58378019
>>58378051
>>58378075
a u t i s m
u
t
i
s
m
>>
>>58378075
No it's not. If you want to give yourself a special snowflake label make up one that's not already used for something.
>>
>/dpt/ full of semiNEETs
>/dpt/ triggered by semiNEETs

It's true. 4chan truly hates itself.
>>
>>58378104
If you don't have autism, why would you be using 4chan?
>>
>>58378115
*enemy noticing snake noise*
>>
>>58378065

They aren't really in the same space.

You can write a shitty algorithm in misra c or spark. TLA+ is supposed to help you fix that.
>>
normie/abnormie is a different axis than neet/productive member of society
>>
>>58377448
What for?
>>
>>58377448
If you want to learn Scala, learn Haskell instead
>>
>>58378197
This.

t. worked with scala professionally for 5 years
>>
>/dpt/ - autism
>>
>>58378157
no
>>
File: AHAHAHA.gif (491KB, 500x220px)
AHAHAHA.gif
491KB, 500x220px
>>58378230
>professional
>Scala
>developer

pick 1
>>
>>58378245
stay mad, joblet
>>
File: 1475165444218.jpg (91KB, 1280x720px)
1475165444218.jpg
91KB, 1280x720px
>>58378334
>tfw no job
>>
>>58378366
>tfw the only jobs you get start with h or b
>>
>>58378411
Haskell?
>>
>>58378411
H1B, Pajeet?
>>
>>58378411
homoend and backend?
>>
i tried to compile your life but got a ValueError
>>
Doing C++ tutorials and being confused over something trivial.

The << and >> operators. Is there a simple way to think about them?
>>
>>58378517
The simple explanation of << and >> is "a mistake"
>>
>>58378517
You are supposed to overload every operator in c++ so no there is no simple way to think about it because it could mean anything the library dev wants.
>>
>>58378492
I tried to write a type H for your sense of humour but I was able to prove H = ∀A.A.
>>
is learning C++ a smart investment to get into robotics? I heard it's like C but with OOP but then i saw that for example ROS also works with python and I saw a robotics programming job in germany required Java for most positions. Then again boston dynamics asks for c/c++ experience. Does it depend on the job/company or was it just that one german company that was weird?
>>
>>58378517
first, think of them as the bitshift operators, and then throw that immediately out the window because they could be literally anything.
>>
>>58378536
>>58378563
Confusing.... They look like they're used a lot, so I'm going to have to figure it out in full to keep going I think. C# seemed easier than this.
>>
>>58378075
You stupid ass, you don't go around telling everyone you're unemployed just because you have days off.
>>
>>58378517
If you have std::cout << some_object, then some_object is "entering" the output stream. Conversely, with std::cin >> some_object, the contents of the input stream are "entering" some_object.
>>
File: dpt.png (742KB, 1920x1080px)
dpt.png
742KB, 1920x1080px
>>
>>58378778
))<<>>((
>>
>>58378803
is that supposed to be goat.cx?
>>
>>58378833
Looks like a double dildo entering 2 asses to me. Probably part of the C++ standard library.
>>
Why can't I get templating to work with interfaces in C++?
>>
>>58378545
C++ is becoming more standard in embedded programming these days.
Wouldn't imagine pure OOP being the go to for that sort of stuff, I'd imagine it would be a half mix of OOP and imperitive.
I'd argue learning C++ is always good, since it is an incredibly broad and deep language.
>Java & Python
Embedded systems are big/powerful enough now that you could take the resource/efficiency knock of not using pure C/assembly
>>58378858
Gonna need to be more specific there anon
>>
>>58378858
Templates don't play well with dynamic dispatch because of monomorphization. Post code.
>>
>>58378671
don't worry about it too much at first. if you want to bust your brain, look at the ostream class (of which cout is an implementation) to see the most common example of an overloaded operator. instead of bitshifting cout by a string value -- which is obviously nonsensical -- the bitshift operator has been overridden to send that string to stdout.

for any class you write you can write code that associates a custom function with the specified operator when used with one or more objects of the associated class.

class adder
{
private:
int a;
public:
adder(int b) { a = b; }
int operator+(const adder &b) { return this->a + b.a; }
};

int main()
{
adder a(2);
adder b(3);
std::cout << a + b; //prints 5
}
>>
>>58378803
>>58378833
https://www.youtube.com/watch?v=8TOk925l-5I
>>
File: hereyougo.gif (88KB, 10000x10000px)
hereyougo.gif
88KB, 10000x10000px
I have the following code to return the shortest path on a multidimensional array from top left corner to bottom right corner, with the option of removing one of wall cells (marked with '1') by changing its value to '0'. My approach is to make a list of removable walls and then by removing them one at a time in a loop, do a BFS search for the shortest path. At the end, I return the shortest path overall.

I have the following code that works. However, when I put my code in the online interpreter, I have a timeout error. Is there anything I can do to make it faster?


http://pastebin.com/qwAyrcn6
>>
>>58378959
part 1/1
class Queue:
def __init__(self):
self.items = deque()

def isEmpty(self):
return self.items. == []

def enqueue(self, item):
self.items.append(item)

def dequeue(self):
return self.items.popleft()

def size(self):
return len(self.items)

def memodict(f):
""" Memoization decorator for a function taking a single argument """
class memodict(dict):

def __missing__(self, key):
ret = self[key] = f(key)
return ret
return memodict().__getitem__

@memodict
def adjacent_to((maze_dim, point)):
neighbors = (
(point[0] - 1, point[1]),
(point[0], point[1] - 1),
(point[0], point[1] + 1),
(point[0] + 1, point[1]))

return [p for p in neighbors if 0 <= p[0] < maze_dim[0] and 0 <= p[1] < maze_dim[1]]

def removable(maz, ii, jj):
counter = 0
for p in adjacent_to(((len(maz), len(maz[0])), (ii, jj))):
if not maz[p[0]][p[1]]:
if counter:
return True
counter += 1
return False
>>
File: ex4.png (15KB, 398x445px)
ex4.png
15KB, 398x445px
I finished all the other exercises in this assignment without trouble except this one. It now prints 1 2 3 4 and I need to have it print that in reverse (4 3 2 1).

It's for my data structures course and I can't see a prof until monday. It's killing me. I would appreciate it if someone would point me in the right direction.

I'm only allowed to use python basic operators.
>>
>>58378958
https://youtu.be/KQoJo81lujk?t=4m48s
>>
>>58378959
>>58378979
meant to say 1/2

part 2/2
def answer(maze):

path_length = 0

if not maze:
return

dims = (len(maze), len(maze[0]))
end_point = (dims[0]-1, dims[1]-1)

# list of walls that can be removed
passable_walls = set()
for i in xrange(dims[0]):
for j in xrange(dims[1]):
if maze[i][j] == 1 and removable(maze, i, j):
passable_walls.add((i, j))

shortest_path = 0
best_possible = dims[0] + dims[1] - 1

path_mat = [[None] * dims[1] for _ in xrange(dims[0])] # tracker matrix for shortest path
path_mat[dims[0]-1][dims[1]-1] = 0 # set the starting point to destination (lower right corner)

for wall in passable_walls:
temp_maze = maze
if wall:
temp_maze[wall[0]][wall[1]] = 0

stat_mat = [['-'] * dims[1] for _ in xrange(dims[0])] # status of visited and non visited cells

q = Queue()
q.enqueue(end_point)

while q:
curr = q.dequeue()

if curr == (0,0):
break

for next in adjacent_to((dims, curr)):
if temp_maze[next[0]][next[1]] == 0: # Not a wall
temp = path_mat[curr[0]][curr[1]] + 1
if temp < path_mat[next[0]][next[1]] or path_mat[next[0]][next[1]] == None: # there is a shorter path to this cell
path_mat[next[0]][next[1]] = temp
if stat_mat[next[0]][next[1]] != '+': # Not visited yet
q.enqueue(next)

stat_mat[curr[0]][curr[1]] = '+' # mark it as visited

if path_mat[0][0]+1 <= best_possible:
break

if shortest_path == 0 or path_mat[0][0]+1 < shortest_path:
shortest_path = path_mat[0][0]+1

return shortest_path
>>
>>58378983
Build up a new list from scratch, while tearing down the existing list.
>>
>>58379018
Please elaborate? I don't see how I'm supposed to loop through the existing list in reverse order without manually typing in the directions to the list attributes for every value which I'm not allowed to do for this assignment.
>>
>>58378892
>>58378894

#include <iostream>

class IMessages {
public:
virtual void sayHello() = 0;
};

template <typename T>
class IMath {
public:
virtual void sumAndPrint( const T& a, const T& b ) const = 0;
};

template <typename T>
class person : public IMessages, public IMath<T> {
public:
void IMessages::sayHello() {
std::cout << this << " says hello" << std::endl;
}
void sumAndPrint( const T& a, const T& b ) const {
std::cout << a + b << std::endl;
}
public:
person() { }
~person() { }
};

int main() {
person<float> p;

p.sayHello();
p.sumAndPrint( 0.3f, 0.15f );

std::cin.get();
return 0;
}



I would like to explicitly write out in the person class that it uses IMath<T>::sumAndPrint just like with IMessages but I get errors whenever I do that and I can't figure out what is wrong
>>
>>58379004
>>58378979
Fuck off, no one here is smart enough to know that cuck
>>
>>58379100
Pretty sure you'd just write IMath::sumAndPrint and the T will be inferred by the parameter types. It's a bit weird but that's C++ for you.
>>
>>58379088
I don't want to completely rob you of the benefits of figuring it out yourself so I'm not going to give you the full answer.

Suppose instead of trying to loop through the list in reverse order, you construct a new list, which is the original list but reversed, which you could then loop through normally. Which element would you want to be last in it? Which would you want to be second last, and so on?
>>
>>58378894
>what are polymorphic components
>what are existentially quantified types
>>
>>58379180
Not in C++, that's for sure.
>>
>>58379205
>implying
>what is #include <clang>
>>
>>58379100
What are the fucking errors anon?
>>
>>58379225
You can't include a header and have C++ gain higher rank polymorphism.
>>
>>58379248
that's where you're wrong kiddo

>recompile source code at runtime
>>
Is Modern C by Jens Gustedt a good book?
>>
>>58379261
Might as well just use void pointers in the first place.
>>
I'm screwing around with "modern" C++. Let's say I have a vector of integers. If there's a 2 in the list, I want to replace it with a 9. What's a clean way to do this *in a safe way*?

    std::vector<int> arr = { 1, 2, 3, 4 };

printIntList(arr);

// Change 2 => 9:
*(std::find_if(arr.begin(), arr.end(), [](int i) -> bool { return (i == 2); })) = 9;

printIntList(arr);

// Sort list:
std::sort(arr.begin(), arr.end(), [](int a, int b) -> bool { return (a < b); });

printIntList(arr);


(consider the case that the vector doesn't contain a 2, in which case the code fails)

The obvious solution is:

    // Change 2 => 9:
auto element = std::find_if(arr.begin(), arr.end(), [](int i) -> bool { return (i == 2); });
if (element != std::end(arr))
*element = 9;


But I find this ugly and prone to repetition. Is there a slick way I'm not seeing to deal with this sort of conditional modification?
>>
>>58379313
Why are you using find_if when you can use std::find?

Also, do you want to change all 2's into 9's?
>>
>>58379313

std::transform(cant remember parameters, [](auto a) { if (a == 2) then return 9 else return a; });

i.e.

map (\a -> if a == 2 then 9 else a)
>>
>>58379313
std::transform(arr.begin(), arr.end(), arr.begin(), [](int& i) { if (i == 2) i = 9; });
>>
>>58379421
Oops, fucked up the lambda. Should just be [](int i) { return i == 2 ? 9 : i; }
>>
>New job
>It's millions of lines of spaghetti code with no documentation
>Hundreds of lines of code for a single function
>Initially, doesn't even compile in a machine other than the boss'
I made a terrible mistake.
>>
>when you add a bunch of new code and compiles and works perfectly the first time
>>
>>58379462
Trust me, there's a bug.
>>
>>58379448
>Hundreds of lines of code for a single function
wait, are you saying my callbacks shouldn't be 1000 lines long?
>>
>>58379474
Only if you want the maintainer to kill himself within a few months in the job.
>>
>>58379462
>>58379472

Yeah this is a trap, write tests.
>>
>>58379164
I get what you mean. Two loops going through eachother. I just don't see how I can accomplish that without manually referring to the needed elements though (i.e: l.value, l.Tail.Value in untill the end of the list)
>>
Middle of the night. 6.5 hours until university servers close and I still have 2 more assignments to complete.
How do I keep myself awake and survive tomorrow?
>>
where can i find programmer friends? or any friends really
>>
>>58379519
dildo in the ass
>>
>>58379522
I would also like to know this : I....
>>
>>58379164
>>58379509
Oh wow it just clicked, thanks! It's actually rather simple.
>>
>>58379534
friends?
>>
>>58379551
Or just use recursion and it'll be a lot simpler
>>
File: 300px-Xmatrix.png (112KB, 300x225px)
300px-Xmatrix.png
112KB, 300x225px
Will programming be any different in 100 years?
>>
>>58379628
ais will maintain and write code. humans will maintain and write the ais or wait?
>>
>>58379628
It will be redundant. Computers will program themselves.
>>
>>58379519
Just go to sleep, you are so tired and that bed looks so comfortable...
>>
File: image007.jpg (57KB, 601x500px)
image007.jpg
57KB, 601x500px
>>58379628
Something may change, but it will be the same in nutshell.
                                                                                                                                                                                                                                                                                                                                                                                                                                                       These are not computer punchcards on the picture.
>>
>>58379700
>c'est ne pas une computer punchcards on the picture.
>>
>>58379628
Programming computers will be like programming dogs
>>
>>58379747
>mfw puppernet becomes self aware and begins nuclear war.
>>
>>58379783
I've spoken with doge.
He already is.
>>
>>58380029
Doge is aware?
>>
new thread >>58380134
>>
>>58380085
aware that you're a faggot
>>
>>58380029
>>58380085
i've spoken with reddit, they want their village retards back
>>
>>58380168
>i've spoken with reddit
t. redditor
>>
>>58380145
>Created before the bump limit
Delete this shit and kill yourself
>>
>>58379367
>Why are you using find_if when you can use std::find?

Why does it matter? I don't see how that changes the core of the question.

>Also, do you want to change all 2's into 9's?

Seriously? Substitute literally *any* change of state that you want to. It was a completely arbitrary example.

>>58379412
>std::transform(cant remember parameters, [](auto a) { if (a == 2) then return 9 else return a; });

That's going to call the transform function on every single element, right? That seems computationally excessive, if it were a more complex structure.

>>58379421

Same problem.

Also, I'll point out that the provided solutions don't give the same result. find_if only returns the first instance. transform is going to affect every element.
>>
>>58379448

FWIW, the first thing I do on a new codebase is run Doxygen on it. I turn on the callgraph generator and tell it to generate documentation on ALL functions.

I find it to be extremely helpful for getting up to speed fast.
>>
>>58380522
>That's going to call the transform function on every single element, right? >That seems computationally excessive, if it were a more complex structure.
No, a map (i.e. applying a function to every element) is the default, and only for specialised structures (e.g. sets, ordered arrays) can you do more efficient transformations.
Thread posts: 316
Thread images: 29


[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.