[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: 301
Thread images: 24

File: 1451173470578.jpg (28KB, 444x399px) Image search: [Google]
1451173470578.jpg
28KB, 444x399px
old thread: >>52198068

What are you working on, /g/?
>>
Working on expanding my anime-inspired legwear collection for cute trapping
>>
threadly reminder that negative numbers are a meme
>>
Is dependency injection even possible in C or C++ ?
>>
File: 1451763095689.jpg (753KB, 1276x1015px) Image search: [Google]
1451763095689.jpg
753KB, 1276x1015px
>there are people ITT who think C is low level and ancient
>there are people ITT who can't implement the OO design patterns in a non OO-oriented language
>>
File: kkk.png (4KB, 553x120px) Image search: [Google]
kkk.png
4KB, 553x120px
What else in math is a meme, /dpt/?

We know negative numbers, irrational numbers, and infinity are a meme, what else is there?
>>
post repos
>>
>>52201071
Dependency injection is just passing dependencies and not using globals.
>>
>>52201062
ǝɯǝɯ ɐ ǝɹɐ sɹǝqɯnu ǝʌıʇısod
>>
>>52201071
Yes?
>>
>>52201086
It's not exactly a meme, but you don't really need any even numbers other than 0 and 2 to get anything done
>>
File: snakes.png (40KB, 540x566px) Image search: [Google]
snakes.png
40KB, 540x566px
>>52201086
Real numbers aren't real apparently, at least according to Python
>>
>>52201091
https://github.com/nezumisama/mpvmenu
>>
>>52201096
>>52201105
I mean conveniently, using some sort of injection container and annotations
>>
>>52201086
Zero is a meme, one is a meme, non-integers are a meme and non-primes are a meme.
>>
Instead of trying to find out what numbers are memes, let's do this the constructivist way: What numbers do you actually need?

I propose 0 to index things and to represent the absence of other numbers, but not as an actual number because it's useless (something * 0 = 0, something + 0 = something, so what's the point?), 1 because you can have 1 of some thing, 2 for when you have a pair and all other odds.
>>
>>52201137
Isn't that just a factory? What problem does a "dependency injection container" solve?
>>
File: 1450940678029.jpg (168KB, 640x960px) Image search: [Google]
1450940678029.jpg
168KB, 640x960px
Are traps a meme?
>>
>>52201160
Prime numbers are literally the only non memes
>>
>>52201137
Templates.
>>
>>52201104
You can hold 2 apples in your hand, you nonce.

>>52201140
Those aren't memes, 0 is the absence of things (i.e. nothing).

You can have no apples. You can have 1 apple. You can have 1.5 apples. You can have [insert non-prime number] apples.

You're not getting this, anon.

Memes are things that can't exist IRL like perfect circles, negative amounts, and infinity.
>>
>>52201219
so infinite rational are a meme, like 0.(5)?
>>
File: 1450349710274.jpg (53KB, 599x800px) Image search: [Google]
1450349710274.jpg
53KB, 599x800px
Friendly reminder that you self-taught codemonkeys have no chance of securing a job or advancing without a CS degree.
>interviewing candidates
>tell them to outline a proof of the cook-levin theorem
>100% fail
>ask them to prove that the halting problem is unsolvable
>75% fail
>ask for proof that sqrt2 is irrational
>only 2 get it
>mfw they start rambling about their github repos and node
>most of them didn't even have a CS degree

Codemonkeys gonna codemonkey
>>
>>52201199
yeah, this seems to be what I'm looking for, thanks
>>
>>52201244
The halting problem is undecidable, not unsolvable.
>>
>>52201244
>go to programming interview
>retard gives me some math shit
>turn 360 degrees and leave
>go to next interview
>actually competent HR
>instant 100k/year
>>
File: fds.jpg (136KB, 569x422px) Image search: [Google]
fds.jpg
136KB, 569x422px
It says here you don't believe in negative numbers. Care to explain?
>>
>>52201342
I can't have -1 dicks m8
>>
>>52201219
The "absence of things" is a meme.
There are only things.

Unfortunately, not everything is about apples.
>>
>>52201342
yes, the bank tells me I have a negative amount of money so I pretended to be a retard to avoid having to pay it back. now I live in a mental asylum.

btw I've escaped so if you see my handler anywhere near just give me a wink and I'll duck right away.
>>
File: ?.png (121KB, 250x418px) Image search: [Google]
?.png
121KB, 250x418px
Is 0 even?
>>
>>52201365
but that's just a vagina
>>
>>52201219
>You can hold 2 apples in your hand, you nonce.
No you can't, the only number which exists is 1.
Only one universe, only one set of atoms, rearranging the atoms into so called "two" or "three" apples doesn't change anything you're still using the same atoms, which is the one set.
>>
>>52201091
Promise not to bully me for being a girl?
>>
>>52201368
There is no 0, use a maybe monad instead
>>
>>52201396
Can you share 0 apples evenly between two people?
>>
>>52201396
even what?
>>
File: 346356365234.jpg (45KB, 620x413px) Image search: [Google]
346356365234.jpg
45KB, 620x413px
>learning some physics so I can simulate the phenomenon
>half an hour with plenty of multivar calc in, prof mentions that lna - lnb = ln(a/b)
what the fuck do americans learn in hs maths?

>>52201415
are you a qt grill?
>>
File: Interviewer.jpg (17KB, 350x244px) Image search: [Google]
Interviewer.jpg
17KB, 350x244px
It says here you don't have any formal education or even a degree in Computer Science.
You realize this position requires at least 4 years of experience, correct?
>>
>>52201421
Yes, they both get zero.
>>
Daily reminder that 1 is the only REAL number.
You can get any number from 1.
>>
>>52201448
So it is even.
>>
>>52201331
>HR
>ever competent
>>
>>52201442
>You realize this position requires at least 4 years of experience, correct?
So look at my work experience then, and not my education.
>>
>>52201424
Does it matter?

>>52201452
The only REAL number is 0. Confirmed for never having read Principia Mathematica.
>>
>>52201396
k is even if k = 2i where i is an integer
0 = 2*0
0 is an integer
therefore 0 is even
>>
>>52201452

{ 1 }

+ -> N
/ -> Q
√ -> C
Σ -> etc
>>
>>52201396
Even numbers: 2k he k is a integer
0*any integer = 0
=> 0 is even


even if it was bait
>>
Has anyone here ever read about crystal science?
>>
>>52201452
It's just easier to write 2 instead of 1 + 1, or 3 instead of 1 + 1 + 1, or 4 instead of 1 + 1 + 1 + 1, and so on up till the maximum number of countable things, not infinity because infinity is a meme.
>>
>>52201561
You can't do shit with 0. Every valid operation is a fucking endomorphism.

>mfw you're right and every quantum field sums to 0 everywhere and literally nothing exists
>>
>>52201569
this relies on the theory that 0 is an integer though
>>
>>52201564
>>52201569
shit m8 i was slow
>>
>>>/sci/
>>>/sci/
>>>/sci/

GET THE FUCK OUT OF HERE YOU NERDS
>>
>>52201577
Exactly, 2 (and any other N) is REALLY just a + operation on 1s

Rationals are just a / operation on + operations on 1s

Complex numbers are just a √ operation on / operations on + operations on 1s
>>
>>52201619
This is philosophy and mathematics you prick.
Don't lump us in with those /sci/ cunts. We're closer to /dpt/ than anything else.

Philosophy, Maths & Religion board when? (bonus: programming should be allowed there)
>>
File: semen demon afterparty.jpg (168KB, 1280x720px) Image search: [Google]
semen demon afterparty.jpg
168KB, 1280x720px
How much math do I need to excel at programming?
I looked at Introduction to Algorithms but I didn't understand any of the weird math symbols.
What does U, upside down U, left facing U and right facing U mean?
>>
Can it be career advice time? Help me choose from things I like to do:

- Go further with C# / ASP.NET / Windows. It's just really easy with Visual Studio and huge libraries. I get paid to do this at the moment

- Security / pentesting / consulting (probably web apps and network)

- Hardware / low-level / C & C++ (I've had fun with RFID readers and a raspberry pi making LEDs blink). Get into the drone market?

- Pick up some new language (probably Rust) and go balls deep and be an early expert. I'd probably switch exclusively to linux jobs and drink the Red hat enterprise kool aid if I did this
>>
>>52201640
Holy fucking shit
Philosophy and mathematics
/Phi/

Why hasn't this happened yet?
>>
>>52201640
>bonus: programming should be allowed there
Only theoretical unimplemented languages
should also include magic so we can talk about conjuring the spirits of the computers with our spells
>>
>>52201662
Look up set theory notation

I think CLRS even covers that in the appendix
>>
>>52201679
Maybe we can finally fix that bug where OP is a faggot
>>
>>52201679
/dpt/ and programming in general are more maths/philosophy than they are technology

If magic was real wizards would literally be programmers
>>
>>52201710
/dpt/ is 90% shitposting about languages and frameworks and 10% off topic shit.
>>
>>52201710
>If magic was real wizards would literally be programmers
Alchemists that make potions by reading a book with instructions are script kiddies/coders/code monkeys.
Alchemists that make new kinds potions are "Computer scientists"
>>
>Care to explain why you haven't paid your debt?
>You can't have a negative amount of things, here let me show you my apples.
>>
>>52201710
>If magic was real wizards would literally be programmers
lisp would be arcane magic, algol would be elemental magic
>>
>>52201695
>faggot
>>>/b/

At least call him an HIV incubator or something. You just sound like an edgy retard.
>>
>>52201794
>arcane magic
>elemental magic
What is the difference?
What would Erlang be?
>>
>>52201796
Ridiculous, I'm part of anonymous now, these are my privs
>>
Anyone else want to suck a trap's feminine dick and see him get embarrassed?
>>
>>52201825
algol deals with the earthly and the physical, the things you can actually touch, like the earth, water, fire, wind and positive numbers

lisp deals with the occult and immaterial, such as contacting demons, owing debt or reading people's thoughts
>>
>>52201911
Don't be gay, lad.
>>
>>52201030
Something that draws what I draw only zoomed so I don't need to make a screenshot and zoom in to look at what I've drawn
>>
>>52201932
>not wanting to eat a girl's cock
I think YOU are gay
>>
>>52201949
What's wrong with Gimp?
>>
>>52201972
>him
>girl

...what?
>>
>>52201992
a girl can identify as him and still be feminine
>>
>>52201911
>not degrading them by forcing them to wear a chastity belt so they can only feel pleasure from their boipussy

are you gay?
>>
QUICK POST CODE TO FIND THE PRODUCT OF A LIST OF NUMBERS MULTIPLIED TOGETHER IN YOUR LANGUAGE OF CHOICE
>>
>>52201975
I'm drawing everything using algorithms
>>
>>52202031
product
>>
>>52202015
>not forcefully painting their cute soft toes and then tickle them until they pee or cum.
>>
>>52201442
you realize you called me here right?
>>
>>52202031
total=0
for num in list:
total = total * num
>>
>>52202031
List.fold (*) 1
>>
>>52202031
import QUICK POST CODE TO FIND THE PRODUCT OF A LIST OF NUMBERS MULTIPLIED TOGETHER IN YOUR LANGUAGE OF CHOICE
>>
>>52202031
int total = 0;
unsigned i;
for (i = 0; arr[i] != NULL; i++)
product *= arr[i];
return product;
>>
>>52202040
I hope you're using a scaling matrix.

>>52202060
That sounds nice but my toes probably aren't cute enough for anyone to do it.
>>
>>52202031
(defun prod (list)
(cond
( (cdr list) (* (car list) (prod (cdr list)) ))
(t (car list))
)
)
>>
>>52202031
nums = input().split(" ")
n = 1
for item in nums:
n = n * item


>>52202072
n * 0 is always 0
>>
File: uui9.png (481KB, 626x988px) Image search: [Google]
uui9.png
481KB, 626x988px
>>52202031
function meme(list) {
var temp = 1;
for(var i of list) {
temp = temp * i;
}
return temp;
}


i think it's right, i haven't tested it though tbqh senpai.
>>
>>52202122
>n * 0 is always 0
I realised my mistake

what an idiotic simpleton of the lowest calibre I must appear haha
>>
>>52202115
Why would I need a "scaling matrix"?
I just need to see the individual pixels of what I've drawn
>>
>>52201564
wouldn't division be a better way to show this?
>>
>>52202240
Nevermind I'm dumb, it's the same either way
>>
>>52202229
To scale up the image duh.
>>
>>52202085
I want python babbies to leave
>>
D is literally perfect
>>
>>52202354
'no
>>
>>52201688
>an appendix
Get Naive Set Theory by based Halmos.
>>
>>52202293
My algorithm just uses a zoom factor since I'm only doing pixel-perfect scaling
>>
>>52202398
me, i need a job to pay for my crossdressing fetish

i can write whatever you want so long as it's in standards compliant C89
>>
>23 posters
>104 replies
/dpt/ is just a circle jerk tbqh
>>
>>52202398
me! i'm not very smart but i browse /sci/ alot
>>
>>52202417
>C89

Why not C90?
>>
>>52202354
It's good but it's not perfect
D + Ocaml + F# would be perfect
>>
>>52202460
>muh computation expressions
>>
>>52202444
same thing
>>
>>52202431
Now it's just 22 posters.

Somebody had all his posts deleted. I hope he's ok.
>>
>>52202431
the poster number didn't increase when you posted this
it's a circlejerk and you're participating
>>
>>52201062
kill yourself
>>
trying to get better at java, so I'm trying to do a game of life with the SWT library and eclipse

I have a main class, and each different state of the program is enclosed in a different class that I was going to each have it's own shell

so it would:
>do thing
>user wants other state, maybe menu
>open new shell with new menu class
>close current shell
>user does stuff on menu
>moves to new state
>opens new shell, makes new class
>closes old shell
>user does stuff on new shell

Problem I ran into here is that I can't seem to find a way to get my main() to keep track of if the shells are disposed or not at any given time, i.e. whether the program is active or not
I thought about using global variables for the shells and setting them to a new one when each class is created, but it looks like global variables have to be static in java

is StackLayout what I want here? single shell, multiple layouts I can swap between through the different logic in the program? I'm thinking the first way I tried to do it would make potentially make a lot of objects and eat a lot of memory worst case.

honestly, I just want to get this graphical and display stuff out of the way so I can get to the fun of programming the main logic
>>
>>52202540
Don't ever fucking reply to my comment again unless you're contributing to the thread.
>>
>>52202553
>I just didn't fall for the abstract meme.
>in a motherfucking programming thread
>>
File: 1432691158015.jpg (1MB, 4961x4961px) Image search: [Google]
1432691158015.jpg
1MB, 4961x4961px
>>52201062
haha how are negative numbers real nigga just subtract by a positive number
>>
Threadly reminder that you should not refer to the act of programming as coding. It is improper and makes you look like a 15 year old

You are a programmer, not a coder

Developer is okay
Magician is okay
Software Engineer is okay
Software Architect is okay
Software Alchemist is GOAT
>>
>>52202736
what about computer alchemist?
>>
>>52202736
Is Conjurer of Algorithmic Spells ok?
>>
>>52202736
no one here is saying coding/coder unironically you retarded fucking assburger
>>
>>52202736
Coder is synonymous with programmer, stop being fucking autistic.

I don't like that manspreading, cis, diversity, multiculturalism, etc. are words, but they are.
>>
>>52202472
No, C90 adds __STDC_VERSION__
>>
>>52202814
What is that for?

preprocessor if statements?
>>
>>52202803
>manspeading is a word
>cis is a word
fuck off
>>
>>52201062
look at 2:20 and stop being so fucking retarded

https://www.youtube.com/watch?v=s1i-dnAH9Y4
>>
>>52202834
Yes, unless you are some weirdo that printfs it
>>
>>52202836
https://en.wikipedia.org/wiki/Cis%E2%80%93trans_isomerism
>>
/dpt/ can't write a function that shuffles an array
>>
>>52202938
why tho?
>>
>>52202938
>/dpt/ can't do my homework for me
>>
https://www.youtube.com/watch?v=OAoLCXpao6s
>>
>>52202938
void shuffle(int *arr, size_t n)
{
if (n < 2)
return;

int tmp = arr[0];
arr[0] = arr[1];
arr[1] = tmp;
}
>>
>>52202938
import random
def shuffle(x):
random.shuffle(x)
return x

x = shuffle(x)
>>
>>52202842
You can't have a negative amount of apples.

I understand the idea of negative numbers, but they are describing something that can't exist, therefore they are a meme.
>>
>>52203023
probably a shit quality random
>>
>>52203032
Your girlfriend is a meme
>>
>>52203032
>le apple meme
see 4:30 in >>52203006
>>
>>52203032
Calm down man, you don't have to do this
Just put the apples down
>>
>>52203034
It uses the mersenne twister so no
>>
>>52202938
Shuffle a dict in 5 lines
>>
>>52203070
D E P R E C A T E D

http://xorshift.di.unimi.it/#quality
>>
>>52203061
You can't be less than 0 meters above sea level, again it's describing something that can't exist.

You're either above or below sea level, pick one.
>>
>>52203103
Good enough for 99% of use cases to be honest family, for example... for shuffling an array
>>
>>52203134
kill yourself

the starting point is arbitrary

if the ocean is 100 meters deep and you have it as 95, 100, 105 meters above the bottom of the ocean

then if you change your reference point to the sea level you subtract each value by 100

and what do you get

lo and behold -5, 0, +5

kill yourself
>>
File: assburger king.jpg (69KB, 650x452px) Image search: [Google]
assburger king.jpg
69KB, 650x452px
>>52203134
>>
>>52203169
>lo and behold 5 meters below sea level, 0 meters below sea level, 5 meters above sea level

Negative numbers are a meme. Accept it, anon.
>>
Lisp is kind of fun
>>
>>52203230
kill yourself retard
>>
>>52203261
Don't be frustrated because anon is right. I had hard time accepting that negative numbers are a meme too.
>>
File: 18211.png (98KB, 400x300px) Image search: [Google]
18211.png
98KB, 400x300px
>>52203302
>>
>>52203322
He's having a giggle anon
>>
Daily reminder that if your language of choice is not on this list you should probably give up and kill yourself:
- C++
- C#
- Lua
- Python
- Elixir
- Haskell
- Bash
- Clojure
- D

http://jackstouffer.com/blog/nd_slice.html
>>
File: Depressed-Man.jpg (1MB, 2048x1450px) Image search: [Google]
Depressed-Man.jpg
1MB, 2048x1450px
>no qt bf to keep me company and cuddle while i work on stuff

life is depressing desu
>>
>>52203361
No love for R?
>>
>>52203393
Let's pair-program
I hope you like D :^)
>>
>>52203322
You can't have a negative number of things.

Jesus Christ. What's so hard to understand?

You can't have a negative amount of money, you either have it or you don't. You can't be a negative distance above sea level, you're either above it or you're not, when referring to temperature 0 should start at absolute zero and go up from there.
>>
>>52203412
memest of memes
>>
>>52203393
>tfw you realise you unintentionally said hurtful things to your bf-interest

just fuck me lads
>>
what's the difference between fullscreen and maximised borderless window?
>>
>>52203393
Partners suck it isn't until you having a partner do you wish you were lone wolfing it
>>
Going through all the mid level intro algorithms
> median find
> TST
> topo sort/BFS

What next?
>>
File: assburger.jpg (67KB, 500x511px) Image search: [Google]
assburger.jpg
67KB, 500x511px
>>52203443
kill yourself
>>
>>52203473
Fullscreen windows can change the resolution.
>>
>>52201126
here's your reply now fuck off
>>
>>52201126
pyfags will defend this
>>
>>52201595
That's not a theory you nigger that's a fact
>>
>>52203616
No, it's a theory. It's impossible to prove that 0 is an integer because 0 isn't even a number
>>
>>52203443
>what is a reference point
>>
>>52203682
The definition of an integer is a number that can be written without a fractional component. 0 does not have a fractional component.
>>
>>52203682
>0 isn't even a number

What am I reading?
>>
I refuse to believe you idiots lack the most basic levels of abstract reasoning while frequenting a fucking programming general.
>>
When creating a class in C++. Is it better to deep copy an array or just copy the pointer?
Example:
node &operator=(node &rhs)
{
//Deep copy the node
return *this
}

or
node &operator=(node *rhs)
{
this = rhs;
return *this;
}
>>
Has anyone here made their own kernel?
If so, post pics.
>>
>>52203774
You can't pass a pointer to a copy assignment operator.
>>
>>52203820
Huh. So you can't. Alright but I just tried this and this works.
node &operator=(node &rhs)
{
this = &rhs;
return *this;
}

>>
>>52203810
Yeah, check it out here
https://www.kernel.org/
>>
>>52203974
Sup Torvalds.
>>
>>52201062
This. Natural numbers are well-founded on the Peano axioms, whereas the integers require a partition of NxN which does not justify the mapping of nonnegative integers to the naturals all that well.

>>52201077
>implement the OO design patterns in a non OO-oriented language
Even if you can, you shouldn't. OOP belongs to the loo.
>>
>>52201640
>Philosophy
So a bunch of retards chime in, saying philosophy is meaningless while posting sophomoric junkie shit about the mind and consciousness
>Religion
Fedora dickwaving threads galore
>>
>>52204004
try writing games without OOP
>>
>>52202031
(reduce #'* list)


>>52202116
>separating ending parens like a blubfag
>>
>>52201640
>>52201669
fags

>>>/sci/

fucking retards i fucking hate you

you are not welcome in /dpt/
>>
>>52204105
It's possible and you're retarded if you think it isn't
>>
>>52202031
foldl1 (*) list
>>
>>52204126
are you sure you know what OOP is senpai
>>
>>52204105
>muh gaems
>>>/v/
>>
>>52204157
/v/ doesnt make video games
>>
>>52204105
This meme is getting tiring. You're the same faggot who was trying to argue ECS was necessarily OOP in /agdg/, aren't you?
>>
>>52204105
The Doom engine was originally in C, git fucked
>>
>>52204230
see >>52201077
>>
>>52204118
>not liking your parens spaced neatly
and I'm the blubfag?
>>
>>52204242
What are you trying to say here
>>
>>52204264
nothing is stopping you from implementing the useful bits of OO in C.
>>
>>52204169
They care about games, and come to /g/ because of games.
>>
>>52204300
You think structs are object-oriented or something?
>>
>>52204376
it's not about structs, it's what you do with them
>>
>>52204376
you can abuse them to an object oriented effect, yes.
>>
Classifying things by whether or not they are object-oriented or functional or procedural or whatever is fucking stupid, because it has no bearing on the quality of the code and nobody can agree on the definition of any of those terms anyways.
>>
>>52204410
you probably can't even define half of those big words you just used
>>
>>52204441
That's my point, you fucking idiot.
>>
>>52204441
That was his point dumbfuck.
>>
>>52204450
>>52204456
you're angry at me for saying something insulting obvious, right?
>>
>>52204385
>>52204402
They're data structures, and their state is open to any change. Objects, however, contain data whose structure is obscured from direct access and whose mutation is constrained to methods provided by the object. There's also the separation of class and instance.
>>
>>52204486
>Objects, however, contain data whose structure is obscured from direct access
if you need to hide library-specific implementation details of an object, just add a pointer to an opaque struct typedef
>>
>>52204464
No, it's because you're dense as fuck.
>>
>>52204522
I get that a lot.
That must make you angry indeed.
How dare someone like me be allowed to post on 4chan! teehee
>>
>>52204541
If you're allowed to shitpost, I'm allowed to call you out.
>>
>>52204551
nobody cares desu senpai
>>
>>52201126
>>> 1 - .9
0.09999999999999998
>>> type(1 - .9)
<class 'float'>


Nobody ever said they were reals
>>
>>52204710
>>> from decimal import Decimal
>>> float(1 - Decimal('0.9'))
0.1
>>> type(float(1 - Decimal('0.9')))
<type 'float'>
>>>
>>
>>52204743
Great?
>>
I went to a CC class to learn c++, and I want to get better at it. What's a good book to do programming questions?

http://www.amazon.com/Starting-Out-Control-Structures-Objects/dp/0133769399/ref=sr_1_1?ie=UTF8&qid=1451798163&sr=8-1&keywords=c%2B%2B+tony+gaddis

This is the book we used.
>>
Relative noob here.

Making a text-based spaceship RPG combat engine thing because I want to, and have a couple questions. Using Python.

>1. How do I modify inherited methods from other classes? I want to add an argument to a specific subclass - do I have to redefine the method entirely?

>2. I've heard people say that if you're using isinstance(), you're doing something wrong. But the way my game works, I need to call certain methods of certain subclasses(say, calling the shieldRegen method of a ShieldGenerator subclass) from a list of objects (other parts of a ship) that are mostly different classes(shield generator, turret gun, life support, etc.). How else could I do this other than iterating through and checking if it's the specific subclass I'm looking for?
>>
>>52204928
As for 1), you can just call whatever method you want as it will work as long as the method exists correctly and will break if it doesn't

As for 2), a correct OOP >design< doesn't rely on isinstance(). Change your design

Instead of
class Cat(Animal):
def eatMice (self):
pass
class Dog(Animal):
def eatSquirrel (self):
pass
class Alligator(Animal):
def eatCat (self):
pass

#...
animal = ...
if isinstance(animal, Alligator):
a.eatCat()
elif ...


Do it like
class Cat(Animal):
def eat (self):
self.eatMice()
class Dog(Animal):
def eat (self):
# etc...

#...
animal = ...
animal.eat() # <- no isinstance() check done, OR NEEDED


I'm going to have to see your specific case to decide how you might refactor it.

Note: This design is actually something I disagree with. I prefer the functional approach to the so called "expression problem"
http://c2.com/cgi/wiki?ExpressionProblem
>>
File: trooth.jpg (160KB, 500x377px) Image search: [Google]
trooth.jpg
160KB, 500x377px
>>52204777
>programming questions
contribute to open sources
>>
>>52204928
>I want to add an argument to a specific subclass
Why? The point of subclassing is that the objects have the same interface with different behaviour. You probably have a more important flaw in your design, and having to do this is a "symptom". Classic XY problem.

>But the way my game works, I need to call certain methods of certain subclasses(say, calling the shieldRegen method of a ShieldGenerator subclass) from a list of objects (other parts of a ship) that are mostly different classes(shield generator, turret gun, life support, etc.)
Have an update method that is shared between all those classes. The logic for regenerating shields goes in the shield generator's implementation of that method.
>>
>>52204004
>Natural numbers are best and negative numbers suck cause they don't map directly to natural numbers

nigga wut thats some circular shit
>>
What useful data structures should I learn aside from linked lists and binary trees?
>>
>>52205154
0 isn't negative so there's one more natural number than negative number
>>
>>52205165
Hashmaps
Unless you're studying for a CS exam, learn what you need for something you're making, or learn what is interesting to you, don't just stockpile useless knowledge
>>
>>52205168

Who cares? Why are natural numbers the benchmark for BEST NUMBERS

But at least we can all agree that real numbers are the fucking worst.
>>
>>52205168
zero doesn't real
>>
>>52205186
Make that CS exam or interview
>>
>>52205154
Integers are constructed from natural numbers, not vice versa. It's simple abstract algebra. Integers are constructed as equivalence classes of pairs of natural numbers (a,b) such that (a,b) and (c,d) are equivalent iff a + d = b + c. Then the inverse of (a,b) is (b,a), (a,b) + (c,d) = (a+c,b+d), and (a,b) * (c,d) = (ac+bd,ad+bc). The idea is that (a,b) represents the integer a-b.
>>
>>52205165
Stacks, B-Trees, and Hash Tables/Maps
>>
>>52205186
What's the best way to handle a hashmap collision?
I read one source that claims every hash cell should contain a linked list to dump collided entries
>>
>>52205187
>real numbers are the fucking worst.
Ya bet

>>52205207
Shure
>>
>>52205225
Right, so integers are just as well defined as natural numbers, so why how are they more meme than natural numbers? If anything natural numbers are some 90s kid hipster bullshit.

>DAE think Queen is the best band and natural numbers are the best numbers
>>
>>52201077
>there are people ITT who think C is low level and ancient

To be fair, when it comes to languages in general there are few who boast C's longevity, and a plethora that wish they could.
>>
>>52205258
>plethora
stop using big words
>>
>>52203322
hahah man this meme is awesome xD are you from le 9gag too????
>>
>>52205225
This is called inverse completion by the way.
https://proofwiki.org/wiki/Construction_of_Inverse_Completion

>>52205251
Because natural numbers are connected to the concept of recursion by the Recursion Theorem, and induction by the Principle of Mathematical Induction, and both these concepts require a base case, representing 0, and an induction step, representing the successor function n -> n + 1. The successor function s has to be injective, meaning s(m) = s(n) => m = n, and 0 has to be outside the image of s, meaning there is no natural number n such that s(n) = 0. The notion that 0 is outside the image of s is fundamental to induction (and therefore recursion). But if you start with integers instead of natural numbers, 0 loses its meaning and uniqueness.
https://proofwiki.org/wiki/Axiom:Peano%27s_Axioms
>>
>>52205336
https://proofwiki.org/wiki/Principle_of_Recursive_Definition

Polite sage for double post
>>
>>52204777
>What's a good book to do programming questions?

Try Effective C++ & Exceptional C++, go from there.
>>
>>52205240
>I read one source that claims every hash cell should contain a linked list to dump collided entries

That's a pretty good choice.
>>
>>52201244
This sounds more like real life:
>interviewing candidates
>can prove cook-levin theorem
>can prove the undecidability of the halting problem
>can't write a basic sort
>doesn't know what a for loop is
>fails miserably in real world programming
>>
>>52205131
>You probably have a more important flaw in your design, and having to do this is a "symptom".
Probably. I'm not pretending like I know enough to not fuck this stuff up, that's why I'm asking.
Here's essentially what I was thinking I would do.
I'd have a Part base class, with an __init__ function that has all the arguments that every part would need.
Then I'd have a ShieldGenerator subclass that has a regen_amount argument that controls how much of the shields would regenerate every time an update method was called.

What should I change about that?
>>
>>52201396
1. Zero can be divided by any number, since anything times zero is equal to zero.
2. An even number is a number which can be divided by two.
3. Zero is even.
>>
>>52205385
Oh, constructors are not methods. It's normal for subclasses to take different parameters in their constructors.
>>
>>52205411
Okay, got it. Had to look up what a constructor was, but I get it now. Thanks for the advice!
>>
>>52205408
Isn't it usually restricted to natural numbers? I think it is...
>>
>>52205490
No, parity is defined for the integers.
>>
How do I perform math on numbers larger than 18,446,744,073,709,551,615?
>>
>>52205533
Use floating point or a bignum library.
>>
>>52205533
"Bignum" arithmetic. Basically you just represent numbers as lists of integers and handle carries between them when you're doing arithmetic yourself. You'll find support and/or libraries for it in any language.
>>
>>52205533
python
>>
File: img.png (1MB, 1600x7680px) Image search: [Google]
img.png
1MB, 1600x7680px
I'm was playing around with an encryption algorythm and I think I messed up but, I'm going literally insane because I cannot find where the mistake is, halp...

You can see all in the picture, to the bottom. For some reason the hex value "04" is recurring and it's unexpected for me.
I checked 3 times all the operations but I didn't find any errors, though since I'm kinda sleepy I cannot exclude that I missed it.
Did I really messed up or did I just accidently created something interesting?

If there're no mistakes, it should be possible to create a decryption algorythm from this, right?

I'm trying to make a program for it using Perl by the way, if you have better suggestions let me know, I just started learning Perl but if there's something better for this kind of stuff I'd gladly try it.
>>
>>52205533
Been a while since I used gmp but something like this should do:
static const char *x = "18446744073709551620";
static const char *y = "18446744073709551620";

auto main(int, const char **) -> int
{
mpz_t a, b;

mpz_init(a);
mpz_init(b);

if(mpz_set_str(a, x) != 0 || mpz_set_str(b, y) != 0)
throw std::runtime_error("faggot");

mpz_add()

mpz_clear(a);
mpz_clear(b);

return 0;
}
>>
>>52205597
i don't think that does what you think it does
>>
>>52205597
>mpz_add()
lel
>>
>>52205597
>auto main(int, const char **) -> int
>mpz_add()
wat
>>
>>52205609
it does exactly what i think it does
>>
>>52205240
Linked lists are easy and don't take up much room when there's few collisions. However vectors are more efficient for adding and removing so if for some reason you have a lot of collisions you could use that
>>
typedef enum { male, other } gender_t;


:^)
>>
File: VJjYPSG.png (17KB, 756x380px) Image search: [Google]
VJjYPSG.png
17KB, 756x380px
I absolutely despise databinding.

I really really hate it.

But I've gotta do it if I want this to not be utter shit..

I have an observable collection of objects, each object has an "artist" property and an "album" property.

How do I bind all the different artists to my artists datagrid, all the albums associated with the selected artist in the album datagrid, and then all the songs in that album?

I know how I'd do it in codebehind, using lambdas to jam stuff in, but that's fucking lazy and dumb. I need to databind but I don't know how to databind certain properties.
>>
>>52205790
just write it in C
>>
Linux brothers!
How do you guys code for large projects?
I miss the semantic highlighting of Visual Studio.
>>
>>52205808
hehehehehe
>>
>>52205790
>databind
>datagrid
>codebehind
What are these buzzwords?
>>
File: 295.jpg (13KB, 177x278px) Image search: [Google]
295.jpg
13KB, 177x278px
>>52205808
>>
>>52205827
>These very specific words to describe very specific concepts generally are buzzwords
>>
>>52205717
But what if I'm both male and female, shitlord?
>>
>>52205827
>>52205843
no really, what the fuck is databinding?
>>
>>52205858
Take a wild fucking guess.

See if you can take the giant mental leap to split that compound word down the middle and come up with a definition.
>>
You have one minute to tell me why OOP is bad.
>>
How can I apply what I learned in my Algorithms/Data Structures courses to real-life scenarios before I work in the industry?
>>
File: stupid goy.jpg (16KB, 280x390px) Image search: [Google]
stupid goy.jpg
16KB, 280x390px
>>52205336
>>52205353
>going on an autistic rant just to say negatives don't real
>>
>>52205881
More like POOP lol
>>
>>52205881
It doesn't model how computers work.
>>
>>52205871
Binding data?
>>
>>52205897
Solid argument, I'm convinced
>>
>>52205881
OOP isn't bad, but forcing OOP for everything and adopting cargo cult mentality for all your solutions is retarded.
>>
>>52205881
Smelling like shit and curry is uncalled for in a modern working environment.
>>
File: 986.jpg (12KB, 232x231px) Image search: [Google]
986.jpg
12KB, 232x231px
>>52205901
Well done you, gold star.
>>
What is the best language to edit raw byte data (in hex)?

I just found this:
https://golang.org/pkg/encoding/hex/

Though I never heard this lang before, by any chance is there something similar to this but for c++ or c#?

It can be probably done using arrays and ASCII decoding (I guess), but I'd rather use something that directly works on bytes.
>>
>>52205881
This >>52205909 and the fact that nobody can agree on what OOP is, which compounds the cargo cultist problem.
>>
>>52205911
what does binding data do in the context of computers, senpai?
>>
>>52205909
>look at me, i'm le rational moderate! extremism is just so bad!
gb2 >>>/reddit/ fucking fence-sitter
>>
>>52205923
>directly works on bytes
Any file I/O ever?
>>
What's the most easiest language to learn?
>>
>>52205925
https://msdn.microsoft.com/library/ms752347%28v=vs.100%29.aspx
>>
>>52201091
https://github.com/AG-Systems/MicroProjects
>>
>>52205923
>best language
It literally doesn't matter what language
>>
>>52205954
C
>>
>>52205923
>language
Just use ghex or some other hex editor
>>
I asked this question in /wdg/ but I'm pretty sure I'll get better and faster answers here.

What does /g/ think about WordPress ?
>>
>>52205954
ASM, Common Lisp, C++, Haskell
>>
>>52205954
Just use python.
>>
>>52205955
So it's an enterprise buzzword for a babby version of reactive programming?
>>
>>52205954

Python or Java.
>>
>>52205974
>Buzzword
I don't think you know what that word means.

https://en.wikipedia.org/wiki/Data_binding
>>
>>52205988
Java is a terrible beginner's language. Actually, it's a terrible language in general.
>>
Missed the negative number meme. Can someone fill me in?
>>
>>52206004
"Data binding" just sounds like corporate (Java, C#, Delphi) jargon for reactive programming to me.
>>
>>52206087
>Implying "reactive programming" isn't corporate jargon
>>
NEW THREAD!

>>52206105
>>52206105
>>52206105
>>
>>52206119
Dumbass
>>
>>52206101
I think it's a pretty apt and descriptive name, it is about programming by making things automatically react to phenomena. Whereas "databinding" makes me think of databases and "business logic" and that kind of stuff.
>>
>>52206087

That's the rub, basically. GUI elements get automagically updated when the properties they are bound to change.
>>
>>52205954
C
The issue is once you know it, it can be difficult to do something because it's a low level language. But the good thing is that is force you to learn how things works instead of using hight level stuff.
>>
>>52205529
Yup. Looked it up.
Thread posts: 301
Thread images: 24


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