/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?
Also, there was no active /dpt/ thread on Sup Forums for several minutes! Stop being lazy!

Other urls found in this thread:

pastebin.com/rfpYRHm3
imgur.com/gallery/mWkeC
dyingsungame.com/screenshots/ffyy909uci06fk9til13ddch40ubp5
mooc.fi/english.html)
twitter.com/SFWRedditGifs

How do I prevent SQL injections?
Do I just strip out semicolons on user input?

Parameterized queries.

in haskell, without writing it all out, how can I get the list

[[1..2],[1..3]..[1..9]]

that is, a list of lists ranging from 1-2 to 1-9?

>without writing it all out, how can I get the list
just write a nested loo-
>in haskell
lololololololol nevermind

great post user, thanks!

If writing it like that doesn't work then haskell isn't cool enough

hory shet

Though of how to do it myself

muhlist = [[1..n] | n

>yfw even the simple task of setting up your variables requires solving a puzzle in haskell

/dpt/ help me. I'm trying to learn Schmeme and write a tail-recursion function, but it keeps throwing errors at me.

pastebin.com/rfpYRHm3

( define sumOfSquares
( lambda (L)
(sumOfSquaresHelper(L '()) )))

( define sumOfSquaresHelper (lambda (L acc)
(cond
(( equal? L '()) acc)
(( = 1 1 ) (cons acc (+ ( * (car L)(car L))))
(sumOfSquaresHelper (cdr L) acc)))))

(sumOfSquares '(2 2))

Gives me "application: not a procedure;
expected a procedure that can be applied to arguments
given: '(2 2)
arguments...:"

What the fuck do you mean it's not a procedure, it's literally calling sumOfSquaresHelper.

What are some good SDL2 readings?

Tbh the solution was kind of obvious I was just thinking you could write it as a range.

I'm just going through project euler and all my solutions have been in shorter lines than my C solutions, and it's fun so I enjoy it

python solutions would be even shorter
might as well learn that instead

you should learn golfscript then

except python is ugly as fuck and often slow as fuck, haskell is sexy and pretty fast, functional programming is super fun

Why are you applying L to the empty list?

also wouldn't hurt to learn a couple 'trick' languages that print out things like the lyrics to 99 bottles of beer with a single character source file

>pastebin.com/rfpYRHm3
nigga what in the fuck are you doing?
change line three to (sumOfSquaresHelper L '())
>that formatting
why?
>(= 1 1)
why?
read SICP

>read SICP
That's what I'm doing!

python is like twice as fast as haskell bruh stop maymaying

Maybe cpython but otherwise haskell seems faster, I admit I don't have much experience but that's just from what i've seen

no, regular python
cython could be more like 20x faster
haskell is not a fast language by any means

>(= 1 1)
>application: not a procedure;
expected a procedure that can be applied to arguments
given: #t
arguments...: [none]

Look, it just works.

Haskell is faster in Haskell vs vanilla Python. If you use Cython, that would be faster of course. I'm unbiased.

Ask a programming expert anything

Why are you on Sup Forums

cpython is the slow as shit vanilla python interpreter
cython is a different language entirely

You're right, I should be out finding a mate or learning how to cook

Yeah I meant cython

Why are you on Sup Forums

I'm a bad programmer

Cython mentioned
>try the naive implementation of the Fib sequence in C, Python and Cython
>C: ~4 mins
>Cython: ~7 mins
>Python: ~2 hours
Interpreters were a mistake

For fib(50), btw

hey /dpt/, do you like this art style?
imgur.com/gallery/mWkeC
dyingsungame.com/screenshots/ffyy909uci06fk9til13ddch40ubp5

Is there open source software that incrementally archives Sup Forums?

python just has a slow design, interpreters can be a lot faster than that

can anyone help me with C++ threads and mutex stuff ?

XSS_clean that shit or force the user to not use shit like semi colons

It looks pretty good but I wish it didnt have so much harsh "blacks".
It would really benefit from some half-lambert so it isnt just shading to black everywhere

>tfw don't get the job because I studied data structures but all the questions were high level OOP questions

feels bad I was so ready for shit with linked lists, stacks, binary search trees but no it was simple shit like what is polymorphism that I had completely forgotten.

at least I got a nice offer from another company. But fuck me that just stings when I get a call saying they were looking for more "technical experience" basically saying I'm stupid as shit.

You are, desu. Not understanding polymorphism? Seriously?

kek, was asked what polymorphism was in year 1 CS

poly;orphism ain't OOP

Should have done haskell to solve this argument

i just started learning, so i'd recommend lazyfoo.net

>It looks pretty good but I wish it didnt have so much harsh "blacks".
UHH Sexist and RACIST much?!

>high level OOP questions
jesus christ

I learned polymorphism in my first year of CS and just completely forgot how to explain it on a higher level.

that was my first technical interview and I just fucking crashed under the pressure.

That was from awhile ago and I don't know Haskell

Hash everything. If all that gets passed to SQL functions are strings of 0-f, then SQL injections are impossible.

>I get a call saying they were looking for more "technical experience"
I'm sure what they meant was "practical experience"
because in the real world you're essentially never going to implement your own linked list, stack, or binary search tree
so of course someone who knows what they're doing is not going to ask you questions about that

they only care if you know how to solve a real problem and can understand the other programmers code

I don't get how people can "understand" something and not know how to describe it

ok then, explain to me what the word "because" means without looking it up

main :: IO ()
main = print $ fib 50

fib :: Int -> Integer
fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)


I'd repeat the test myself but I'm too lazy to rerun hour long tests and I don't have the same setup as you to steal your results

"Because" is reversing a modus ponens by exhibiting the premise.

>dictionary.com has just logged a peculiar spike in traffic for the page defining "because"

I'm getting close to finishing reading my first java basics book.
Can someone tell me what I should do next?
I wanted to do this finnish course (mooc.fi/english.html) quickly since I tought that the author didnt talk about certain things in depth enough

>I don't get how people can "understand" something and not know how to describe it

well polymorphism is a bad example because I never really used in much in my CS courses.

but for stuff like classes, inheritance, libraries,testing I didn't know the formal definition but I have used it a ton but can only explain it using examples.

Because gives a reason to the statement in front of it.

Explain a number or a computer.

Great, it fixed it, now "acc" returns " '() " regardless of however much I cons it.

Fuck this language, fuck SICP, when do I reach meme enlightenment?

I am taking a course on C to learn how Objects work to program making games

Polymorphism is basically you having many different forms of the object For example

We could have a base pie object and then we could have many different forms of the base pie object such as blueberry pie object applepie object and strawberry pie object

Sicp is a meme book it will not help you with relevant programming you are better off learning C or Java

>that formatting

>What the fuck do you mean it's not a procedure
'(2 2) is not a procedure.

My point is more that if you purport to understand something then you should be able to explain the reasoning behind why it exists, what it's useful for, how to use it, and depending on the subject, how it accomplishes its purpose.

Unfortunately, standardized testing typically only covers the "how to use it" and maybe "what it's useful for" parts. If you only remember those parts then you're going to have trouble reconstructing it later and likely don't fully understand it as a concept.

>Polymorphism is basically you having many different forms of the object For example

in the interview I got close to that definition I said functions called based on the data type supplied. but he had to hold my hand a bit on that question and I got hung up on shit I knew.

for example what's the difference between I a class and an object? I knew it in my head but it took me forever to spout the answer because I kept thinking I was wrong as fuck.

my nerves were shot by the 3rd question out of 14 in the interview.

A class is the blueprint of the object. What were the other questions?

>what's the difference between I a class and an object
This is the classic
>How nervous are you?
question

You need to be specific like how I said giving an example relating to actual Object programming your explanation does not relate to objects at all

A good answer is a class is a blueprint and an object is an instantiation of the class

I took the interview last Tuesday but off the top of my head:

>explain .Net
>what is OOP
>what is functional testing
>what should be put on a Software Specification Sheet?
>what is inheritance?
>if class B derives from class A what else can you do with class B?
>if you test software and it comes back perfect what does that mean? is your software bug free?
>explain use cases
>how do you describe a use case?
>what is a UML?

The questions are straight forward but my nerves were terrible so I probably missed half because I was second guessing myself the whole way.

It was my first technical interview how do I get better and not make my nerves so utter dog shit?

CLion, NetBeans or Code::Blocks?

I have used Code::Blocks for coding and debugging in C which is nice.

Netbeans is good to especially for web dev.

never used CLion

How does one become a god at programming?

I'm trying to move from Java to C#, as my uni almost exclusively teaches java until Programming III, where we go into a bit of C.

Any exercises or small projects to get me to make the transition easier? I've noticed there's a large amount of similarities from Java to C#, so it hasn't been hard so far.

also inb4

>poo in loo

What's the best scheme and why is it bigloo?

do it for an ungodly amount of time for your entire life

Spin in a circle 3 times, jump and yell "MAY THE SILICON BE WITH ME" as loud as you can. If it didn't work, you didn't yell hard enough. Try again,

what's a good naming scheme and folder/namespace layout for naming classes in c#?

lets say i'm handling anime episodes and i have individual classes for different cases, would an appropriate scheme be something like namespace Classes.File.Episode with class name "Individual", or just Classes.File with "IndividualEpisode" in there, along with "MultipleEpisodes" and "RangeOfEpisodes"? How much information should the class name convey?

the only right answer :(

Be born autistic

>explain .Net
A mechanism invented by Microsoft in an attempt to lock developers and their software in to the Windows platform

I don't have a question or topic to discuss, I just want to vent. Feel free to call me a retard/faggot.

>be doing job interview
>coding test
>get to the very end
>"cool, so everything works, I just have a few more questions"
>"okay, so what's the time complexity"
>O(n)
>"okay good, so what's the space complexity"
>uhh I'm not sure
>"okay that's fine"
>"we'll be in touch"
>close skype call
>instantly figure out what the space complexity is

what did you have to code?

I want to learn ruby and build my portfolio. Anyone got any fun little programming project ideas?

yeah learn javascript or java instead of a hipster retard language

I'm paranoid about people finding me out, so I'm not gonna say exactly, but I will say it was super simple (like 1st year CS undergrad homework simple), it's just that I used some C++ standard library stuff which made me think figuring it out was more complicated than it actually was.

I already know java, any ideas for javascript?

Was it FizzBuzz? Don't tell me you messed up FizzBuzz after all that training we gave you.

>Sicp is a meme book it will not help you with relevant programming you are better off learning C or Java
It's helped in that I now can't turn anything that's more than 30 lines of code into a function.

>javascript instead of a hipster retard language
dude wut

No, it was more of a string processing problem. And I didn't mess it up, I just had a brain fart when the interviewer asked me about it at the end, so he possibly thinks I'm stupid even though it worked.

At the end of the day javascript > ruby.

Tell me when has anything made by Microsoft not been a attempt to lock developers and users into the windows platform?

I mean damn the company releases open standards and then doesn't follow them in their own products.

Yeah, but consider how subtle that is
compared to
>Here's a framework that your users will have to install in order to run your software.
>We will release it only for Windows.

hololens uses unity as a graphics engine, does that count?

>Write a recursive function for generating all permutations of an input string. Return them as a set.

DAE suck ass at recursive problems

how is js hipster
do you also think that the web is hipster?

Read "the little schemer" senpai

Was it reverse a string?

was it remove each x element from the string?

was it remove duplicates from a string?

I need to knoww