old thread: >>53733358
What are you working on, /g/?
How do I stop being a weeaboo /g/?
>>53736758
one of these.
https://en.wikipedia.org/wiki/Suicide_bag
>>53736788
weebs make the best computer software
>>53736758
Some CUDA shit to benchmark how well the on-board DMA-engines fare.
Corgi's are cute, CUTE
>>53736793
Shemales do
Working on my file server with torrent support.
I'm nearly done implementing an indicator for new downloads.
Should I add the indicator (a '*') before or after the file name?
Lovely to see a proper /D/ Programming Thread
>>53736758
Systematically tracking down and eliminating people who program in Rust.
Can you finish this function, /g/?bool is_odd(int n) {
// code goes here
}
>>53736821
That's very kind of you. They must be grateful for you putting them out of their misery.
>>53736862
>bool is_odd(int n) {
return !is_even(n);
}
>>53736862
return n&1
>>53736862bool is_odd(int n) {
return n % 2 != 0;
}
>>53736862int is_odd(int n)
{
return !(n % 2);
}
>>53736862bool is_odd(int n) {
return n == 2; // it' the oddest prime, can't get any more odd than that
}
>>53736804
proof?
>>53736862
public static boolean is_odd(int n)
{
return (n % 2 != 0) ? true : false;
}
>>53736862
int an = std::abs(n);
bool result = false;
while (an) {
an--;
result = !result;
}
return result;
>>53736873
>>53736878
You fail the test.
n % 2 is going to be zero if n is even and zero means False while any number other than zero means True.
Get fucking good, scrubs.
>>53736804
You mean mentally ill men make the best software? You're probably right.
>>53736908
I am wearing a dress right now as we speak
>>53736901
look closer shitlord. >>53736873
>>53736810
I'd add it before the filenames, so the user doesn't have to scroll all the way to the end when the filename is very long.
>>53736923
how l-lewd, hope your cock is comfortable.
>>53736919
why are you laughing?
it works perfectly and is completely portable
>>53736919
Why is `return n&1` incorrect?
>>53736959
ones' compliment
Is JS acceptable to code in?
I know that the HTML/CSS side of stuff is firmly not-dev and JS sucks as a language, but is it okay to talk about it here?
>>53736959
Because <insert arbitrary reason based solely on preference here>
>>53736931
Yes, I looked very close and it's very shit. You didn't need the != 0, chucklefuck. return n % 2 would've done the trick.
>>53736938
I'll be your girlfriend tonight
>>53736965
Stop it, you'll make me blush
>>53736965
>what is bit ordering
non-fag thread
>>53736903
>>53736903
>>53736976
if your JS code doesn't run outside of a sandbox in your webbrowser, it's not programming
>>53736862if (n/2) = 2 return false;
else if (n/2) = 1 return true;
else return false;
how'd i do? i normally do webdevelopment but i'm teaching myself coding now (i'm a girl btw)
Still working on my python turn base soccer game.
>>53736982
>>53736923
picture please
>>53736976
all webshit, especially frontend shit, is not programming
most websites shouldn't even use javascript, they should just use HTML/CSS, you are not good just because you use javascript, fucking retarded memer
>>53736990
this has nothing to do with endianness. This has to do with representation of signed ints
>>53736994
nice bait but you forgot to use ==
if ((n/2) = 2) == true return false;
else if ((n/2) = 1) == false return true;
else return (false == true);
>>53737007
Mr Bond, if you didn't get the joke about "compliment" being the wrong word, then I wont feel bad about cutting you in half with this laser.
Write a function that takes an integer of any bit length and returns a pointer to a char array containing the binary data of that integer.
Only boys who dress up like schoolgirls can solve this.
>>53737018
>this has nothing to do with endianness.
Of course it does.
n & 1 works with one's compliment.
>>53736965
>>53737018
First bit (b0) will only be set if the number is odd though, for 1 or 2s complement.
Just because it's a hack doesn't mean it isn't perfectly functional.
>>53737050
No, n&1 DOES NOT work with ones' complement.
example, -5 is odd, but the LSB is 0
>>53737023
wow i'm a dumbie x( thaaanks lol
>>53737061
>First bit (b0) will only be set if the number is odd though, for 1 or 2s complement.
Except YOU'RE FUCKING WRONG about 1s complement. And 1s complement is one of the 3 allowable representations of signed ints in C/C++
>>53737037
Into the gas chamber you go.
i & 1 works just fine
http://ideone.com/MPU40e
Web programming master race here just check in you code monkeys to say that in node js "is_odd" is as easy as "npm i is-odd", it's webscale as well.
https://www.npmjs.com/package/is-odd
if you have normalized 2d vectors (points on a unit circle), what's a good way to map them to a "dial". like on a clock if you have 12 numbers evenly distributed along the edge of circle, then (1,0) would map to 3 and (0,-1) would map to 6 and so on.
the obvious solution would be to use atan2(y,x) to get the angle and then multiply it by a constant factor, but then you run into problems when x or y are close to zero, so i'm looking for an alternative solution. any ideas?
this is for opengl shader code btw
>>53737101
implementation-defined
>>53736800
nothing explains why he prefers any of those features. why are macros or higher order modules bad? why are higher kinded types/type classes bad? he says they're not useful but these are literally the best tools I can think of for cutting down on boilerplate.
then some things (like pattern matching addition) are literally undecidable at runtime... the only way to do that would be if you defined + as a pure/total function operating on a simple data structure (like natural numbers) and that would make execution slow as fuck. half of these have nothing at all to even do with F#.
>>53737065
>example, -5 is odd, but the LSB is 0
pls go and stay go
>>53737109
hashmap
>>53737109
the first solution is fine, just use an epsilon to deal with floating point inaccuracy
>>53737043
No anon, I'm not doing your homework
>>53737018
>"bit order doesn't matter"
>>53737065
>"bit order does matter"
Also, pic very much related. Thanks for playing.
>>53737108
Pretending to be retarded?
>>53737101
See >>53737079
>>53737129
ONES' COMPLEMENT! See >>53737079
>>53737135
>confusing byte ordering with signed bit representation
>>53737132
no it's not fine in glsl, the implementation is likely to fuck it up severely, like it can give -pi/2 instead of pi/2 for (0,1)
>>53737159
>>confusing byte ordering with signed bit representation
I said bit ordering, I never said anything else. & 1 gives you the LSB.
>>53737187
and the LSB for -5 is 0 for ones' complement, see >>53737079
>>53737187
http://stackoverflow.com/questions/3952123/representation-of-negative-numbers-in-c
>>53737185
Point of atan2 is to preserve the quadrant.
>>53737122
It works with unsigned ints, one's complement and for two's complement.. What other ways of representing integers are defined by the standard?
>>53737210
>works for ones' complement
Except it doesn't. See >>53737198
>>53737204
when you have division by 0 anything goes
and glsl implementations are optimized for efficiency, not correctness
>>53737197
It's not, it's 1. See >>53737135
How does one embed GLSL in their C programs?
Meh.
>>53737210
>i don't know one's complement
>>53737219
That link clearly talks about MSB. See >>53737239 and >>53737135
It definitively works, as one's complement representation of -5 ends with 0xB.
If you guys want good programming practice with programming challenges everyday and programming tournaments coding against other coders.
Check out codefights.com you guys will enjoy it
>>53737244
char arrays
>>53737244
a fat const string.
>>53737252
See >>53737239
Now get lost.
>>53737253
>>53737239
Jesus christ, you're beyond saving.
YOU ARE NOT USING ONES' COMPLEMENT, YOU ARE USING TWOS' COMPLEMENT, OF COURSE IT WORKS
READ THE STACK OVERFLOW ANSWER MORE CAREFULLY >>53737198
>>53737268
>>53737270
is there any way to make these look nice, like they're really part of the C file itself, instead of putting parantheses everywhere?
>>53737272
That only works because your c implementation uses two's complement, which is not guaranteed to be true for all systems.
>>53737272
herp derp
>>53737266
I hate that shit. It's kinda fun, but all the challenges are autistic dick waving contests. If you want to get good at programming, start making cool shit.
>>53737291
wrap the source in a TOSTRING macro maybe
>>53737291
put it in a separate file i guess, and embed the file or some shit.
>>53737291
>>53737319
seperate file and load them in
>>53737159
>Pretending to be retarded?
Actually I just got 1s complement mixed up with sign/magnitude representation.
1s complement is slightly less shit than sign/mag but only slightly, both of them make passing the positive/negative boundary fucking painful in hardware.
Pretty funny that plenty of others don't understand this though, they can't all be pretending.
>>53737308
But it's too hard to make all the cool shit I tried and have failed
>>53737106
>importing a library for one trivial function
Checking if a number is even or odd is so trivial that you can easily inline it in an if statement in about as many characters as it would to invoke the function in the first place. Consider the following two cases:if (isOdd(n)) { ... }
if (!(n%2)) { ... }
>>53737135
This does not produce correct output on the Univac 1100/2200 series of computers, and their modern successors, the Unisys Clearpath machines, which use 9 bit bytes and one's complement signed integers.
>>53737367
All is possible in programing. Just keep learning, reading and trying until you can do it. If you're not very naturally talented, then just be patient.
>>53737368
>less characters is better
Haskelfags are not permitted in this thread.
>>53737368
!(n % 2) is not webscale, this is though:'use strict';
var isNumber = require('is-number');
module.exports = function isOdd(i) {
if (!isNumber(i)) {
throw new TypeError('is-odd expects a number.');
}
return !!(~~i >> 0 & 1);
};
Thanks /dpt/, now I know how to find odd numbers on ancient and/or clown-architecture machines.
And I only had to wade through a few dozen sperged-out shitposts!
>>53737368
>!(n%2)
Retard detected
>>53737043
template <typename T>
char* serialiseBits(T n) {
char* x = new char(sizeof(n) * CHAR_BIT);
for (size_t b = 0; b < sizeof(n); b++)
for (size_t i = 0; i < CHAR_BIT; i++)
x[b*CHAR_BIT + i] = ((char*) (&n))[b] & (1 << i);
return x;
}
>>53736758
How do I contribute to projects?
Nobody else's code makes any sense to me.
>>53737000
How do you make soccer turn based?
>>53737368
Why should I remember arcane operators such as % when I can just import a lib do it for me? Remember, Real Programmers Ship
>>53737237
Unlikely to cause any problems in practice, glitches a user can hardly perceive are perfectly fine.
And if it does cause noticeable glitches just fudge the edge cases around 0.
>>53737432
>arcane operators such as %
gurl programmer detected
>>53737413
Wait, shit, it's n%2.
I just woke up. Brain doesn't work yet.
>>53737441
>what is sarcasm
>>53737429
I'm thinking about it. Next thing I have to do is implementing payers movement. I think it will be simultaneous.
>>53737409
you're welcome ^_^
I hope you understand that C has standards now
>>53737421
whoops!
new char[sizeof(n) * CHAR_BIT]
>>53737451
readable code is best code. None of this n%2 shit pls.
I am making a dating application that is based off of Interests. So you and a person both fill out a bunch of interests and you are matched with someone with a lot of similar interests. For 1 minute each you have to talk about the highlighted interest in a live chat you both share and at the end of all the same interests you are given an option to give out your contact info or on to the next person
>>53737441
check yourself before you rek yourself
>>53737479
>readable code is best code
Only if it works. broken readable code are totally useless.
>>53736871
Don't know why no one's accepting this. Oh wait.. No one on /g/ knows anything about computing, I remember.
>>53737494
>are
get back to eclipse, pajeet
>>53737492
lel, I remember that, if anyone want's a laugh
https://css-tricks.com/tales-of-a-non-unicorn-a-story-about-the-trouble-with-job-titles-and-descriptions/
>>53737494
>broken readable code are totally useless.
If it's readable, it's easy to tell when it's broken. That's one of the primary benefits.
>>53737421
>>53737477
woah I definitely fucked up somewhere
>>53737266
I don't understand it, why does it give me solutions that need a tiny adjustment? Why is my opponent not coding in real time but rather can do it anytime? What's the fucking point?
>>53737490
What do you guys think?
>>53737490
Sounds like any other dating app tbqh
>>53737479
n%2 is plenty readable, and most programmers intrinsically know what it means.
>>53737266
this fucking sucks, if the number of lines differ it won't accept it? SHIT
>>53737544
There's a shitzillion sites that do that sort of thing anyways. What's the point?
>>53737523
I know readable code that are pure garbage. Best code is maintainable code, not readable.
>>53737423
Generally, I’ll just pipe find into less and try to understand
the directory structure. Then either something grabs my eye or I don’t
understand what something is. So I pick a random file and get a feel for it.
Then I bounce around and wander aimlessly until I’m bored and then pick a
new random spot to jump in.
A lot of times, I’ll work on building it in parallel with reading it because
they’re very parallelizable tasks, especially if it’s hard to build. By the time
it’s finally built, then I can start tweaking it if I want to.
>>53737558
You just fucked it up yourself peice of shit.
>>53737558
Oh the irony... >>53737451
>>53737572
I didn't say all readable code is good you dumb cunt. Better to be readable garbage than unreadable garbage no?
Maintainability and readability are not remotely mutually exclusive, and do in fact largely go hand in hand.
>>53737368
>not n & 1
>>53737585
My capacity for programming is at its worst within the first hour or so of having woken up, and at its best right around when I should be heading to sleep.
>>53737646
it is platform dependent
>>53737666
Great, so no one, including yourself, can reliably work on your code base if they are a little sleepy.
Maybe you could just make it more readable, and not have to hope and pray no one who works on the code fucks up as much as you just did.
>>53737714
Generally speaking, one should be awake enough to program by the time they've managed to drive to work without killing anyone.
What the fucks wrong with this code tbqhtypedef enum {false, true} bool;
int main()
{
bool fizz;
bool buzz;
while (int i = 1; i <=100; i++)
{
if (i % 3 == 0)
fizz = true;
if (i % 5 == 0)
buzz = true;
if (fizz || buzz) { // || == "or"
if(fizz)
puts("fizz");
if(buzz)
puts("buzz");
} else {
printf("%d\n", i);
}
}
}
>>53737770
Generally speaking, one should be awake enough to program by the time they've decided it was a good idea to start shitposting on 4chan about it.
In any case, make your code more readable and it there will be less fuck ups. The end user doesn't give a fuck about how many characters your codebase had.
>>53737802
>while(stmt;stmt;stmt)
>>53737829
Anon, there is never a wrong time to post on 4chan, even if you're braindead.
>>53737319
>tostring macro
Is this portable?
because it seems to work great.
It ignores newline breaks, but it's not like GLSL cares about those anyway.#define GLSL_embed(str) #str
int main(int argc, char **argv)
{
char *vertex_shader = GLSL_embed
(
int main(void)
{
// Transforming The Vertex
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
// Passing The Texture Coordinate Of Texture Unit 0 To The Fragment Shader
texture_coordinate = vec2(gl_MultiTexCoord0);
}
);
printf("%s\n", vertex_shader);
}
>>53737872
spoken like a true shitposter. The latter still stands.
>>53737669
>implying anyone cares about endian-ness
>Javascript
Should I just give in and use jQuery, or is pure JS good enough nowadays.
I'm only caring about up-to-date firefox/chrome/edge, fuck legacy browsers.
>>53737507
Stop being a fucking baby. Kids learn about bitwise operations in MIS 101. It's a boring answer to a boring question and we aren't obligated to suck your dick.
>>53737905
http://blissfuljs.com/
>>53737880
Fair enough. I suppose in a larger corporate codebase, making a function out of everything would probably be more logical. That said, using a library for it is retarded. As I recall, NPM had some issues with dependencies after some dude pulled a large number of libraries from the repo.
>>53737973
eat shit ruby fag
>>53737973
>I suppose in a larger corporate codebase
I've never heard an argument that made sense about why something that is good for large codebases is not good for small codebases.
I'm done with this shit python is too difficult for me fuck programming seriously how the fuck i can learn programming? Not the language for languages are plenty of books out here but for learn programming zero
>>53737878
double wrap it and it's fine#define GLSL_embed1(str) #str
#define GLSL_embed(str) GLSL_embed1(str)
http://stackoverflow.com/questions/240353/convert-a-preprocessor-token-to-a-string
>>53738162
Try learning Javascript first it is the easiest language
FUCK. ME.
I HAVE JUST SPENT LITERALLY 4 HOURS WRITING JAVA CLASS FOR UPLOADING FILES VIA SFTP TO WEBSERVER AND I DIDN'T REALIZE THE SCRIPT AND WEBSERVER WILL RUN ON THE SAME VPS, THEREFORE SIMPLE COPY COMMAND WOULD DO THE JOB
>>53738191var isPositiveInteger = require('is-positive-integer')
>>53738162
learn java
https://docs.oracle.com/javase/tutorial/
python and javascript are SHIT
>>53738163
Why do I need to doublewrap it?
>>53738144
One word: Java.
>>53738128
Love you too, Anon.
>>53738218
because otherwise if you put MUH_MACRO in your source then the source will have MUH_MACRO instead of what MUH_MACRO expands to
>>53738218
so you don't catch std exceptions
>>53738237
>catching stds
it's not 1997 anymore bjarne
>>53738214
If he is struggling with Python he isn't going to get Java. Java is a much harder language to understand and learn
>>53738251
it depends on what kind of person you are. java is much better structured. python is for minecraft playing ADHD shitkids who don't care about learning things properly
>>53738236
What's the problem with MUH_MACRO being in your code?
Is this a C++ problem or something?
>>53738233
>Java
Well.. sorta. Java is shit for small projects because it's horribly verbose. But this is shit for large projects too.
>>53738297
you don't want your GLSL code to literally say MUH_MACRO, it means nothing in GLSL, you want it to say 1.23 or whatever
>>53738320
But that's not what's happening.
the code in >>53737878 outputs$ ./test
int main(void) { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; texture_coordinate = vec2(gl_MultiTexCoord0); }
A thief has a backpack that can carry exactly GMax kilograms. He can stuff it with the items he found in the house he is burglarizing. Only whole objects can be put into the backpack, so they cannot be divided into pieces. For each object you know its weight and price.
Your task is to find the maximum profit the thief can make.
Notice that the weight of all objects in the backpack must be equal to GMax.
Example
For n = 7, GMax = 100, weight = [80,10,20,10,100,30,55] and price = [8,20,5,1,10,30,20], the output should be
backpack(n, GMax, weight, price) = 29.
The thief can take the first, the second and the fourth items (1-based).
[input] integer n
The number of objects, 1 ≤ n ≤ 100.
[input] integer GMax
The maximum weight of the things the backpack can carry, 1 ≤ GMax ≤ 300.
[input] array.integer weigth
Array of length n, the items' weights. 1 ≤ weigth[i] ≤ 100.
[input] array.integer price
Array of length n, the price of each item. 1 ≤ price[i] ≤ 100.
[output] integer
The maximum price of the items the thief can carry, Return -1 if there's no solution.
>>53738358
but then you might have additional macros in the GLSL source code just like you'd have macros in your C code
>>53738377
Can't this be avoided by naming all the macros in CAPITALS?
>>53738369
tldr
>>53738388
no why would it
look
http://ideone.com/z4EUbd
>>53738206
>what is rsync
>>53737901
>what is ones' complement
>>53738206
Just wait until you realise how shitty Java is.
>>53736758
How can I test if a double (or float) is whole or not without converting it to an integer (c++)?
This is my solution but I'm converting it:static inline bool isWhole(double n) {
return n == (int)n;
};
>>53738644
modulo by the floor of the double and see if it's 0
>>53738644
>double
>==
>>53738692
or return n== floor(n) should work too now that i give i thought
>>53738644
Is this an interview question?
>>53738707
this
>>53738717
this
you shouldn't be doing this, and if you should, you should probably have some tolerance for round off errors
>>53738692
>>53738710
orreturn n % 1 == 0
>>53738772
gg replied to the wrong guy
>>53738790
what
the only reasonable excuse for wanting to do it is if it's for an interview question
>>53738813
my bad. I thought you were trying to reply to the double equals guy
>>53738707
>>53738746
It works. Is it just bad for the performance or are you memeing?
>>53738775error: invalid operands of types ‘double’ and ‘int’ to binary ‘operator%’
>>53738692
>>53738710
So how do I write a floor function without converting to an Integer
>>53738832
I'm not so familiar with C. Would work in C#.return n % 1.0 = 0.0;
>>53738775
at least answer with working code...
Someone please explain this. What the fuck is this magic?
>>53738885
thats an invalid left-hand assignment ;)
>>53738885
I mean '=='
>>53738870
http://www.cplusplus.com/reference/cmath/floor/
you should generally avoid if/else type stuff, at the very least for checking if a float is an integer, because your algorithm should work for any float or if it works on integers then you should use an integer type or the previous steps should ensure that the float ends up as an integer
>>53738904
Watch a video about "floating point precision" and then you'll understand
>>53738918
What languages support both integers and floats that aren't statically typed anyways?
>>53738904
python starts rounding numbers at the 16. Int
(I never programmed in python but this is obvious i hope you are b8ing)
>>53738829
>what is a lack of total ordering
>>53738932
Lua?
>>53738904
>python
and retards try to say python isn't shit for learning lmfao
pytards don't even touch the OOP, it's just basic control flow which you learn literally in the first day of java, you hardly even learn what a float or an array is
>>53738829
Why do you need to know whether a floating point value is an integer?
>>53738904
IEEE 754
>>53737490
1 min is too short
>>53738951
click to what he replied omg I'm gonna ask /b/ they are more intelligent than this board...
>>53738904
17 9's are the equivalent to 1 and 16 returns a false due to it not being rounded?
>>53738369
http://lmgtfy.com/?q=maximum+subarray
>>53739051
>>53738904
the double closest to .17 9's is 1.0
the double closest to .16 9's is not 1.0
Is this portable?/* embedding GLSL in a C program */
#define TO_STRING(str) #str
#define GLSL_INLINE(code) TO_STRING(code)
#define GLSL_MACRO(macro) macro\n
int main(int argc, char **argv)
{
const char *vertex_shader = GLSL_INLINE
(
GLSL_MACRO(#version 120)
GLSL_MACRO(#define SOME_CONSTANT 3.14159)
attribute vec2 position;
int main(void)
{
/* Transforming The Vertex */
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
/* Passing The Texture Coordinate Of Texture Unit 0 To The Fragment Shader */
texture_coordinate = vec2(gl_MultiTexCoord0);
}
);
printf("%s\n", vertex_shader);
}
>>53736862bool is_odd(int n)
{
return true;
}
>>53739584
Fake
>>53739646
>>53739679
holy shit
>>53739679
Fake
>>53739711
>>53739646
thank skeltal obvious
>>53739679
how did she take that picture with no hands
>>53739711
I'd honestly be shocked if it was fake. Pretty much 0 of these #girlscancode that I've seen have ever had anyone involved who seems to know what the fuck they're doing. If I was female I'd be so fuck embarrassed and ashamed by this shit, and I know two females who are.
These are dark times we live in. I look forward to the day when we can as a society look back at this shit and laugh, just like with the hippies.
>>53739711
no. no it isn't
https://www.instagram.com/p/5c1WXeESvD/
>>53739774
you were faster.
it's on archive.is too https://archive.is/IWRgs
>>53739679
>crazy_strings.rb
wew
>>53739584
This is true though barely any of you guys use comments in your code don't deny it
>>53739766
selfie cam with her mouth
>>53739766
marketing form which hired her for the product placement
>>53739584
Btw that is the godly quake quick sqrt function on the left, one of the most brilliant functions to ever exist.
>>53739870
Doxygen conform comments because guidelines enforce it.
>>53739880
fast inverse sqrt function, get it right
>>53739879
*firm
>>53739768
stop.jpg
>>53739870
>comments in your code
USELESS
>>53739856
if you and RUBY got into a fistfight who would win?
>>53739870
I don't comment often because I make my code readable. I comment whenever I have a block of code where I feel it will be difficult to understand the intention of.
I've been thinking about writing a web-crawler, but then i realized that this is probably an easy way to get put on any government watch-list ever, unless i put severe restrictions on the web crawler.
public LinkedList<City> getPath(City originCity, City destinationCity) {
Stack<City> stack = new Stack<City>();
markVisited(originCity);
stack.push(originCity);
City currentCity = originCity;
while(!(stack.peek().equals(destinationCity)) && !stack.isEmpty()){
currentCity = getNextCity(currentCity); //set currentCity to the next unvisited city adjacent to currentCity
if(currentCity == null){ //all cities adjacent to the previous currentCity were already visited
stack.pop(); //remove the dead-end city from the stack
}
markVisited(currentCity); //mark the current city as having been visited
currentCity = stack.peek(); //set the new current city to the new top of the stack
}
if(stack.isEmpty()){
return null; // the origin and destination cities do not connect
}
else{
LinkedList<City> result = new LinkedList<City>();
while(!stack.isEmpty()){
result.add(stack.pop());
}
return result;
}
}
this should work, right? i haven't implemented everything and i don't know how to unit test so i can't check it right now so i'm just requesting a 3rd party sanity check since i've been working on this project a while and i'm a little worn out
Holy asslicking, ruby died pretty quickly didn't it? The whole buzz lasted for less than a year, it feels like.
>>53739870
Autogen comments
>>53740059
A trick post. However the reply you didn't want is this, "Government already has you on the watchlist." Therefore your work will not put you on any government watch-list, since by technicality you're already on one.
>>53740118
Yeah I can't remember a piece of code in the past year written in ruby
>>53740059
You're on a watch list for visiting 4chan
>>53740059
What would you crawl for?
>>53740118
welcome to modern programming. Hot retarded new programming memes every few months. It's tiring just trying to read about all this new shit and separating the 90% that's shit from the 10% that's actually useful.
>>53739998
I would. I'd just shoot him.
>>53740176
yep
just stick to C++/java/C# and you're golden
>>53740221
>java
>golden
>not brown
alright pajeet
>>53740185
> I would just fist him
ALL NIGHT LONGG
>>53740221
embedded programming infinite job security master race
Will you guys atleast admit Java is a great learning tool for learning programming?
>>53740185
Shots fired, pun intended.
>>53740221
Pretty much. I don't people using other languages, but you need to know these basic ones pretty well to start with. They do pretty much everything pretty well. If you do a lot of work in a certain domain were certain languages are worth learning just for that work.. then that's fine. It's frustrating hearing people saying shit like Ruby or PHP is great because it's less complicated or verbose than Java, which is their only other language.
>>53740287
It's terrible for learning to program. Why on Gods green earth would you use it over C#?
>>53740287
java is literally the best for learning programming
>>53740287
java is ok for learning to program
>>53740311
Because all the jobs are in Java. All the Colleges and Universities a ton of them use Java for learning programming. JUST ADMIT IT
>>53740311
less syntactic sugar, fewer features, less confusion, milder learning curve
>>53740287
Are you insane? Every if you must write "object != null", how is that acceptable for beginners? Python does a much better job. Even fucking Ruby does a better job.
>>53740287
bottom up > middle out > top down
IN MY OPINION
C++ > Java > Python
Unless you're a retard, in which case you won't get far in the first place.
>>53740350
>Every if you must write "object != null"
no you don't
if you have to do it in your retarded shit code, then you have to do it in python/ruby as well
>>53740350
>>53740352
>>53740367
Holy shit you guys don't even agree on a basic simple thing like Java is a great learning programming language.What do you guys do agree on? Anime? Traps?
>>53740335
>Because all the jobs are in Java.
Most are, certainly not all. We're talking about it being a good language for learning programming.
>>53740338
>less syntactic sugar, fewer features,
How are these good things?
>less confusion
Java is objectively broken.
>milder learning curve
How so?
>>53740350
>Python does a much better job. Even fucking Ruby does a better job.
Those language require null checks to you stupid fucking cunt. I fucking hate dynamic typing advocates. They are the most retarded programming demographic by far.
>>53740287
C++ is the best for learning. C if you don't care about learning objects.
>>53740402
>How are these good things?
easier to learn, dumbass
and knowledge of java easily translate to other C-like languages, while the features in C# are mostly specific to C#
>>53740414
>easier to learn, dumbass
You don't need to know any syntactical sugar or all the features to be able to use the language.
>while the features in C# are mostly specific to C#
like? Lamadas? unsigned integers? Working generics? Properties? Events? Pointers? What features do you mean?
>>53740382
Have you considered your opinion is... WRONG?
>>53740456
I beg to differ considering most of the universities and colleges all teach Java and there is a reason so many of them are doing it because it is a great learning tool for programming.
>>53740414
You know it is possible to mildly dislike c# and still think Java is absolute dogshite, right?
>>53740382
like 75% of /dpt/ agrees that static typing is better than dynamic. in an ideal world it'd be closer to 100% but still
>>53740477
The reason is that the lecturers get to shill their own textbooks for it, because java is such a clusterfuck that there is no universal textbook to learn from.
>>53740490
yes, if you don't understand java or you fell for the the "java is bad" meme
>>53740477
they also teach UML, how about actually considering why things the way they are rather than accepting that the current practice/majority is correct?
>>53740495
in the most general sense, of course it is. but is it really better in practice for web programming?
>>53740514
Why do you prajeets always assume that people who dislike it just don't "get" java?
I fully understand the "reasoning" behind some of the language design choices, the language itself is not confusing.
What IS confusing however is the logic behind most of these retarded choices, and the almost consistent inconsistencies.
>http://developer.download.nvidia.com/GPU_Programming_Guide/GPU_Programming_Guide_G80.pdf
>Don’t Compute the Length of Normalized Vectors
>>53740514
Java has no redeeming qualities next to C# besides having a stronger job market, and having a better ecosystem for certain things. As a langages, there's nothing about it that isn't better in C#.
>>53740521
I'm so glad my uni teaches C++ from the start.
>>53740569
>What IS confusing however is the logic behind most of these retarded choices, and the almost consistent inconsistencies.
you don't understand java
>>53740576
see >>53734175
>>53740569
What is confusing is how /dpt/ consisting hates on Java for absolutely no reason. Look at all the reasons you guys have they are not even a real argument. Java is a good programming language just deal with it.
>>53740606
half of them are memeing and half of them are dumb as hell
>>53740606
Funny how you give no arguments for why it's a good language compared to any other.
>>53737518
>Except for JavaScript "engineering" and anything related to algorithms, my technical skills are sharp
>my technical skills are sharp
>can't into algorithms
Fucking hell I wasn't ready
>>53740569
everything in every language is there for a reason
was put there deliberately by some person probably much smarter than you (you specifically)
the real test is how you will complain about this or that for your entire life but will never ever have any idea for an alternative
and that is why you are an inferior slave
>>53740601
Literally no points except that Java is "simpler". Which is not really true since stuff like genetics being broken makes real world code more complicated very quickly.
>>53740606
>It's good because I say it is, just accept it!
No :^)
>>53740647
Simple grammar - Java has a very simple grammar familiar to anyone with experience in C and C++, which must be 99.9% of programmers. The BNF for Java has about 50 rules; that for C++, about 140. And C++ also has templates and a preprocessor in addition to the grammar. Java just got quite a bit more complex in 1.5 (excuse me, Java 5). They haven't even released a new version of the language spec yet.
Portability - These days Java really does run well on all the popular platforms (Linux was a little behind, until Sun realized they needed them... now it's just FreeBsd, OpenBsd, and NetBsd lagging) (Too bad that Ruby, Python, Perl, Squeak don't work well on most platforms... Oh wait, they do!)
Speed - The latest JIT compilers for Suns JVM approach the speed of C/C++ code, and in some memory allocation intensive circumstances, exceed it. (Too bad Ruby, Python, Perl, and Squeak don't even come close)
Standard APIs - You can happily write your code knowing that the standard java.* libraries will be waiting on the client for it, assuming a recent enough version of Java is installed
GarbageCollection - the programmer doesn't have to worry about memory (most of the time)
VM - see WhyAreVirtualMachinesGreat
interface vs. class
CheckedExceptions (some people hate this, but its optional) (some ppl love it)
single class inheritance
singly rooted class hierarchy (the reason that lack of templates isn't a killer)
no OperatorOverloading
reflection
Inherent support for dynamic linking and loading.
Guarantees of binary compatibility w.r.t. changes to linked code.
fast edit/compile/run cycle faster than what?
I can only attest that this makes EclipseIde great. It is wonderful to be able to make small changes to a class and have the recompiled class linked into the running application for immediate testing. I don't know whether this is possible in other Java environments.
>>53740676
who the hell uses generics, seriously
CRUDfags maybe, since all you do is storing things and sorting them all day
>>53740690
All of those things have been done better by other languages.
enough of these memes, let's truly figure out which /dpt/ thinks is better
http://strawpoll.me/7214303
>>53740690
>muh jvm
>muh 'write once run anywhere'
>>53740868
Both are equally shit.
>>53740868
>No option for "fuck off cunt"
>Probably 10 people viewing the poll for every person who actually votes
Wow
>>53740868
At least traps are programming related.
>>53740868
>enough of these MEMES!
>>53740933
fuck off fag
>>53740945
I'm wearing a dress right now. ;)
Literally why
> expected , or ; before )
it upsets me that i cant find out what the problem iswhile (1) {
scanf("%s", input1);
if (strcmp("exit", input1) == 0) {
break;
}
scanf("%s", input2);
jobsname[job] = input1;
jobstime[job] = str2int(input2);
//testing
printf("#:%d ", job);
printf("name:%s ", jobsname[job]);
printf("time:%d\n", jobstime[job]);
job++;
}
int i;
for (i = 0; i < job; i++) {
printf("%s\n", jobsname[i]);
}
as soon as i exit this while loop all jobsname elements become "exit" for some reason... WHY?//sample output
J0 1
#:0 name:J0 time:1
J1 2
#:1 name:J1 time:2
J3 4
#:2 name:J3 time:4
J5 6
#:3 name:J5 time:6
exit
exit
exit
exit
exit
Press any key to continue . . .
>>53740960
ok fag
>>53740971
which language even is that
C# has arrows?
>>53740982
thats typically a sign of out of bounds array access. also where is jobs initialized?
>>53740982
>scanf("%s",
That's just asking for buffer overflows.
>>53741015
C++ you tit
>>53741020char *jobsname[10];
int jobstime[10];
int job = 0;
char input1[10];
char input2[10];
>>53741015
Almost looks like C++
>>53740982
Arent you setting all the values in jobnames to the pointer of input1?
Use strcpy
Also
>scanf
>ever
And scanf("%i",&intsonewh)
For time
>>53740696
>who the hell uses generics, seriously
Are you kidding? Anything modestly complex will use generics. I know Java fags tend to avoid it because it's broken in Java, but it's insanely useful.
>>53741055
>using namespace std
>>53741149
yeah right
you have no examples
you can not do interesting things with generics, it's only for data structure CRUDshit
anything remotely interesting will need an interface
>>53740118
I guess maybe there's still a few jobs out there for memes sake; basic maintenance or something, but I guess it's safer to stick with C/C#/C++/Java/Python etc
>>53741232
I like an easy life
> but I still can't find the ; or , missing
>>53741111
Yes, this is the cause of the bug.
Besides the horrible design, deprecated function calls, and unintuitive variable names, this is why jobnames's entries get overwritten with "exit".
New thread: >>53741285
>>53741252
Data structures and algorithms on them are 99% of programming.
>>53741266
>Python
anon...
but seriously, python is such an overhyped meme just like ruby was, you can be a basic high school dropout python shitter and get a six figure salary just like that, you think it'll last?
>>53741301
99% of CRUDshit
please, tell me WHAT exactly that java struggles with when it comes to generics, and please, tell me a valid use-case for generics, preferably a real one that you can see in a respected project on github
>>53741330
>cuckhub
>respected
anon, I have some news for you
>>53741252
it's nice for just using collections. I make an array, list, linked list etc of an int, DateTime or object or whatever and be completely type safe.
I can also do stuff likeclass ShitDecorator<T> {
public double Length
public double Girth
public Shit : T
}
Which is handy in certain places. And also make functions that can accept IEnumerable<ShitDecorator<T>> as a parameter, which adds type safety to your code.
It's useful.
Interfaces are cool too. Generics and interfaces aren't exactly mutually exclusive though.
>>53741330
Make a ListArray of type "int" in Java for me. Thanks.
>>53741378
wow epic meme faglord
>>53741393
>Javafag rage quits.
Thanks for playing
>>53741439
yeah you sure convinced me bro, simply epic
>>53741466
back to le reddit
>>53741466
using epic in both posts, BTFO'D KID!
>>53741466
I wasn't trying to convince you. I just answered your question and you spazzed out.
>>53741472
>>53741494
>>53741513
yeah fuck off back to /b/ idiots
>>53741531
see you there, friend
>>53741531
literally every java advocate in these threads. Java and dynamic typing advocates shouldn't be allowed in the industry. We'd all be a lot better off.
>>53740971
>>53741274
Why haven't you explicitly cast to string on line 39 like in line 33?
Shouldn't make a difference at all, but I wouldn't put it past C++.
>>53741015
It's to identify whitepsace you tit, tabs specifically.
Jesus, did you not notice the newline characters and dots for spaces?
>>53741855
>It's to identify whitepsace you tit, tabs specifically.
Not who you're replying to, but that is retarded. All it does is add a bunch of unnecessary "noise" to the code.
The tab one MIGHT be helpful if you're using a proportional font, but doing that is equally as retarded.
>>53741855
i was referring to the arrow operator
>>53741951
also just so we're on the same page, string without the std:: and the retarded curly brace style made it look kinda like C#
>>53741946
>>53741951
I nope neither of you reproduce.
It's the fucking text editor, it overlays certain characters so you can tell where whitespace is being used.
If you didn't have the linenumbers on the left, there's no way to tell the difference between a newline and a wrapped line without the newline placeholder.
None of this shit is stored in the source file, the editor just adds it in to the display.
As for the bitshift operators, I have no idea why that particular editor uses that, it's common to use non-ASCII characters to avoid this kind of confusion.
>>53742010
i'm not talking about those
i'm talking about the arrow inGAAP_node->
and whitespace highlighting is dumb, he must've enabled it in desperation trying to debug his "easy" C++
>If you didn't have the linenumbers on the left, there's no way to tell the difference between a newline and a wrapped line without the newline placeholder.
but that's fucking wrong you fucking idiot
a line only auto wraps when it reaches the end of the line, and you shouldn't have line wrapping in your IDE, you should only have purposeful line wrapping with double indent
>>53742010
>It's the fucking text editor, it overlays certain characters so you can tell where whitespace is being used.
>None of this shit is stored in the source file, the editor just adds it in to the display.
I fucking know, idiot. It's still visual noise.
>If you didn't have the linenumbers on the left, there's no way to tell the difference between a newline and a wrapped line without the newline placeholder.
Try not writing such long lines.
>>53742071
>Doesn't know what the -> operator is
>Calls other people stupid
>>53742153
You said:
>All it does is add a bunch of unnecessary "noise" to the code
But it's not adding diddly to the code, it's just an option toggled on in the fucking editor.
Holy shit, are you really going to deride someone for their editor preferences instead of actual code content?
>I've never in my experience ever had to use whitespace identifiers in a text editor, therefore nobody else should ever need it!
>Just don't write such longs lines xD
Maybe when you go to big-boy school they'll let you look at someone else's shitty code and ask you to deal with that.
>>53742247
i asked if C# had it because it looked like C# with the string instead of std::string because he uses namespace std like a retarded fuccboi
>>53742274
and he uses a shitty curly brace style
>>53742247
fuck you and get a life stupid sperg
>>53742247
>But it's not adding diddly to the code, it's just an option toggled on in the fucking editor.
Notice the scare quotes i used on 'noise'. I was referring to visual noise, which I thought was obvious. I guess you're just a fucking idiot.
>Holy shit, are you really going to deride someone for their editor preferences instead of actual code content?
Yes. Welcome to /g/.
>Maybe when you go to big-boy school they'll let you look at someone else's shitty code and ask you to deal with that.
What the hell are you on about, you fucking moron?
>>53742010
>>53742071
>arrow in GAAP_node->
>bitshift operators
Come on guys. Read the bloody manual.
Source: Bjarne Stroustrup
>>53742349
>also known as the arrow operator
>>53741946
>All it does is add a bunch of unnecessary "noise" to the code.
I like it, it helps me indent.
>>53736758
>She