[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: 313
Thread images: 39

File: 1415673498821.jpg (258KB, 1114x876px) Image search: [Google]
1415673498821.jpg
258KB, 1114x876px
http://boards.4chan.org/g/thread/57415525#top
>>
>>57421367
What the fuck is this shitty thread
>>
>>57421367
>Created before the bump limit
>A URL
Delete this shitty, invalid thread, and kill yourself.
>>
third for python 3
>>
>>57421367

Are you the retarded linux fag that doesn't even know how to install an ide?
>>
>>57421367
>tfw I have the doujin on harddisk
>tfw this is a blue board
>>
>>57421442

source?
>>
>>57421478
>>57418458
>>
Coding conway's game of life in Javascript. Still lifes seem to work but glider guns don't glide so I know something's wrong. Anybody see a bug? Thanks /g/.

var newState = window.gameState.slice();
for(var i = 0; i < 30; i++){
for(var j = 0; j < 30; j++){
var total = 0;

for(var k = -1; k < 2; k++){
for(var l = -1; l < 2; l++){
total += window.gameState[(i + k + 30) % 30][(j + l + 30) % 30];
}
}

if(window.gameState[i][j] == 0){
if(total == 3){
newState[i][j] = 1;
document.getElementById(i + "-" + j).className = "alive";
}
}else{
if(total < 3 || total > 4){
newState[i][j] = 0;
document.getElementById(i + "-" + j).className = "dead";
}
}
}
}
window.gameState = newState.slice();


Accidentally posted an old version so re-doing this post
>>
does anyone know where i can get a scheme compiler for ubuntu.
>>
>>57421597
Chicken Scheme compiles Scheme to C iirc
>>
>>57421537
A cell is alive if there are 4 live cells in the 3x3 neighbourhood, or if there are 3 live cells including the cell itself.
>>
how realistic is reading all of the art of computer programming with low math background?
>>
>>57421843
You have the rules of the game wrong. A cell stays alive if it has two or three live neighbors. It dies if it has fewer than two or more than three. A cell is born if it has three live neighbors exactly.

I found the bug, by the way. It was annoying as hell. I'll leave finding it as an exercise to the reader.
>>
Learning Python 3.4 in a rush to make some simple shit. I'm on chapter 2 of the tutorial but it's just telling me lots of useless shit instead of showing me simple programs. How do I take the input of the user as a variable? That's all I wanna know. Also I assume that interactive code and script code look the same right?
>>
>>57421463
What's the name?
>>
File: confused.jpg (68KB, 300x300px) Image search: [Google]
confused.jpg
68KB, 300x300px
>>57421463
make tasteful crops to use as reaction images
>>
>>57421853
Just look up what sigma notation is, and you're good to go.
>>
>>57421891
>(C73) [Mieow (Rustle)] ~(^-^)~.exe 2007
That should help you.

>>57421919
No.
>>
>>57421537
Are you not double buffering?
>>
>>57421971
Is this legal?
>>
>>57422026
>>57421537
Oh, yes you are, it's so fugly I didn't notice.
>>
>>57422127
It's loli. I'd say you decide if it's legal or not.
>fuck the police
>>
File: 2d.png (306KB, 977x1400px) Image search: [Google]
2d.png
306KB, 977x1400px
>>57422127
>>
>>57422182
wtf I love lolis now
>>
>>57422142
Don't blame your poor reading skills on me anon.
>>
Dynamic typing bothers me, especially in regards to how difficult it is to analyze someone else's code.
>>
File: 1476889332037.jpg (38KB, 415x512px) Image search: [Google]
1476889332037.jpg
38KB, 415x512px
>favorite language
>language you're most familiar with
>language you've used the most at work
>language you've used the most not at work

Haskell, but it used to be Scheme
Java
Java or C++
Java or Scheme
>>
>>57422127
you just revealed your normalfag powerlevels
>>
>>57422244
C++
C#
C# or C++
C#
>>
File: image.jpg (46KB, 512x512px) Image search: [Google]
image.jpg
46KB, 512x512px
>>57422257
>>
File: 1477255349332.png (208KB, 395x375px) Image search: [Google]
1477255349332.png
208KB, 395x375px
>>57422291
>favorite language C++
no excuse
>>
>>57422312
DOOOO EEEEET!
>>
>>57422244
Coq or Idris or something?
OCaml
C#
OCaml
>>
>>57422327
M
OD
ERN
C++/CLI
>>
>>57422244

C#
C#
C#
C#
>>
>>57422244
C++
C++
JS
C++
>>
>>57422244
C++
C++
NEET
C#
>>
>>57422244
cubicaltt
Haskell
N/A
C++
>>
>>57421879
userInput = input("Enter something: ")
>>
>>57422244

C
C
C
Python
>>
>>57421367
I've been telling you guys all along. Anime posters need to leave. And you all laughed at me. And now when an anime poster creates a shit thread like this, I'm the only one laughing now
>>
>>57422234
Dynamic typed languages with insufficient tooling to do proper analysis of code are a real pain, especially considering Common Lisp shows a lot of ways to reduce the brain fatigue with good tools for peeking into the machine
>>
I feel stupid. Does anyone know really good resources to learn about matrix transformations in the context of opengl, webgl and canvas transform operations?

The worst part is I can't tell if the matrices are column major or row major and what the differences are.
>>
>>57422244
Common Lisp
C++
C++
C++
>>
I'm building my tic tac toe check win state engine.

how big the grid (3x3, 6x6, 9x9, 19x19)? 3x3
--- --- ---
| || || |
--- --- ---
| || || |
--- --- ---
| || || |
--- --- ---
player 1 wins


I'm really liking to programing.
>>
>>57422244
Python
Right now? C++. Before Python
AutoHotKey surprisingly
C++
>>
>>57422452
https://open.gl/transformations
You are pretty much covered for the simple stuff.
>>
>>57422452
In OpenGL it's up to you. The decision is ultimately made in the shader where you choose the order of multiplication during vertex transformation or whatever.
>>
>>57422435
Literally no one who matters (those without severe autistic tendencies) care.
>>
>>57422444
What are some of those tools?
>>
does anyone know where i can get a scheme compiler for ubuntu.
>>
>>57422521
In the trash 2bh.

nobody uses scheme anymore. Just download default-jdk
>>
>>57422244
Python
Java
C++
Java
>>
>>57421405
>before bump limit
it was made at 299 to be included in 300
>>
>>57422244
Ada
C++
C++
Ada
>>
>>57422521

sudo apt-get install chicken-bin
>>
Trying to figure out why the multi layer perceptron from the sklearn package produces a memory error when it has only allocated 20% of the maximum size.
>>
>>57422452
Conventionally, OpenGL uses column-major order, and performs transformations with the matrix on the left and a column vector on the right (DirectX does it the other way around).

Early versions only supported these conventions. Later versions added e.g. glLoadTransposeMatrix() so you can use a row-major matrix. GLSL lets you declare that a matrix is row-major via layout qualifiers. glUniformMatrix() has a "transpose" parameter to transpose the matrix.

In GLSL, multiplying a matrix by a vector treats the vector as a column vector if it's on the right and a row vector if it's on the left.

Note that (A.B)^T = (B^T).(A^T), so multiplying transposed matrices in the reverse order is equivalent to transposing the result.

If you use M.v (matrix on left, vector on right), the translation components should be in the right-hand column, while the bottom row should be [0,0,k,0] for a perspective projection and [0,0,0,1] for anything else. If you use v.M (vector on left, matrix on right), M should be transposed (translation on the bottom row).
>>
>>57422244
C++
C++
C++
C++
>>
How long did it take for you to read sicp, /dpt/?
I'm reading a subchapter a day, it's not always possible to finish all exercises in a day, but it's been a comfortable pace.
>>
>>57422586
Bump limit is 310
>>
About matrices. I tried to make a simple 2d matrix multiply function, however when looking at a "correct" solution (from glmatrix) it is different and I'm not sure why.

    // glmatrix function
multiply = function (out, a, b) {
var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5],
b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5];
out[0] = a0 * b0 + a2 * b1;
out[1] = a1 * b0 + a3 * b1;
out[2] = a0 * b2 + a2 * b3;
out[3] = a1 * b2 + a3 * b3;
out[4] = a0 * b4 + a2 * b5 + a4;
out[5] = a1 * b4 + a3 * b5 + a5;
return out;
};

// my function
var a00 = this.matrix[0], a01 = this.matrix[1],
a10 = this.matrix[2], a11 = this.matrix[3],
a20 = this.matrix[4], a21 = this.matrix[5];

var b00 = matrix[0], b01 = matrix[1],
b10 = matrix[2], b11 = matrix[3],
b20 = matrix[4], b21 = matrix[5];

// a02, 12 and 22 are 0, 0, 1 respectively
// a02
this.matrix[0] = a00 * b00 + a01 * b10;// + 0 * b20;
this.matrix[1] = a00 * b01 + a01 * b11;// + 0 * b21;

// a12
this.matrix[2] = a10 * b00 + a11 * b10;// + 0 * b20;
this.matrix[3] = a10 * b01 + a11 * b11;// + 0 * b21;
// a10 * b02 + a11 * b12 + 0 * b22;

// a22
this.matrix[4] = a20 * b00 + a21 * b10 + b20;// + 1 * b20;
this.matrix[5] = a20 * b01 + a21 * b11 + b21;// + 1 * b21;
>>
>>57422908
Is it because I put a on the left instead of on the right?
>>
>Here are some examples of poor wacky hash functions I've seen suggested in forums on the internet.

>md5(sha1(password))
>md5(md5(salt) + md5(password))
>sha1(sha1(password))
>sha1(str_rot13(password + salt))
>md5(sha1(md5(md5(password) + sha1(password)) + md5(password)))
>>
>have issue with code silently failing to do what I intended for half the day
>ended up just being me failing to allocate an object to the heap instead of stack and it dying too fast

oh my god
>>
>>57423151
That's just stupid. Everyone should do
int n=63;
while( n )
{
password = md5(password);
n--;
}
>>
i dont feel like studying but exams are soon, what should i do. Its not like i need to study much anyway
>>
>>57422244
C++
C
N/A
Probably C but soon to be C++
>>
>>57423235
install gentoo
>>
>>57423151
>md5(salt)
y
>>
>>57423151
>password
B C R Y P T

It's not difficult, people.
>>
>>57422244
Rust
JavaScript
JavaScript
Rust and JavaScript
>>
>>57423027
Yes. Yours calculates b*a, glmatrix' is a*b
>>
>>57421853
hard, but doable. all math in it is explained from basic principles, but in a really difficult way.

try concrete mathematics, it's the book by knuth&co and is basically extended introduction to math section of taocp.
>>
>>57422244
racket
racket
c
haskell
>>
>>57422369
Coq is not a language.

>>57422399
cubicaltt is barely a language, it's just an experimental implementation of a specific flavour of lambda calculus. The performance is also completely shit.
>>
>>57423478
Fuck you double nigger, it's still the coolest programming language there is at the moment.
>>
>>57423478
nigga what? are you retarded?
>>
Fixed my solution to exercise in previous thread to allow non-unique a,b,c,d.

; EXERCISE: write a program to find all a, b, c, and d; where a^3 + b^3 = c^3 + d^3; where all a,b,c,d are a thousand or less

(define (cube x)
(expt x 3))

(define all-possible
(let* ((number-range (range 1 1001))
(lst (append number-range number-range number-range number-range)))
(combinations lst 4)))

; takes a list of four elements
; if a^3 + b^3 = c^3 + d^3, where a is car, b is cadr, c is caddr and d is cadddr,
; is true return #t
; else #f
(define (cube-sum-equals? lst)
(let ((a (car lst))
(b (cadr lst))
(c (caddr lst))
(d (cadddr lst)))
(if (= (+ (cube a) (cube b))
(+ (cube c) (cube d)))
#t
#f)))

(filter cube-sum-equals? all-possible)


>>57423478
lambda calculus is programming language, if extremely primitive.
>>
File: 1433394021292.png (158KB, 2289x1744px) Image search: [Google]
1433394021292.png
158KB, 2289x1744px
>>57422127
Depends on whether you live in a draconian shithole or not.

US: Depends
Commonwealth: Illegal as fuck
EU: Legal
>>
>>57423605
Tfw commonwealth

fuck my shit up cunt
>>
File: 1463961519647.jpg (123KB, 644x689px) Image search: [Google]
1463961519647.jpg
123KB, 644x689px
>>57423617
Move while you still can.
>>
>>57423629
I'm in hecking new zealand. I mean it's comfy and chill, but I don't want to get thrown away for looking at cute girls or drawing cute girls. I'm not going to rape a child god damn it.
>>
>>57423642
Doesn't matter, you're still a criminal.

https://en.wikipedia.org/wiki/Legal_status_of_cartoon_pornography_depicting_minors#New_Zealand
>>
>>57423673
I know, I know. Some dude was arrested for it once too.
>>
>>57423676
So move while you still can.

Northern europe or northern US is still somewhat reasonable (just avoid Sweden).
>>
>>57423691
but I'll get killed by turban heads for not being arab or liberals for not thinking i'm oppressed if I do that
>>
I am sorry for the shitty code but this always breaks when I increase the limit of i == to a number proportional to n.

For example, if i is on any level higher than 4 when doing n = 5 iterations it goes out of bounds on the array and I just can't figure out why.

http://pastebin.com/xFkTU9VT

working on the midpoint displacement algorithm, and I'm pretty new to algorithms
>>
File: free.png (22KB, 664x230px) Image search: [Google]
free.png
22KB, 664x230px
This might be a stupid question but I'd appreciate some help.

I just picked up C and have been messing around with a couple things. I want to make a test based game where the user makes decisions and it changes the story depending on input.

My question is when I have a long bunch of text printed onto the screen, words get cut off at the end of the console and move to the next line halfway through the word, how do I stop this from happening?

(Pic related, ignore the interjection in a windows cmd).

 
#include <stdio.h>
#include <stdlib.h>
#include "freedoms.h"

int main()
{

printf(FREE);

return 0;
}
>>
>>57423843
Break the string at first space before line length with \n
>>
File: Screenshot_250.png (7KB, 618x135px) Image search: [Google]
Screenshot_250.png
7KB, 618x135px
Help me please

How would I enter a link into the highlighted text of this variable? I know how to do this in python, but I'm not familiar with HTML

Basically I want something like this
<testvar> EXAMPLE LINK HERE (Basically the variable containing the code, and the link inserted into the middle) </testvar>
To make my code look less messy/confusing

Thanks guys...
>>
Creating a C function to get the next line off a file descriptor. Calling it in a while loop should get each line until the fd is done. I'm using a static list to keep track of the different fd's and respective buffer.
>>
File: Capture.png (33KB, 898x400px) Image search: [Google]
Capture.png
33KB, 898x400px
>>57423800
nvm solved it
>>
>>57423707
Like I said, avoid Sweden.
>>
lua sounds cute , what can I do with it?
>>
>>57424547
not much
>>
>openshit has some free tier level of hosting
>is not available in your country

Well shit, any other recommended hosts that has free tomcat? If paying is my only option left might as well learn aws
>>
there is litterally nothing wrong with javascript.
>>
File: 1361752574642.png (170KB, 519x424px) Image search: [Google]
1361752574642.png
170KB, 519x424px
>>57424712
>>
>>57424712
>
smuganimegirl.webp
>>
>>57424712
>nothing wrong with javascript
Were you dropped as a child?
>>
Why don't we have a NaNoWriMo for code?
>>
>>57423605
Illegal in France T_T
>>
>>57423605
I'm in red state what's gonna happen to me
>>
>>57423605
>tfw illinois
>>
>>57424914
that's exactly what we do though...
>>
>>57422376
microbitch
>>
>>57425020
Where? What's it called?
>>
File: startTheVan.jpg (49KB, 640x435px) Image search: [Google]
startTheVan.jpg
49KB, 640x435px
>>57424944
Félicitation, vous êtes le grand gagnant d'une fiche S à votre nom!
The party van will be coming soon.
>>
>>57425047
oh lmao I thought I was on /agdg/
>>
>>57424678
I use jelastic for free hosting.
https://jelastic.cloud

Although im not sure whats going on with it atm. my trial account was destroyed a while ago but i was able to get it back with no problems, maybe it's unlimited now? i don't know.
>>
Is Node a stupid back end language to learn? For front end I've been focusing on JS so I thought it'd be best to keep with the JS and learn Node. But is something else like Python better to learn?
>>
Hey im looking for a guide on minimax trees for java. Can anyone help, please?
>>
>>57422127
Depends where you live.

Its all just imitation child porno for failures at life who think that children are sex objects, anyway.
>>
>>57422244
C#
C#
C#
C#
>>
>>57425447
>cringe bait
It's art. Humans are a failure anyway.
>>
>>57422244
CCCC
C
C
CCCC
>>
>>57425473
thank tay, it's not just me
>>
>>57425476
>humans are a failure
>hence morality is irrelevant
Nice mental gymnastics. kys
>>
>>57425473
this exactly
>>
>>57423605
>>57424949
The image is retarded.

Texas, for example, doesn't give any fucks.

>>57422244
>10/13 anons who responded to this post are employed as a programmer
doubt

C# across the board for me.

>>57425118
>Is Node a stupid back end language to learn?
Since you're already in the Javascript world, learning Node should be fairly straightforwards for you. Regardless of its quality or comfiness, it's very popular and would be a good tool to have if only for the employability boost.
>>
>>57422244
Assembly
Assembly
Still studying, so not working.
Assembly
>>
>>57422244
Go
Perl
PHP
Perl
>>
File: 1461524262737.jpg (98KB, 461x424px) Image search: [Google]
1461524262737.jpg
98KB, 461x424px
>write programming tutorial
>no license mentioned for code snippets
>sue everyone who uses the code
>>
>>57425545
>lacking basic logical thinking
You're just proving my point. This form of art isn't comparable to the degenerate porn you fap to everyday.
>>
>>57422244
c++
c++
//
c#
>>
>>57425599
>its art
>therefore its inherently moral/good
And you think I'm the one who lacks an understanding of logic?

Nice mental gymnastics again, faggot.
>>
>>57425612
>it's art therefore it's good
Yes.
>harmless
>provides a mental source of please

Also, you're fucking retarded. Don't even try calling me baka. :^)
>>
>>57421367
I asked in SQT but no one seems to know.
How do you make your own GUI in python, can you even do that or do you need to use another language?
>>
>>57425666
Use a library like PyGTK, PyQt, etc. I'm sure you can find Python versions of just about any C GUI framework.
>>
File: asdf.png (114KB, 651x953px) Image search: [Google]
asdf.png
114KB, 651x953px
>>57425666
>can you even do that
Holy fuck, anon.
>>
>>57422244
Java
Java C#
Java
Java

t. Ramit Inmah Ashol
Senior Java EE Programmer
>>
>>57425657
>hurr i got rekt so im going to ignore the truth
Amoral, idiotic pedo. Sounds about right.

No wonder you're attracted to children, you're too pathetic for any adult to love.
>>
>>57425684
Yeah, those are just using existing packs. I want to create my own.

>>57425676
Thanks mate.
>>
What should I learn for back-end? What do you think about Go? or kore.io?
>>
>>57425709
Vertx
>>
>>57425689
>rekt
Just stay on r/eddit cancer, kiddo.
>>
File: 1450365207969.png (8KB, 461x90px) Image search: [Google]
1450365207969.png
8KB, 461x90px
can someone explain to me:
1) why does it print 50 digits?
2) why is it incorrect after 16 digits?
i read that long double support precision of 20 digits
>>
I want to run some Cucumber tests by executing a jar.

How do I build it with Maven to start running the tests immediately?

Do I keep the classes in the src/test folder or src/main?
>>
>>57425857
1) Because you told it to
2) Floating point numbers are imprecise by nature, the precision in number of digits is pretty much meaningless
>>
>>57422244
Prolog
Python
N/A
C
>>
>>57425882
and how are the digits "generated"? does printf access the memory next to variable f?
>>
>>57425974
The floating point numbers are stored in a special format called IEEE 754, which has nothing to do with decimal numbers.
printf converts from IEEE 754 into decimal, and that's why it's imprecise.
>>
>>57423843
Why did you write /n instead of \n inside FREE? Is this bait?
>>
>>57425986
i get it how floats are represented internally.
i meant where does printf read the missing 30 digits?
shouldn't it be zeros by default or is printf reading the memory next to the variable and read bits from the memory which does not belong to the variable.
hope this is understandable, sry english is not my mother tongue
>>
>>57426091
>i get it how floats are represented internally.
Clearly, you don't.

>i meant where does printf read the missing 30 digits?
It DOES NOT read the decimal digits from memory. It reads the IEEE754 representation and converts that to decimal. The conversion doesn't give an exact numbers, that's where the "missing" digits come from.

Imagine I invent a system where I store numbers as integer multiples of Pi, so internally you can have 1*Pi, 2*Pi, 2132*Pi, etc.
When you try to printf 2*Pi it will show an infinite number of digits if you want, but in memory the only thing stored is "2".

printf has to do a conversion, that's why it's imprecise.
>>
>>57425079
Thanks, any catch that I should be aware of?
Like in openshift, completely free tier requires a visit every hour, otherwise my host sleeps
>>
>>57426124
k i understand my mistake now, had an thinking barrier...
>>
File: help.png (39KB, 1252x362px) Image search: [Google]
help.png
39KB, 1252x362px
I know that what I have typed in the pic isn't whats being asked but I don't know how to correct it.

Any help is much appreciated.
>>
>>57426379
>requires an object return type
>all conditions are null
Am I being meme'd?
>>
>>57426379
WTF you're STILL on this shit exercise after TWO (2)! days?
>>
>>57426379
>packet.remove("flavour")
probably should be packet.remove(flavour)

>Cost >= x
Can't see what these variables are, Cost should be lowercase if its a field, x is just a bad name for a field in general, and if Cost is the cost in pennies of a pack of crisps shouldn't you be checking Cost <= pennies.size() ?

The first condition looks like its supposed to be the "correct" one, but it returns null instead of a PackOfCrisps object.
>>
>>57426458
This is the last thing I need to do for this shit exercise, so any help to end my suffering will be appreciated.
>>
File: sucideKillYourself.jpg (314KB, 1239x795px) Image search: [Google]
sucideKillYourself.jpg
314KB, 1239x795px
>>57426497
>any help to end my suffering will be appreciated.
Sure, can do!
>>
>>57426497
Do you need to do that for your uni?
>>
>>57426509
Yep unfortunately.
>>
>>57426517
Kek, just drop out already
>>
>>57426535
>Hopeless NEETs trying to drag others down to their level
>>
>>57426379
>>57426517
what kind of error are you having? after applying >>57426489
>>
>>57426549
I'm not a NEET faggot I'm a student too but this nigger can't even do a simple assignment, he's just wasting his time
>>
>>57426379
You will also need to check if there's any crisps of the specified flavour, ignoring the other problems for a moment, you only seem to check of packet (contains the number of packets in the machine?) .size() >= 1, which means there is at least 1 packet in the machine, but not if that 1 packet is the correct flavour.
>>
>>57426379
>>57426497
I'm a bit worried as to your attitude on this.

Treating it like a dumb bullshit assignment is not where you want to be, because you're demonstrating a basic misunderstanding of how types are returned and used within a function.

That's a fundamental to any of the major languages like this, and it's something you should know very well. If this is your "last assignment", I'm curious as to what your previous assignment look like.
>>
>>57426580
>>57426597
That's the part i'm actually stuck on as I don't know how to search through an array to find the specified flavour.

Also I've corrected the return statements & variable names, so its just that part that I need help on.
>>
>>57426680
What is "packet" ? Is it a standard List type of PackOfCrisps? Is it a List of String containing just the flavours of packets in the machine or is it supposed to be a list of PackOfCrisps objects?

If its a standard List, .remove() will return a true if the item was removed from the list, so you can check
if (packet.remove(flavour)) {
pennies.clear();
System.out.println("Purchase Successful");
return new PackOfCrisps(flavour); /* ? not really sure what this line would be since I haven't seen what a PackOfCrisps is */
} else {
System.out.println("No packet of " + flavour + " crisps available.");
return null;
}
>>
>>57426680
if your packet is an array list of PackOfCrisps objects try packet.get(#), put a number in #.

If your using Eclipse usually you can see a bunch of options by just typing ctrl+space after the dot. See if you have the get(index) show up in there.
>>
File: DeepinScreenshot20161107155202.png (4KB, 304x33px) Image search: [Google]
DeepinScreenshot20161107155202.png
4KB, 304x33px
I just learned this.
I think I officially have cancer now.
>>
>>57426844
This is why we need WebAssembly
>>
>>57426844
Open you browser' console, type
 '5' - '3' 

and
 '5' + '3' 


enjoy
>>
>>57425118
You're stupid. Node is not a language.
>>57425709
>Go
Generally the best compromise between abstraction and performance for backend.
>kore.io
If you really need something that much faster, sure.
>>
Can someone post the newest pro/g/ramming challenges that they have saved ^^
>>
>>57426853
where is the problem? it does make sense.
>>
>>57425118
>Is Node a stupid back end language
ITT: Cringefest and baits
>>
>>57423629
Holy fuck, Britland has lost it's goddamn mind.
>>
>>57426926
wut? no
>>
> get bored waiting for grid engine to finish calculating results
> tired of having to juggle config files and changing hard coded svn paths just to debug my shit
> talk to supervisor about it
> he's fed up with it too
> back when he wrote it he was alone on the project and didn't give a shit about version control
> did everything in the trunk
> hardcoded trunk everywhere
> semi-implemented config files to specify version later but never bothered because his first partner sat in the same office so they both just worked on the trunk
> now get to tinker with the nuts and bolts of the framework instead of doing Pajeet tier high level shit
I love my job.
>>
File: shot0033.jpg (310KB, 1920x1080px) Image search: [Google]
shot0033.jpg
310KB, 1920x1080px
/dpt/-chan, daisuki~

>>57426877
https://better-dpt-roll.github.io/

>>57426853
looks fine.

>>57425118
>Is Node a stupid back end language
yes.
>>
Can anyone help me get this java to work? It compiles, but it doesnt do anything. I think I know why, but I don't really know how to fix it.

    public void equipWeapon(Weapon weapon) {
for (Item item : items.values()) {
if (item instanceof Weapon) {
this.setMinDamage(this.getMinDamage() + weapon.getBonusDamage());
}
}
}
>>
>>57427273
What is the point of looping through all of your items if you don't use any of them? This is ultimately equivalent to
public void equipWeapon(Weapon weapon) {
this.setMinDamage(this.getMinDamage() + weapn.getBonusDamage());
}
>>
>>57427273
>unironically using run time reflection

Don't talk to me or my CPU ever again.
>>
GUYS!
You can get the E-book Python_101 for free, the offer is up for 48 hours, it's pretty neat.
http://leanpub.com/python_101/c/48hours
>>
>>57427335
But why would I want to do that.
>>
>>57427273
>>57427318
nvm, its worse, unless the idea is equipping a weapon adds BonusDamage for every item that is a weapon in your inventory.
>>
>>57425447
Why do you care what people fap to?
>>
>>57427135
Senpai why don't you ever answer to my posts? ;-;
>>
>>57427339
If you want to learn Python. Just thought i'd tell in case anyone was interested
>>
>>57427318
That's kind of my problem. I want to go through the list of items and equip the weapon specified in the parameter if it is an Item of the Weapon-class, and to not do it if it's any other type of Item. But whatever I do I just end up with an equivalent to your method.
>>
>>57427366
You mean, there are people that doesn't already know python?
>>
>>57427369
You want to equip "weapon" to each Item in your inventory that is a Weapon you mean? (with "equip" meaning adds weapon's BonusDamage to item's MinDamage)
for (Item item : items.values()) {
if (item instanceof Weapon) {
item.setMinDamage(item.getMinDamage() + weapon.getBonusDamage());
}
}
>>
>>57427381
I, for example, didn't know everything in that book, sure i knew a lot of it, but there were some good parts that i didn't know
>>
>>57427414
I'm sorry, I probably omitted too much information about my code. This method is in a class called "player", that holds a Hashmap of items, from the class Item and superclass Weapon. minDamage is a field in player, bonusDamage is in Weapon.

What I want to do is to simply add the bonus damage from an item to the players already given minDamage.

Sorry for being shit at describing, pretty new to this.
>>
>>57427454
So you want to check if the argument to equipWeapon(Weapon weapon) is a Weapon...

Anon, weapon is already guaranteed to be a Weapon because you said Weapon weapon instead of Item weapon...

If you also want to check if weapon is in the player's inventory.
public void equipWeapon(Weapon weapon) {
for (Item item : items.values()) {
if (item.equals(weapon)) {
item.setMinDamage(item.getMinDamage() + weapon.getBonusDamage());
return;
}
}

System.out.println("Cannot equip that weapon, its not in the player's inventory!");
}
>>
Anyone here used Heroku at all? I'm interested because it'll save me maintaining a server myself
>>
>>57427414
>>57427318
do you have it the other way around?
Weapon wpn = new Weapon();
Item itm = new Item();
System.out.println(itm instanceof Weapon);
System.out.println(wpn instanceof Item);



One returns true the other doesn't
>>
>>57423605
>EU: Legal
Land of freedom. Mitsudomoe-level comedy is ok, but porn isn't.
>>
>>57427491
No, I want to add the bonusDamage from an Item of subclass Weapon in the HashMap items to the minDamage field of player.
>>
>>57427562
>an Item
but which Item? What is the item's relationship to weapon (the parameter)? You could have a dozen Weapons in your inventory, should all of their bonusDamage be added when you equip any weapon?

Supposedly you are calling this like
player.equipWeapon(sword);

but now you say you don't want to add the bonus damage of "sword" but from some other item in their inventory?
>>
>>57427544
meant to be for >>57427273 . Is Weapon a subclass of Item?
also
- "this" may be referring to something else, not the item you are checking if it is an instance of Weapon. Try adding this if you added the bonus damage properly
System.out.println(item.getMinDamage() );  //take note of this
this.setMinDamage(this.getMinDamage() + weapon.getBonusDamage());
System.out.println(item.getMinDamage() ); // did this change?
>>
which text editor should I use to write code lads?
>>
>>57427718
vim
>>
>>57427626
The item given in the parameter? That's why I said "an Item".

so if there is an object of the class Weapon called "Sword" that is in the HashMap items, I want to add the int value of the field "bonusDamage" in Weapon to the int value of the field "minDamage" in Player.

>>57427683
The get and setMinDamage refers to a field in Player, not Item. But yeah, Weapon is a subclass of Item.
>>
>>57427718
WordPad
>>
What's the best editor with Erlang support?
>>
File: 4dxzUeE.jpg (703KB, 2400x3600px) Image search: [Google]
4dxzUeE.jpg
703KB, 2400x3600px
Do you ever get to a point where you feel like you're good at development?
>>
File: 1477688448752.png (125KB, 512x512px) Image search: [Google]
1477688448752.png
125KB, 512x512px
>>57427720
>don't use vim for a couple years
>forget how to use it

feels bad man
>>
>>57427731
Is the problem that your Player object instance is not getting the extra weapon damage?

this comment >>57427454 also says otherwise. "from the class Item and superclass Weapon", this is not true the other way around, just to make it clear
>>
>>57427731
>The item given in the parameter? That's why I said "an Item".
So weapon IS the Item in their inventory? If that is actually the case, then there's no reason to loop through the items like I said, just do
public void equipWeapon(Weapon weapon) {
setMinDamage(getMinDamage() + weapon.getBonusDamage());
}

but if that is still "wrong" when you test it, I suspect you've misunderstood something.

>so if there is an object of the class Weapon called "Sword"
What do you mean by "called"? Are you referring to a String field in Item that is their name? And what you actually want to do is be able to call equipWeapon like
player.equipWeapon("Sword");
?
>>
>>57427887
Yeah, that is correct.

And yeah, I meant subclass. Sorry about that.
>>
>>57427785
no
>>
File: 1454466061122.png (217KB, 501x648px) Image search: [Google]
1454466061122.png
217KB, 501x648px
Should i get deeper into functional programming if i want to work for a bank and make $$$? I already know decent level haskell and I think I like functional more than imperative. t bh fa m
>>
>>57427785
Yes.
>>
>>57427903
Weapon is a subclass of Item, and the hashmap items holds a list of objects from Item, and thus Weapon.

That method might work, but it would also apply to weapons not in the HashMap items.

I phrased myself poorly on the "called" part, I was going somewhere with it but went a completely different way. I want to call equipWeapon like
player.equipWeapon(sword);
>>
File: iO1cMKy.jpg (712KB, 2400x3600px) Image search: [Google]
iO1cMKy.jpg
712KB, 2400x3600px
>>57427970
How long does it take?
>>
do all you guys use vim? I've been told to use sublime text
>>
>>57427972
>That method might work, but it would also apply to weapons not in the HashMap items.
So again, the solution for that was already given: >>57427491

That checks if weapon is in the player's inventory. If you have a custom definition for equals on Item/Weapon then you might want to do
if (item == weapon)
instead
>>
>>57427983
Depends of your IQ, took me 8 years with 150%.
>>
>>57427947
>work for a bank

lmao

learn COBOL, Fortran, C and Java.
>>
>>57427947
If you want to work for a bank you should learn COBOL
>>
>>57427999
But that doesn't work

first the get and setMinDamage is a field in Player, not Item. Changed to something that would compile leaves me with the initial problem, the field minDamage doesn't change.
>>
>>57428004
>IQ
>150%

kek, you're so smart anon
>>
>>57428061
This.
>>
>>57428031
You have to replace item.set/getMinDamage with just set/getMinDamage too, there were two separate issues with how you were explaining things when that was posted.

To spoonfeed:
public void equipWeapon(Weapon weapon) {
for (Item item : items.values()) {
if (item == weapon) {
setMinDamage(getMinDamage() + weapon.getBonusDamage());
return;
}
}

System.out.println("Cannot equip that weapon, its not in the player's inventory!");
}
>>
>>57427912
Might be possible that you're referencing other instances of player somewhere

Here's a spoonfeed answer which I bet is something that you want
private int damage = 1;
public static void main (String[] args){

Player player = new Player();

Weapon wpn = new Weapon();
wpn.setDmg(10);
player.equipWeapon(wpn);

}

public void equipWeapon(Weapon wpn){
if (wpn instanceof Item){
System.out.println(this.getDamage()); //prints 1
this.setDamage(this.getDamage() + wpn.getDmg());
System.out.println(this.getDamage()); //prints 11
}
}
[/codde]
>>
What is a good autistic book for learning python? The book in my python course is concept based instead of systematic, whatever that means. I need a very detailed technical book with lots of examples and stuff.
>>
>>57428079
under Player class btw
>>
File: 142355478654.png (64KB, 253x215px) Image search: [Google]
142355478654.png
64KB, 253x215px
>>57428061
What's wrong? I'm just saying it would take 12 years for an average human being.
>>
>>57428087
Python in a nutshell?
>>
>>57428119
sure m88, you're so good.
teach me senpai
>>
>>57428129
Thanks, it seems to be what I am looking for.
>>
>>57428079
>>57428072

None of these really do what I need them to do, so I'm going to assume that there is an error elsewhere in my code. guess im just gonna bang my head against the wall for a while till I get somewhere
>>
>Look at the newspaper today
>There's an article about highschool students writing Hello World programs on a raspberry pi for a class.

>4 years ago, the only coding course at my school was for HTML. Just plain HTML.
Is this what feeling old is like? Being bitter because kids have what you wanted but couldn't have?
>>
>>57428167
Well last year at my uni we learned some python but it was really easy stuff.
We had html/css/javascript course too
>>
>>57428031
also make sure that in >>57427972
player.equipWeapon(sword);
, "sword" is in fact as you claim the SAME instance as the one in the players inventory. For example
Player player = new Player();
Weapon aSword = new Weapon("Sword");
player.pickUp(aSword);

/* ... */
Weapon sword = new Weapon("Sword");
player.equipWeapon(sword); // will display "Cannot equip..." message because sword != aSword


>>57428162
when you use >>57428072 does it print the "Cannot equip..." message? That would imply you have the above issue.
>>
File: great151.jpg (94KB, 750x963px) Image search: [Google]
great151.jpg
94KB, 750x963px
>>57428119
You're all arrogant on the outside, does that mean you're dead and worthless on the inside?
>>
>>57428167
Honestly, that's no more complicated than writing HTML depending on how it's presented.
>>
>>57428162
Last try, because I just feel like your problem is that "this" may be pointing to something else. Point it to the Player object instead:


public class Player {

private int damage = 1;
public static void main (String[] args){

Player player = new Player();

Weapon wpn = new Weapon();
wpn.setDmg(10);
player.equipWeapon(wpn, player);

}

public void equipWeapon(Weapon wpn, Player player){
if (wpn instanceof Item){
System.out.println(player.getDamage()); //prints 1
player.setDamage(player.getDamage() + wpn.getDmg());
System.out.println(player.getDamage()); //prints 11
}
}
>>
>>57428210
Yes, I am.
>>
>>57428167
No, feeling old is when every interview is algorithm and data structure quizzes meant for people who just graduated. There was a trend to hire and teach people without the CompSci background because they could hire them more cheaply but now they've changed the playbook. Now they keep new hire ages lower since that is cheaper than hiring non-CompSci students. All of this despite the fact that most companies are still glueing APIs and shit together and are overtesting for skills.
>>
File: Screenshot_2016-11-07_19-06-25.png (37KB, 488x581px) Image search: [Google]
Screenshot_2016-11-07_19-06-25.png
37KB, 488x581px
Finished server-side post parsing + unit tests. Now working on post and thread creation.
>>
>>57428288
>unit tests
Well memed /(x.x)\

It would be cool if users could use custom css when creating a thread. What do you think?
>>
>>57421537

> object oriented conway's game of life

do it in opengl with a geometry shader in C++
>>
jesus christ sorry to
>>57428221
>>57428207

after further inspection it seems that the .equals part did the job after all, I had just not capitalized a letter in the Weapon constructor.

Sorry for being a retard
>>
File: Screenshot_2016-11-07_19-16-18.png (249KB, 662x658px) Image search: [Google]
Screenshot_2016-11-07_19-16-18.png
249KB, 662x658px
>>57428329
Choice of CSS should be left to the viewing end user not thread creator, as he is the one actually consuming the content and therefore the most affected by any choice CSS. That can already be done, if you enable JS (+ putting any image you want as a background).
>>
>>57426853
Well "-" implicitly casts the strings because it does operations on numbers and the "+" works as a concatenation.
Everything's fine chill.
>>
>>57428119
>Pretending to be smart and failing basic cross-product.

| IQ    - 100% - 1/150% |
| Years - 8 - x |

x = 8 * 0.66... ~= 13.3

Kys.
>>
https://pzemtsov.github.io/2016/11/06/bug-story-alignment-on-x86.html

So I thought C was actually portable?
>>
>>57428417
fuuck me I meant
8 / 0.66

w/e you got the point... I guess it doesn't work now though
>>
>>57428411
Everything is not fine
>>
>>57428420
It is if you don't trigger any undefined behavior anywhere in your code.
>>
>>57428374
kek its alright senpai
>>
>>57428402
Then what about using the op image as background? (If the dimensions are big enough to fit the screen, it could be computed on the fly)

I really think this could help visual memory while browsing.
>>
>>57428439
I agree JS is flawed but I don't think that example is a major fuckup.
[] + 0 = "0" 
{} + [] = 0
[] + {} = [object Object]


The beauty...
>>
>>57428516
Yeah but that was the example I had in mind
This language is shit anyway
>>
File: 1461306157667.png (213KB, 750x750px) Image search: [Google]
1461306157667.png
213KB, 750x750px
>>57422244
Python
Python
Python
Python

Not even meming. I lost any interest in looking for other languages, busy actually writing things. Pic unrelated.
>>
>>57422244
JavaScript
JavaScript
Swift
JavaScript
>>
>>57428598
>Nim
What a shit language
>>
File: 1478351317786.png (73KB, 2048x1024px) Image search: [Google]
1478351317786.png
73KB, 2048x1024px
>>57423414
>>
File: .png (8KB, 429x31px) Image search: [Google]
.png
8KB, 429x31px
>>57428516
lmao
>>
>>57428648
>JS users are this stupid
>>
>>57428648
>>
>>57428648

You're worse than JS.
>>
>>57428648
oh wait fug
>>
>>57428701
harsh
>>
Why would you use C++ for a new project in 2016
>>
>>57428507
An interesting idea, but that could be a bad combination with the theme the user had chosen, especially themes with transparency. I wonder if this can be worked around somehow.
>>
>>57426853
Even worse can come out of implicit casting of strings to numbers. For example, '0' behaves like true in boolean expressions but is equal to false.
>>
>>57421367
Can someone explain OP's pic to me?

>4bit processor
The intel 4004.
>8bit OS
I thought maybe CP/M, but it was 8bit from the start and not written for the 4004.
>16bit patch
What does this mean? I thought maybe it meant MS-DOS, but DOS was based on QDOS and 16 bits from the start. It was somewhat inspired by CP/M, but definitely not a patch.
>>
File: wew.png (12KB, 115x111px) Image search: [Google]
wew.png
12KB, 115x111px
>jshit
>>
>>57428837
>Scanf is deprecated

wut?
>>
>>57428883
use ===
>>
>>57428516
does make sense actually
>>
>>57428947
whoops, I menat =====
>>
How will C compete once we reach network-on-a-chip processors where different cores don't even share memory anymore?
>>
>>57428985
>network-on-a-chip processors where different cores don't even share memory anymore?
That's way too slow, nobody does that outside of a classroom.
>>
>>57428985
you know that HPC are programmed in C and C++, right?
>>
>>57428985
>how will C compete in HPC where different nodes don't share a memory bus
Gee, I don't know
>>
File: umarusummer.jpg (56KB, 848x480px) Image search: [Google]
umarusummer.jpg
56KB, 848x480px
>>57428985
https://en.wikipedia.org/wiki/Message_Passing_Interface
>>
>>57428985
How will C compete once STEM is entirely pajeet?
>>
File: 1475664033489.jpg (68KB, 633x758px) Image search: [Google]
1475664033489.jpg
68KB, 633x758px
>>57429001
>>57429009
>>57429034
D-DELETE THIS
>>
>>57428516
what's the problem?
>>
>>57428995
Yeah, except, you know, the entire fucking internet.
>>
>>57429080
And how often do you do computations over the internet?
Only when all the faster options have already been taken.
>>
>>57429091
https://en.wikipedia.org/wiki/Distributed_computing

Pretty often, actually ;^)
>>
>>57428807
i'm glad i'm not the only one that autismed at that pic.
>>
>>57429100
No need to be cheeky, that's exactly what I'm referring to.
Point being if you parallelize on computer cluster before you take advantage of all your local cores, you're doing it wrong.
>>
File: 129540076418.jpg (753KB, 3000x2805px) Image search: [Google]
129540076418.jpg
753KB, 3000x2805px
>>54865579
>>54864936
>>54865095
What does this even mean? I'm trying to make a (good) python proxy checker and have pretty much the same problem.
All of the proxy checkers I have tried to write so far are trash. Help?
>>
>>57428995
These systems already exist. It's the next logical step after multi-core CPUs. If you're talking dozens, hundreds, potentially even thousands of cores it doesn't make sense for them to all share system resources. In fact, shared memory rapidly bottlenecks performance.
>>
>>57429091
how do you think universities are sharing their super computers? when a japan university uses the super computer from Stanford, it's done entirely through internet.
>>
>>57428807
>>57429113
Can you stop analyzing this please?

In situations like that, you're supposed to look at the snarky comment and smugly agree with the author, regardless of the potential issues in the underlying assumptions used to present their case.

We were kings. And stuff.
>>
>>57429141
And that's already a solved problem, with a solution implemented in C.
>>
>>57429142
Yes, I agree.
How often do you personally use a supercomputer?
>>
>>57429141
wrong, otherwise intel would not use multiple levels of cache.
>>
>>57429162
I didn't realize C was a magic language that can override the physics of the underlying hardware.
>>
>>57429170
That's completely irrelevant.
>>
>>57429180
It isn't.
I don't get this trend where people think they're being clever by attacking a straw man.
You're wasting both of our time by intentionally missing the point.
>>
>>57429170
Intel is doing what, 8 cores for consumer CPUs? Maybe you should take a look at supercomputer architecture.
>>
>>57428191

> at your uni

you would expect way more
>>
>>57429169
pretty much every time I search google or post on 4chan
>>
>>57429196
You have 64 cores that are all trying to access memory simultaneously. Tell me how C allows you to bypass this hardware bottleneck.
>>
>>57429202
>what is intel xeon phi
>what is numa
>what are gpus
>>
File: Untitled.jpg (2MB, 10000x9350px) Image search: [Google]
Untitled.jpg
2MB, 10000x9350px
>>57429140
>>
>>57429205
It was first year anon and it was a "generic" year, I don't know how to say that but in France to get in some school you have to do a two years preparation and you do all kind of things in maths physics chemistry and compsci
>>
>>57429220
C works fine over a network, you didn't exactly invent the idea of distributed systems.

But regardless, it's not impossible to manage 64 cores accessing the same memory in C and get decent performance.
If they're accessing different data, then C allows you to control memory layout to ensure no conflicts beside bandwidth issues, which is mitigated on a NUMA system.
If they're all reading the same data, then it will be cached.
If they're all writing the same data, then your algorithm is fundamentally slow.
>>
>>57429132
>if you parallelize on computer cluster before you take advantage of all your local cores, you're doing it wrong.

Not at all, friend! If you have a coarse grained MapReduce type workload that allows simple, efficient distribution between machines, it's much better to do that than to try to take advantage of multiple cores.

It's hard to find a machine with more than 256 cores, but it's easy to build/buy/rent a network with more than 256 machines. And you can always run N instances of your program on a N-cpu machine.

Fine-grained HPC workloads are a different story though.
>>
>>57429345
That's only true if you ignore the cost of spinning up those 256 machines and running your workload.
Or, if you're using a cloud provider, the cost of absurdly high usage fees for the "convenience of cloud".
>>
>>57429396
>>57429396
>>57429396
>>
>>57429345
>It's hard to find a machine with more than 256 cores
right now, xeon allows up to 96 cores (192 threads with HT) per machine
xeon phi has 72 cores (288 threads) per card. some motherboards can receive up to 8 xeon phi cards.
nvidia tesla has thousands of cores per card.
>>
>>57429401
What the fuck do you think you are you doing?
>>
>>57428420
>portable
Since he went for a non-portable answer anyway, he could've used
const uint32_t* q
#if defined (__GNUC__)
__attribute__((aligned(1)))
#endif
>>
>>57422182
i agree, it's 2d so what's wrong
>>
>>57430258
>>>/global/rules/
>>
File: =(^ω^)=.jpg (46KB, 414x435px) Image search: [Google]
=(^ω^)=.jpg
46KB, 414x435px
>>57430258
>[Deleted]
>>
>>57422426
does that mean you dont code in your fav language in your free time?
Thread posts: 313
Thread images: 39


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