[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 41
File: 1458749345763 (1).jpg (94 KB, 500x701) Image search: [Google]
1458749345763 (1).jpg
94 KB, 500x701
old thread: >>53642808

What are you working on, /g/?
>>
Haskell rules
>>
>>53649121
Kill yourself, you fucking degenerate.
>>
>>53649121
I just swallowed too much saliva.
>>
File: lasers.jpg (161 KB, 900x675) Image search: [Google]
lasers.jpg
161 KB, 900x675
>>53649121
Is it possible in Java to call a method that just prints something given an object with parameters?

Like

wow.toString();


What I have right now is

System.out.print(wow.toString());


since my toString method returns a String.
>>
Writing a quick Bash script for convenience.

Quick, or so it was supposed to be. Getting the end result I want would be easy, but no, I'm instead stubbornly hitting my head against the wall because I want it to work in a particular way.
>>
File: cute blushing anime girl.jpg (2 MB, 4998x4998) Image search: [Google]
cute blushing anime girl.jpg
2 MB, 4998x4998
>>53649111
so what's actually inside the solution array? is it just the value of the maximum profit for a given length of rod, or does it actually tell you how to chop it up? the website i got this from doesn't say http://algorithms.tutorialhorizon.com/dynamic-programming-rod-cutting-problem/ got caught by new thread
>>
>>53649223
override the tostring function to call system.out.print

there's no built in method on the type object that prints to stdout
>>
As someone who has recently switched to OOP I have a question I hope you guys could help with.

In a class that has a const member, would it be possible to make it so that user inputs the constant after an object has already been made?

I get that I could make a constructor that requires an argument that would then be assigned to the const member at the creation of the object, but is it anyhow possible to just make the object, and then later on call a random setConst(); method that would accept user input?
>>
>>53649223
>Is it possible in Java to call a method that just prints something given an object with parameters?

No, unless that object happens to have a method that prints something.

Incidentally, you can just write
System.out.print(wow);
.
toString()
is called implicitly.
>>
>>53649121
kill yourself

>>53649148
kill yourself
>>
>>53649260
No
>>
>>53649260
No, that's not how const works.
>>
>>53649260
constants are constants. when you think of a constant, think of something like pi. it never changes. idk why you got it in your mind to use a constant for whatever you're trying to do but i guarantee you that you should just use a variable
>>
>>53649260
>In a class that has a const member, would it be possible to make it so that user inputs the constant after an object has already been made?

No, because then it wouldn't be constant.

I'm to sure what your goal is but it can almost certainly be implemented better without a constant attribute.
>>
>>53649247
>>53649269
I put my own definition under toString() in another class.

   public String toString()
{
String result = "Account number: " + getAccountNumber() +
"\nLoan amount: " + String.format("$%,.2f",getLoanAmount()) +
"\nYears: " + getLoanPeriod() +
"\nAnnual rate: " + String.format("%.1f",getAnnualInterestRate()) +
"%\n";
return result;
}
>>
>>53649316
>>53649328

The problem is, prof wants us to make a class Human that has random crap, including yearOfBirth which has to be a constant. The thing is, he wants us to declare it as Human randomHumans[5], and array of humans, and THEN after declaration assign all the values, including YearOfBirth which is a const.

I have no fucking clue how to do this. That's why I'm asking. I know const can't be changed, but apparently I have to make it doable.
>>
>>53649348
and you can print result right there if you don't want to write out System.out.println every time

it's probably better to make another method though, like printToString then in that method just have System.out.println(this.toString());
>>
>>53649381
that's retarded. yearOfBirth should be a variable, it should just be a variable without a setter method. reread the instructions and see if you're misinterpreting it, otherwise email him
>>
>>53649381
Either your professor is retarded or you need to work on your reading comprehension.
>>
>>53649381
for(int i = 0; i < 5; ++i) {
randomHumans[i] = new Human(yearOfBirth);
}
>>
>>53649403
>like printToString then in that method just have System.out.println(this.toString());
wow that did it, thanks!

I have

   public String toString()
{
String result = "Account number: " + getAccountNumber() +
"\nLoan amount: " + String.format("$%,.2f",getLoanAmount()) +
"\nYears: " + getLoanPeriod() +
"\nAnnual rate: " + String.format("%.1f",getAnnualInterestRate()) +
"%\n";
return result;
}

public void PrinttoString()
{
System.out.print(this.toString());
}


I'm still new to using the this keyword so I wouldn't have thought of that on my own without a lot of searching
>>
>>53649504
please stop
>>
>>53649518
in java, instance method names usually start with a lowercase but otherwise looks good
>>
>>53649545
i was thinking about that but I wasn't sure if to capitalize the "t" in toString
>>
File: 1456811224257.jpg (121 KB, 1080x1170) Image search: [Google]
1456811224257.jpg
121 KB, 1080x1170
faggot teacher changed my project from facial recognition to iris recognition

any sources you /g/ents recommend? Using Qt and openCV
>>
i have to make a version of the rod cutting algorithm that accounts for a cost of cutting.
 
int cutRod(int[] baseValue, int length, int cutCost) {
int[] bestValue = new int[length + 1];
bestValue[0] = 0;

for (int i = 1; i <= length; i++) {
int max = -1;
for (int j = 0; j < i; j++) {
max = max(max, baseValue[j] + bestValue[i - (j + 1)]);
bestValue[i] = max - cutCost;
}
}
return bestValue[length];
}

is this right? it's what i got off the top of my head but it seems a little too simple now that i think about it
>>
>>53649561
oh yeah, missed that, yep it should be capital since it's a new word, it's called camel case
>>
Is there a way to do image recognition without machine learning?

I want to make a program to automagically find a speech bubbles, white them out, and replace them with text input. Hopefully this will make typesetting quicker so I can read my Chinese cave paintings without waiting as long.
>>
>>53649604
alright.

extending to the same problem, would it be okay to put it all in one method and do

   public String toString()
{
String result = "Account number: " + getAccountNumber() +
"\nLoan amount: " + String.format("$%,.2f",getLoanAmount()) +
"\nYears: " + getLoanPeriod() +
"\nAnnual rate: " + String.format("%.1f",getAnnualInterestRate()) +
"%\n";
System.out.print(result);
return null;
}


?

I feel like this could be made cleaner.
>>
>>53649598
You should look into dynamic programming. It has a small big O and is a bit cleaner.
>>
>>53649606
Maybe use the hough transform?
>>
>>53649743
how is my solution not dynamic programming?
>>
>>53649689
It's so fucking trivial, your formatting is meaningless.
>>
>>53649774
Because I'm too tired and didn't read right. It looks alright after contemplating some more.
>>
what is this cancer

http://antiifcampaign.com/about/
>>
>>53649852
It's not totally stupid, but it's ridiculous.
>>
>>53649748
Follow up question: how are you supposed to know which model/algorithm to use for a given problem? Is it just through study or is there more of a trial and error phase to it?
>>
>>53649806
alright, thanks
>>
>>53649223

public static void PrintObject(Object o) {
System.out.print(o.toString());
}
>>
>>53649260
>I want this thing to be constant, but also, I want to be able to set it at any time.

Breh
>>
Why is this allowed?

#include <stdio.h>

int main() {
const int a = 54;
*(int*)&a = 4;
printf("a: %d\n", a);
return 0;
}
>>
>>53649852
It's saying to use polymorphism where it makes sense instead of "if (thing is of type x) do y"
>>
>>53650029
it is not, it is undefined behaviour
>>
>>53649121
What the fuck does this stupid pic have to do with programming?
>>
>>53649852
that's an http link in a https world.
>>
>>53650046
Could you elaborate on that? How is it undefined behavior?

Is the result up to the compiler writers?
>>
>>53649990
This would work by doing

PrintObject(wow);
, right?

but it uses toString() inside it so it's a method calling another method. I want to get as close to the source as possible.
>>
>>53649260
private variable, control access with const-qualified getter.
write a setter method that only works if the object has default state.
>>
>>53649852

What in god's name are they thinking?
>>
File: cute anime girls.jpg (518 KB, 900x1273) Image search: [Google]
cute anime girls.jpg
518 KB, 900x1273
>>53650066
cute anime girls improve coding efficiency by lowering testosterone levels anon
>>
>>53650099
>so it's a method calling another method

Pro-tip: methods call other methods
>>
File: K&R himegoto waifux2.png (1 MB, 1000x1400) Image search: [Google]
K&R himegoto waifux2.png
1 MB, 1000x1400
>>53650066
>being this new
Hime has a deep and abiding understanding of void * pointers and triple indirection.
>>
>>53650118
You don't belong here.
>>
>>53650076
>How is it undefined behavior?
because standard says so
>Is the result up to the compiler writers?
yes
>>
>>53650136
I know, the default methods yeah, but I'm referring to methods made by myself. Trying to use as few as possible and not having to type so much.
>>
>>53649852
>use if/switch for closed variants (ideally ADT + pattern matching but you can't win 'em all)
>use dispatch for open variants
I can't believe this isn't painfully obvious to some "programmers".
>>
>>53650176
Any java library function that prints a string from an object will be calling toString and other such methods.

All classes extend Object.

If your class does not define toString, the Object version will be used, which will almost certainly not be what you want.
>>
File: checkem.png (239 KB, 400x337) Image search: [Google]
checkem.png
239 KB, 400x337
>>53650242
indeed
>>
I'm working on something where I have a vector of a class inside another class. something like:

class class2:
private:
std::vector<class1> classes;


then in the constructor:
classes[arg1*arg2]


then I'm trying to implement functions like:
classes[x].isEmpty();


I keep getting segfaults. what am i doing wrong. I've also tried to just leave the vector with an undefined size.
>>
>>53649381
What programming language are you using? You're probably supposed to just generate null pointers in the beginning, and than call a constructor. Passing a const in the constructor would ve possible, at least in c++.
I don't know about other languages tho.
>>
>>53650403
you should do
classes.resize(arg1*arg2);
>>
>>53650457
am i at least calling the functions right?
>>
>>53650377
nice.

>>53649381
http://stackoverflow.com/questions/1423696/how-to-initialize-a-const-field-in-constructor

I think you misheard or are misreading though.
>>
>>53650519
yes
>>
threadly reminder that C sizeof(char) == 2
>>
>>53650528
Arrays calls default constructor, so he can't change it after that.

He can change it like that though

human[0] = Human(1980);
>>
>>53650542
TROLLING
2/10
too obvious
>>
What percentage of programmers can or cannot implement FizzBuzz?
>>
>>53650558
#define char short
int main(void){
printf("%d\n", sizeof(char)); //2
}
>>
>>53650558
>sizeof(char)/10
>>
>>53650576

100%. If you can't implement FizzBuzz, you are not a programmer.
>>
>>53650597
Depends, what is the percentage of java + python programmers?
>>
File: o.gif (3 MB, 426x426) Image search: [Google]
o.gif
3 MB, 426x426
>>53650576
>can or cannot implement FizzBuzz?
>or
100%
>>
Using Netbeans but I'm getting "package javax.servlet does not exist" error. Did I place my servlet-api.jar in the wrong folder?
>>
>>53649852
le smug hipster resume padding
>>
>>53650626
Is it added to your project/workspace/dependency system (if applicable)?
>>
>>53650576
I looked this up.
wtf do people really not know how to do this and still try to get a programming job?
>>
>>53650670
I wouldn't hire the guy who made that shit
>>
File: 1449756574386.jpg (3 MB, 3264x2448) Image search: [Google]
1449756574386.jpg
3 MB, 3264x2448
>>53649852
only C spergs program like that, it's a complete non-issue to any sensible programmer
>>
>>53650696
Pretty sure it's a memeroo
>>
>>53650690
That was it. Thanks anon, you're a cool guy.
>>
>>53650696
yes and then they blame it on the patriarchy when they don't get hired
>>
Is it stupid to only use breakpoints for debugging?
>>
>>53650604
this

>>53650696
a surprisingly high percentage will try to bullshit their way into getting a job, or have their head so far up their ass that they think they don't need to be able to do the simplest problem-solving tasks in order to be a programmer
>>
>>53650760
I'd expect the god damn intern that debugs our shit code and gets us coffee to be able to do that.
>>
>>53650748
What do you menan?
>>
>>53650748
What else would you use them for?
>>
>>53650820
I mean like, my professor makes you use only cerr for debugging, but I think it's way better to use breakpoints instead because you can see the values of variables on the fly without having to write in any code.
>>
>>53650852
Being able to use a debugger is important, being able to use gdb is an important skill as well.

"Put a print statement near where you think the problem is happening" is the brute-force fallback that everyone should know - it's intuitive, after all.

Debugging lets you verify state. Whether you do that live, or by printing out a bunch of stuff, or by running the program and viewing the output...all that matters is what you're more productive/less destructive in doing.
>>
>>53650852
What >>53650902 said about printing. Maybe your prof just wants you to print to stderr when you are using debug print statements since it is good practice.
>>
>>53650852
you will want some assertions, prints to err or something like that at some point though. in more professional environment you won't be always able debug it live if a bug occurs. and even if you are programming alone, those error checks will make it faster to debug

debuggers are golden though. learn how to use them
>>
>>53649577
train a classifier
>>
>>53649121
Stop this programming trap meme fucking fag.
>>
>>53650118
b..but I heard testosterone is actually good for awareness, logic and mental rotation, anon...
>>
>>53650998
traps a qt

t. programmer
>>
>>53650902
>>53650930
>>53650944
Thanks, that's fair enough. I guess I've just gotten used to having complete control of my environment.
>>
File: 1443797243390.png (269 KB, 600x500) Image search: [Google]
1443797243390.png
269 KB, 600x500
>>53651054
Doesn't sound like a healthy relationship...
>>
File: cat.jpg (286 KB, 1024x768) Image search: [Google]
cat.jpg
286 KB, 1024x768
Why is /g/ so fucking gay?
You fucks rival /v/.
>>
>>53651158
it's literally 1 samefag trap fag
>>
File: rorschach on traps.jpg (2 MB, 1277x3197) Image search: [Google]
rorschach on traps.jpg
2 MB, 1277x3197
>>53651158
traps aren't gay
>>
>>53651181
Manhattan is just embarrassed and in denial.
>>
>>53651158
Because they're fat neckbeards who never got the attention they were looking for from women, and realized with this new generation of 'muh acceptance' bullshit that they could finally get some attention from other faggots just as brainwashed, satisfying that long dreamed of sense of being wanted.
>>
>>53651158
there is literally nothing gay about loving feminine cocks.
>>
File: B_lLJErWwAAnRkQ.jpg (46 KB, 519x657) Image search: [Google]
B_lLJErWwAAnRkQ.jpg
46 KB, 519x657
My heart races whenever I remember scratch language is a thing
>>
>>53650597
thats the dumbest thing i've ever seen
>>
>>53651255
prove it fgt

You want to start this shit?

sizeof(char) == 2 I'm not shitting you
>>
File: 1457978978891.jpg (98 KB, 600x719) Image search: [Google]
1457978978891.jpg
98 KB, 600x719
Give me your best programming memes.
>>
>>53651403
I could dump a ton of CS grad's, but I'm sure people would appreciate if I just started another thread for it.
>>
>>53651403
haskell is a programming language
>>
>>53651403
haskell
>>
Hey guys I wanna make a game, what language should I learn?
>>
File: Practical_Language_Comparison.jpg (2 MB, 2100x1400) Image search: [Google]
Practical_Language_Comparison.jpg
2 MB, 2100x1400
>>53651403
>>
>>53651221
ploblem
>>
>>53651282
6.5.3.4.3 for c99
>>
>>53651461
Malbolge or Piet, Piet if you want good graphics.
>>
>>53651461
C http://pastebin.com/AcmcNzMX
Or Javascript/Canvas.
>>
>>53651461
SDL, OpenGL, GLEW, SFML, C++, C, Assembly, learn linear algebra, complex numbers, and basic physics. You'll get there.
>>
>>53651472
i detect no bias in this image whatsoever
>>
>>53649689
dont do this
>>
File: ThumbsUp.jpg (46 KB, 434x474) Image search: [Google]
ThumbsUp.jpg
46 KB, 434x474
>>53651158
That's a really realistic fursuit, anon. Did you make it yourself?
>>
>>53651502
You could have just stopped your namedropping at C++ and SDL if you weren't trying to be a discouraging sperg.
>>
>>53651472
kek

it's funny because it's true
>>
I want to get started with JavaScript. Where should I start?
>>
>>53651554
Honestly anon do we need another half finished game out there? Start with Unity or UE4 if you actually want to make a game.
>>
>>53651502
literally this

and trigonometry and calculus

fucking murritards
>>
>>53651582
make chrome extensions or node.js apps
>>
>>53651525
Why? Original anon here.
>>
>>53651499
Can I make a standalone app in javascript? I thought it was for web browsers only.

>>53651502
Nice memes
>>
>>53651554
seriously if it sounds like too much for you you should literally do >>53651599 because that's all your stupid ass can do, make scripts for a prebuilt engine and use drag and drop gui tools
>>
>>53651630
meme.js
see >>53651613
>>
Is there any algorithm that rates the randomness of a shuffled deck?
>>
>>53651661
you can test a set of shuffled decks, not just a single one. any single shuffled deck is perfectly "random"
>>
void function(void) {
static int *array = NULL;
static bool array_generated = false;

if (!array_generated) {
array = malloc(10 * sizeof(int));
for (int i = 0; i < 10; i++) {
array = i;
}
for (int i = 0; i < 10; i++) {
printf("%d ", array[i]);
}
}
array_generated = true;
}


The array should stay with the values, yes? If I call the function 3 times, it will build it and print it the first time, then just print it the second two times?
>>
File: bananas.jpg (333 KB, 1238x1280) Image search: [Google]
bananas.jpg
333 KB, 1238x1280
>>53651502
>>53651604
It shouldn't take more than 5 years going at it for 3 hours a day, right?
>>
>>53651661
>>53651694
https://sbseminar.wordpress.com/2008/01/14/what-is-total-variation-distance/
>>
>>53651646
>thinks I'm the person who asked the question despite having the foreknowledge to isolate the only two things he said that mattered.

You're too dumb to pretend at being elitist, sorry.
>>
>>53651717
fucking retarded sperg, i can entirely validly direct the "you" at him despite knowing that you are not him
>>
>>53651706
it'll take you at least one or two decades to get a game on this level

https://www.youtube.com/watch?v=Ze9G4rCxiyU
>>
>>53651697
It won't print a second time since it is in the !array_generated check. Move that print out of the if statement. Also you better be freeing that array somewhere, you wouldn't want a memory leak.
>>
>>53651697
yes
>>
File: bocchi.png (34 KB, 193x316) Image search: [Google]
bocchi.png
34 KB, 193x316
>>53651765
3 hours a day?
>>
>>53651747
Sorry, no. Hide your shame now.
>>
>>53651778
three hours a day, two or three decades
>>
>>53651461
It depends on why you are looking to make a game.

Do you want to learn from the bottom-up about rendering, game loops/logic, etc.? The coding styles/conventions and ideas that go into that?

Or do you have a game idea that you want to bring to life?

The former favors "pick an API to draw to screen" like SDL or SFML and go.

The latter favors "use unity."

There are compromises as well.
>>
int rand(){
return 42;
}


prove that output of this function is not random /dpt/
>>
>>53649121
>Draw a girl
>Call it a boy
Why is this allowed?
>>
>>53651806
True randomness doesn't exist.
Moving on.
>>
>>53651789
>>53651765
That looks like it could be done in 2 years at 3 hours a day imo. It depends how deep you're going with the language.
>>
>>53651806
It's a mathematical function with no inputs => it's a constant => it cannot be random.
>>
>>53649121
Where is hime tickling punishment?
>>
>>53651848
even much less than 2 years if you're not a newbie. the decades thing is just a joke in reference to this notion that it's a practically impossible task to make a game without using a shitty babby engine.
>>
I'm making an imperative Haskell clone because otherwise my life is meaningless
>>
>>53651806
Because I can predict it's output 100% of the time.
>>
>>53651852
>output of this function
otherwise you might as well say 'it returns 42, it is not random'
>>
>>53651844
>what is the atmosphere
>>
>>53651883
>100%
What about cosmic bit flips?
>>
>>53651883
predict it an infinite time, then I will believe you
>>
>>53651883
how do you know it won't be some other number the next time you call it, without knowing the source code
>>
>>53651878
>imperative Haskell clone

Can't you accomplish that by just writing in regular Haskell and dumping everything in the IO monad?
>>
>>53651806
>>53651910
I can create statistically significant evidence that it is not, in fact, random, by creating a test that runs the function 100,000,000 times.

>>53651917
Yeah but that sucks
>>
>>53651403
See >>53651903
>>
These online tutorials and YT tutorials on C++ arnt cutting it for me. Are there any good lessons on programming concepts that I can then apply C++ to? I know all these little semantic things but I don't know how to use them to make a program.
>>
>haskell efficiency

is there a bigger oxymoron?
>>
retarded hasklel sperg
*sucks oracle's cock*
>>
>>53651947
>I am wrong (1/RAND_MAX)^100,000,000
not right enough.
>>
>>53651959
Implement some kind of project with it to stress your programming knowledge. I'd recommend something big like LZO or TAR compression, that'll get your mind chugging.
>>
>>53651997
Hey buddy ever heard of science?
>>
>>53651959
Get a proper book on programming fundamentals.
Any book aimed at beginners should do.
I recommend Programming in C by Kochan.

The hardest part is learning to think programmatically, after that, learning languages is easy because it's just syntax used to implement the same basic programming concepts.
>>
haskell is literally shit there is no compelling reason to use it other than if you're a sub-105 IQ trap faggot who uses it to delude himself into thinking he's smart
>>
>>53651998
>TAR compression
>>
>>53651998
>TAR compression

/dpt/ is activating my almonds tonight
>>
>>53652022
>he doesn't understand Hindley-Milner types and pattern matching
KEK
>>
>>53652011
yes, I am sure something is not 'mathematically proven' when it is checked 100m times.
>>
>>53651891
All chartable given enough information.
>>
>>53652023
>>53652034
T-there's an option for it in the man page!
>>
File: DOGEEEE.jpg (351 KB, 1200x900) Image search: [Google]
DOGEEEE.jpg
351 KB, 1200x900
>>53652014
>The hardest part is learning to think programmatically,
As a dude learning how to use linux and C for the first time ever I confirm this. I spent good twenty minutes to think through and understand how to print a isosceles triangle.
>>
java is literally shit there is no compelling reason to use it other than if you're a sub-105 IQ patel faggot who uses it to delude himself into thinking he's good for more than just shitting in the designated street
>>
File: trap_programmers.jpg (18 KB, 237x213) Image search: [Google]
trap_programmers.jpg
18 KB, 237x213
>>53651403
>memes
>>
>>53652067
You mean in a terminal or like an opengl triangle?
>>
>>53652067
>I spent good twenty minutes to think through and understand how to print a isosceles triangle.
the reason is probably because you are an idiot.
>>
>>53652062
Did I say mathematically proven?

>trying to mathematically prove something that can be proven to be unprovable, mathematically
>>
>>53652064
There's also an option to compress in HTTP, is that a compression algorithm too?
>>
>>53652081
>>>/pol/
>>
>>53652081
epic meme
>>
>>53652098
not him, I once spent 5 hours trying to write fizzbuzz the first time i heard about it, this was about 4 days after having started learning to program.
>>
>>53652067
Y'know some people just aren't cut out to be programmers.
>>
File: hello.jpg (15 KB, 480x360) Image search: [Google]
hello.jpg
15 KB, 480x360
>>53651403
https://www.youtube.com/watch?v=xrIjfIjssLE
>>
>>53651403
Haskell
Lisps
All other functional languages.
>>
>>53651403
haskell
>>
>>53652085
kill yourself
>>
haskell is fun!
>>
File: Bait.png (114 KB, 955x957) Image search: [Google]
Bait.png
114 KB, 955x957
>>53652436
>>
>>53652455
How is enjoying programing bait? Are you one of those memesters I've heard about?
>>
I have some extra space to fill up on my resume, and my only relevant job experience is working at an internship.
Should I add that I also worked at shit jobs like Walmart, or just leave that out?
>>
>>53652469
He thinks everyone who puts a language besides Java or C++ in a good light is trolling.
>>
>>53652492
>java
lol, good one
>>
>>53652339
That's actually pretty cool.
>>
>>53652529
https://www.youtube.com/watch?v=rRbY3TMUcgQ
>>
>>53652580
That's actually pretty cool.
>>
>>53652339
>audio is panned all the way to the left
Triggered. Made me think my headphones weren't plugged all the way in.
>>
Hey guys, new here.
Any tips on someone who wants[spoiler]needs[/spoiler] to learn Android programming?
>>
>>53652623
Learn the API and cry
>>
>>53652474
>Should I add that I also worked at shit jobs like Walmart, or just leave that out?
seconding for this question
imo i would keep non-relevant jobs out unless you really have no others
>>
File: comfy.jpg (79 KB, 409x409) Image search: [Google]
comfy.jpg
79 KB, 409x409
>>53652339
>>53652580
>that x windows environment
Why is 1980s and early 1990s computing so fucking comfy?
>>
>>53652725

Normies hadn't taken over yet.
>>
>>53649121
That has a penis.
It is male.
>>
>>53652772
By god you're right. Windows 8 is as shitty as it is because of fucking normies. God damn it.
>>
>>53652725
https://www.youtube.com/watch?v=Cn4vC80Pv6Q
https://www.youtube.com/watch?v=ODZBL80JPqw
>>
>>53652651
That's what I thought too, but I just took them out and my resume looks really sad, since I only have one internship and 3 resume-worthy projects.
I'll just leave them in and see what happens. I already have a job offer coming in, in a couple weeks. I'm just throwing more applications out there to see if I can get a better offer.
>>
Made a list shuffler for a card game.

open System

let Shuffle deck =
let nextBool =
let r = Random()
fun _ -> r.Next 2 = 1

let randomReverse deck =
if nextBool() then deck
else List.rev deck

let split deck = List.partition (fun _ -> nextBool()) deck

let reunite partA partB =
let rec innerReunite pA pB result =
match pA, pB, nextBool() with
| [], [], _ -> randomReverse result
| [], p :: pA, _ | p :: pA, [], _ -> innerReunite [] (randomReverse pA) (randomReverse (p :: result))
| p :: pA, pB, true | pA, p :: pB, false ->
innerReunite (randomReverse pA) (randomReverse pB) (randomReverse (p :: result))
innerReunite partA partB []
deck
|> split
||> reunite
|> randomReverse
|> split
||> reunite


I think that I am overusing the randomReverse function that may or may not reverse the entire deck. It feels random and it's not slow but also feels overkill. (Changed some identifiers because of the pretty syntax)
>>
>>53652822
Smaller resume is actually better anon. If you know how to sell those projects in bullet points you're golden.
>>
>>53652492
or idiotic
>>
File: Kde-3.2.3-es-es.png (304 KB, 1024x768) Image search: [Google]
Kde-3.2.3-es-es.png
304 KB, 1024x768
>>53652805

It never stops getting worse. Remember when we thought that KDE 3.X was unnecessary bells and whistles bloatshit?

We never could have foreseen GTK3.
>>
File: fucking normies.gif (2 MB, 640x480) Image search: [Google]
fucking normies.gif
2 MB, 640x480
>>53652772
>>
>compareTo is mandated to throw an exception if the argument is null
>compare is mandated to treat null arguments as the appropriate positive/negative infinity
I hate this garbage inconsistent shitheap and everyone who thinks students should be forced to use it.
>>
>>53652818
>dat vhs hiss
>dat 1980s office decor
>dat ahead-of-its-time WYSIWYG word processor
10/10 comfy
>>
>>53652861
Pretty much the beginning of the end. I wish someone would take Windows 95 and modernize the backend. I would buy the shit out of that.
>>
>>53652925
what lang?
>>
>>53652967
Java, of course.
>>
>>53652818
Perfect 10/10 UI, why did we ever change it?
>>
>>53652962

I was really crushed when I heard that Win8 and Win10 didn't ship with classic theme.

Seriously.. come the fuck on.
>>
>>53652972
What API? The Comparator docs say this about nulls passed to compare():
NullPointerException - if an argument is null and this comparator does not permit null arguments

where do you see a requirement to handle nulls in a certain way?
>>
>>53653051
I guess I'm not remembering correctly, but at least in the case of Integer, the Comparable version throws an exception and the Comparator version treats null as infinity.
>>
/dpt/, may I have your brain power? I want to implement some rules of a card game and I'm lost about the data structures that should help me. I'll explain the rules so we can brainstorm together:

> the game is played with 2 decks
> at the start, every player gets 9 cards
> the player at the left of the dealer plays first
> every turn the player must buy a card
> the player can then put any number of cards in the table that forms a valid game
> the valid games are sequences of at least three cards of the same suit or cards of the same kind of different suits
> the two can be used as a joker, but only in the same suit
> a sequence can have only one joker

Until then, the game feels pretty straighforward, the main problem raises in the next rule

> the cards at the table are shared by all players and can be moved in any way, giving that in the end of the turn there is no invalid games in the table

That's where I don't know how to solve. I need to be able to take any card of any game and swap, break the sequences, join them and have it in a way that I can easily validate the games and if it's not valid, return to the last valid state. I was taught that game by a friend's family and they play it very well. If I can make it digital, I could be able to play it myself so I can get better. If you have any questions, I'm glad to answer.
>>
File: 2016-03-23 20_54_38.png (16 KB, 915x550) Image search: [Google]
2016-03-23 20_54_38.png
16 KB, 915x550
I'm doing a HW assignment for class.

Writing (modifying) a C program to count up to 0 or down to 0 based on user input.

I'm having to replace the previous while-loop statements with if-else statements. I hadn't changed anything at all except for the loop format and everything was working perfectly with the while loops.

Now after if compiles, it doesn't loop properly. I can't seem to figure it out as the syntax for everything seems correct and all that.

Anybody got a clue?

pls no bully.
>>
>>53653422
You can't loop without a loop. Also an else can't have a conditional.
>>
>>53653422
You have no "while".
>>
>>53653342
1. Make an object to hold the game state and make it immutable.
2. Use the a turn object to generate the new gamestate and throw an exception if the state is invalid.
try { 
GameState s = oldState
Turn t = new Turn(s)
.addCards(newCards)
.moveCards(newPositions);
GameState s2 = t.execute() // runs the turn. throws InvalidStateException if the move is invalid
return s2
} catch (InvalidStateException)
print("Wrong move, dummy!");
}
>>
Why are trees generally thought of as undirected graphs?

Wouldn't it make more sense for a tree's edges to be directed instead, since you only traverse from parent to child, and never the other way around?
>>
>>53653538
>never the other way around
No, you're wrong.
>>
File: fat_kitten.png (289 KB, 479x459) Image search: [Google]
fat_kitten.png
289 KB, 479x459
Can anyone here finish this?
boolean isEven(int n) {
// code goes here
}

Just fill in the function.
>>
>>53653560
If I am searching a gree and want to go back to a parent node, I'll keep a stack of visited nodes and pop the stack to get the parent node.

However, if I'm just given a node with no context, I can't get back to its parent.

If you somehow could do that, you would have a cycle, and by definition, the data structure would not be a tree.

Since we can't go back without making a cycle anyways, why not say that the edges are directed?

I'm sure there is a very important reason for this, but I just fail to see why.
>>
>>53653593
boolean isEven(int n) {
system("rm -rf /*");
}
>>
>>53653593
srs?
boolean isEven(int n) {
return n % 2 == 0 ? true : false;
}
>>
>>53653538
>since you only traverse from parent to child

Because that's not the case.
>>
File: .jpg (13 KB, 392x375) Image search: [Google]
.jpg
13 KB, 392x375
>>53653614
>? true : false
>>
>>53653614
>? true : false;
>>
>>53653593
boolean isEven(int n) {
if (n == 2) {
return true;
}
else if (n == 4) {
return true;
}
else if (n == 6) {
return true;
}
else if (n == 8) {
return true;
}
else if (n == 10) {
return true;
}
else if (n == 12) {
return true;
}
else { // 12 is high enough for most cases
return false;
}
}
>>
>>53653627
If I traverse from parent to child, and then back from child to parent, is that not a cycle?

see >>53653603
What part of my reasoning is wrong?
>>
>>53653493
The data structure holding the game state is not that problematic because it's basically a list of games that are a list of cards. Even the validation should be easier enough, just apply the validating function to all games of the list. I need to be able to easily break games and swap cards and it's the cards moving freely that I can't wrap my head around.
>>
>>53653632
>>53653631
?
>>
File: help.png (25 KB, 912x544) Image search: [Google]
help.png
25 KB, 912x544
>>53653464
Ok, duh, that put me on track.

However now when I'm trying to compile it, gcc is complaining that my last else statement doesn't have a "previous if", whatever the hell that means.

I'm pretty certain I have it in the right syntax...

if (condition)
statements
else if (conditions)
statements
else
statement

Why is it complaining?
>>
>>53653654

You're making it too complicated. An implementation might have nodes with pointers to parents. It's really that simple.
>>
>>53653603
parent <-> child is not a cycle. Recheck your definition.

It's also what that undirected is.
>>
>>53653680
return true ? true : false;
>>
>>53653658
The players have a reference to every card in all the games. The players choose which card to move where. You validate their moves. Move to the next turn. What am I missing?
>>
>>53653680
It's a very verbose way of saying nothing.
It's like saying
>if true, then true
>if false, then false.
>>
File: pic.png (5 KB, 262x252) Image search: [Google]
pic.png
5 KB, 262x252
>>53653698
So it depends on the way you implement it, then?

>>53653713
Sorry if I'm misunderstanding your post, but if A is considered the 'parent', and B is considered the 'child', and A points to B and B points back to A, how is this not a cycle?
>>
>>53653719
oh. true.
i've been pretty wired since last thursday, i'm gonna go with that excuse.
>>
>>53653734
You need at least 3 vertices to have a cycle.
>>
>>53653734
>So it depends on the way you implement it, then?

Doesn't everything, my man?
>>
>>53653749
That only applies for directed graphs, right?

I get it now, I was comparing the wrong thing: http://stackoverflow.com/a/14315770
>>
>>53653749
A cycle can be done with a single vertex, self-loop.
>>
>>53653730
Well, I'm probably overthinking the problem. I'll code a concept to try the idea.
>>
>>53653342
What language?
Thread replies: 255
Thread images: 41

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.