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

/dpt/ - Daily Programming Thread


Thread replies: 312
Thread images: 28

File: yF1VCTm.jpg (89KB, 1366x768px) Image search: [Google] [Yandex] [Bing]
yF1VCTm.jpg
89KB, 1366x768px
old thread: >>51866080

What are you working on, /g/?
>>
>>51870998
Learning about compilers
Also first for D
>>
>>51870998
>Knuth will die in your lifetime
>>
>mfw hasklelfags think their language is relevant
>mfw hasklel has 20 libraries for any one task
>mfw not a single one of them is even remotely usable in real life
>mfw even fucking common lisp has a better track record in 2015 in the real world than hasklel
>nfw
>>
>>51871032
http://neetco.de/languagedev/language <- my compiler
>>
itt: /g/tards can't average 2 ints in 6502 assembly
>>
File: 010.jpg (38KB, 460x315px) Image search: [Google] [Yandex] [Bing]
010.jpg
38KB, 460x315px
>>51870985
>tfw i might need to retake it because im a huge lazy fuck
>>
>>51871064
Yeah, I saw in the last thread
What does your language look like?
>>
>>51870954
Would appreciate some insight; would rather a hint over the answer.
>>
File: 1450143580507.png (2KB, 170x331px) Image search: [Google] [Yandex] [Bing]
1450143580507.png
2KB, 170x331px
/dpt/ challenge!
  codesnips  ./gchallenge "meme master"
m m m
e e e
m m m
e e e

m m m
a a a
s s s
t t t
eee
meme masteretsam emem
eee
t t t
s s s
a a a
m m m

e e e
m m m
e e e
m m m


Replicate this program in any language of your choosing, then post how long it took you.
>>
>>51871103
let fn = lambda (x, y) x + y;
let gn = lambda (z) 3 fn fn(4, z);
while #t
if { { if (x < 3) x; 5; } > 3 } {
gn(5);
} else {
gn(6);
}
\* nestable \* comments *\ are available *\
\\And so are line-wise comments.

Very experimental at this point, compiles to llvm IR.
>>
>>51870312
I improved my script, what do you guys think ?
def advanced_shitpost(x):
number = 0
list = [ ]
for i in x.replace(" ", ""): list.append(i.upper())
for i in list:
print " ".join(list[number:])
number += 1
def normal_shitpost(x):
list = [ ]
for i in x.replace(" ", ""): list.append(i.upper())
print " ".join(list)
for i in list[1:]: print i
def advanced_shitpost_spaces(x):
number = 0
list = [ ]
for i in x: list.append(i.upper())
for i in list:
print " ".join(list[number:])
number += 1
def normal_shitpost_spaces(x):
list = [ ]
for i in x: list.append(i.upper())
print " ".join(list)
for i in list[1:]: print i
while True:
print "1: advanced shitpost\n2: normal shitpost\n3: advanced shitpost with spaces\n4: normal shitpost with spaces"
inp = raw_input("Pick a shitpost: ")
if inp == "1": advanced_shitpost(raw_input("Shitpost: "))
elif inp == "2": normal_shitpost(raw_input("Shitpost: "))
elif inp == "3": advanced_shitpost_spaces(raw_input("Shitpost: "))
elif inp == "4": normal_shitpost_spaces(raw_input("Shitpost: "))
else:
break
>>
>tfw born too late to program in pure binary
>>
>>51871264
Install Gentoo
>>
>>51870972
grab all the elements, if the value is "ownr" then select it
>>
Constraint Logic Programming in Prolog:

How do I make a 24hr schedule for 30 tasks between 6 resources, each resource having varying duration for each task and cost of use? I need to minimize time/cost.

I understand how to do it with just minimizing cost, but this scheduling part is throwing me off.
>>
>>51871307
Will Arch work?
>>
>>51871319
Absolutely not
>>
>>51871313
Stop using meme languages. Use Church.
>>
File: IBMsWatson.png (94KB, 462x288px) Image search: [Google] [Yandex] [Bing]
IBMsWatson.png
94KB, 462x288px
>>51871339

But Prolog is master race.
>>
>>51871385
Watson never used anything even remotely prolog-related. Kill yourself, memefailure.
>>
>>51871127
$ ./star "meme master"
m m m
e e e
m m m
e e e

m m m
a a a
s s s
t t t
eee
meme masteretsam emem
eee
t t t
s s s
a a a
m m m

e e e
m m m
e e e
m m m


>tfw 1hr40m

Rate my C implementation.
https://paste.installgentoo.com/view/raw/995a844c
>>
>>51871412

do u even google m8
>>
Digital image processing. I'm acquiring my heart rate signal from readings of the brightness signal of the 3 planes(rgb) of my forehead (previously detecting my face). Can't believe its actually working.
Based on a paper and some examples around the internet.
>>
>>51871534
link to paper/examples?
>>
>>51871476
>jaba is a tip of proleg????//
Based retard.
>>
>>51871049
It's true

>trying to do some stuff with x windows in haskell
>using the x11 bindings (package is just called x11)
>missing xgetimg completely

>try xhb instead
>has xgetimg
>one of its arguments is a DRAWABLE
>go try to figure out what a DRAWABLE type is
>its constructor isn't exported by the package
>have to make workaround

I got it to work while writing this though
>>
>>51871688

cool trolling bro. have one more (You).
>>
Any of you use Adderall, how is it?
>>
>>51871794

>addy

Modafinil 4 life breh
>>
Java
A
Shit
>>
>>51871650
For the examples search for webcam-pulse-detector + github, and ignaciomellado + measuring heart rate with smartphone.

The paper is Non-contact, automated cardiac pulse measurements using video imaging and blind source separation (MIT)

Sorry links are being considered spam here and I'm not sure how to post them
>>
>>51871827
explain pls
>>
>>51871794
I don't know, but caffeine is overrated as fuck. I just took my first cup of coffee ever because I was feeling a little lethargic and I don't feel anything. My eyes are still a little heavy, even.
>>
>>51871038
>Hitler died before your lifetime
>>
>>51871855
nigga, unless you injected it you have to wait for it to take effect (45 minutes?)
>>
I was learning Haskell but decided to ditch it for Python, for now. I'll revisit it later because it looked so fucking cool, even if useless.
Good choice?
>>
>>51871855
>this is what normies actually believe
coffee has an effect. it might be overrated but not for the reason you're implying
>>
>>51871922
Can I insert it directly into the bloodstream via my anus like alcohol?
>>
>>51871964
just put a caffeine pill under your tongue, it will go into the blood stream faster
>>
>>51871922
Much like alcohol, it depends on various factors.
If he's eaten a meal in the past few hours, it won't have as strong of an effect as if he drank it on an empty stomach.
It also depends if he's taking small sips or big gulps. Big gulps (with not much time between) will have a bigger effect.
Lastly, everyone has a different "responsiveness" to whatever they ingest. Some people need a lot of a substance to feel an effect, while others only need a little.

Basically, he should skip normie stims entirely and just go straight to smoking meth.
>>
>>51871964
yes

https://drugs-forum.com/forum/showthread.php?t=178543
>Caffeine is very bioavailability rectally so yeah the caffine will be felt

>https://en.wikipedia.org/wiki/Coffee_enema
kek
>>
>>51871855
>I don't know, but caffeine is overrated as fuck
Not really, nobody ever claimed it was as powerful as the good stimulants (amphetamines (adderall, dexamp), methamphetamine). The only purpose it serves is making you not feel tired, but some idiots out there think that drinking 5 cups of coffee will give you something comparable to good stimulants.
>>
>>51872026

I find coffee helps me focus too, even when I have some when I'm not tired. I don't drink it very often though.
>>
>>51871928
Haskell's fun. Python will leave you wanting more.
>>
>>51872110
I know haskell is fun, but I'm looking for useful and employable (in the fast-to-write family)
>>
>>51872026
I don't think I want to dabble with better stimulants, really. I have a pretty addictive personality as you can tell by my high-chaser let down.
>>
>>51871469
>unsigned
>sizeof(char)
>casting the return value of malloc
>mallocing a fucking string
why are C programmers so autistic?
>>
>>51872178
because he's new
it's not C programmers, it's noobs, and most noobs here are learning C as their first language
give him time
>>
File: ruby.png (89KB, 959x833px) Image search: [Google] [Yandex] [Bing]
ruby.png
89KB, 959x833px
Why is she so ugly, /g/?
>>
>>51872305
Why are you so ugly anon?
>>
I'd be happy for a little code review on this, is there anything I could have done better?

Goal: find the number of permutations of a list that will give you the same binary search tree.

example:
there are two permutations of [1,2,3] that will give you the binary search tree:
  2 
/ \
1 3

[2,1,3] and [2,3,1]

from math import factorial
class Tree:
def __init__(self, values = None):
self.left = None #left node
self.right = None
self.lc = 0 #number of nodes on the left tree
self.rc = 0
if type(values) == list: #add initial values to tree, if any
self.root = values[0]
for value in values[1:]:
self.add(value)
else:
if values != None:
self.root = values #add value to root node

def add(self, value):
if self.root > value:
self.lc += 1#incriment left node counter for this tree
if self.left:
self.left.add(value)
else:
self.left = Tree(value)
else:
self.rc += 1
if self.right:
self.right.add(value)
else:
self.right = Tree(value)

def binomial(n,k):
return factorial(n)/(factorial(k)*factorial(n-k))

def permute(tree):
if not tree: #only one way to permute a tree of size 0
return 1
options = permute(tree.right)*permute(tree.left)
choice = binomial(tree.lc + tree.rc, tree.rc)
return options*choice
def answer(seq):
return permute(Tree(seq))
>>
>>51872178
ooh, ooh, do me, do me

http://pastebin.com/8QiT52hZ
>>
>>51870998
Stop this programming trap meme.
Thanks.
>>
>>51872422
>assuming argv[1] exists
nice
>>
>>51872422
Isn't there a way to do cin and cout without the std::? I'm not familiar with C++
>>
>>51872132
Try Ruby, it's pretty alright.
>>
How do classes in python even work if types are implicit
???
>>
>>51872478
using namespace std;
>>
>>51872479
nah, sticking with the py unfortunately
>>
File: 20151213_154221.webm (625KB, 1920x1080px) Image search: [Google] [Yandex] [Bing]
20151213_154221.webm
625KB, 1920x1080px
The internet meme sign guy here again. I want to test out some new functionality; send me some memes right quick. You should receive back "Sent :^)" if it goes through.

import socket

UDP_IP = "97.86.102.68"
UDP_PORT = 5005
MESSAGE = input("What meme do you want to send?\n>>> ")

print("UDP TARGET IP:\t\t", UDP_IP)
print("UDP TARGET PORT:\t\t", UDP_PORT)
print("MESSAGE:\t\t\t", MESSAGE)

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(MESSAGE.encode('ascii'), (UDP_IP, UDP_PORT))
print(sock.recv(1024).decode('ascii'))
>>
>>51871127
W          W          W
E E E

W W W
U U U
Z Z Z

K K K
I I I
N N N
GGG
WE WUZ KINGZGNIK ZUW EW
GGG
N N N
I I I
K K K

Z Z Z
U U U
W W W

E E E
W W W



https://paste.installgentoo.com/view/1bae4a9f

about an hour
>>
>>51872557
>>
File: 20151214_233828.webm (655KB, 1920x1080px) Image search: [Google] [Yandex] [Bing]
20151214_233828.webm
655KB, 1920x1080px
>>51872589

got it; thanks
>>
Whats your favorite outfit to put on when coding?
>>
>>51872610
the memes jack
>>
File: fZQOg8v.gif (2MB, 400x595px) Image search: [Google] [Yandex] [Bing]
fZQOg8v.gif
2MB, 400x595px
>>51872610
Noice
>>51872616
>clothing
>implicando
>>
>>51872557
do you go to the same school as me? i swear i saw this same thing the other day
>>
File: 0poQQ.jpg (20KB, 465x446px) Image search: [Google] [Yandex] [Bing]
0poQQ.jpg
20KB, 465x446px
int foo;
if(bar) {
foo = 0;
}
if(bar) {
fizzbuzz(foo);
}


>The local variable foo may not have been initialized
>>
So if I understand jack shit about programming but would like some introductory reading, where should I start?
>>
>>51872616
Usually just my hoodie and sunglasses. If I'm going into a really serious session of coding, I put on my balaclava.
>>
>>51872664
Depends, what do you plan on doing with it?
>>
>>51872664
https://docs.oracle.com/javase/tutorial/
>>
>>51872664
C Primer Plus by Stephen Prata
>>
>>51872681
At most, just some hobbyist tinkering.

>>51872683
>>51872685
Thanks anon.
>>
>>51872663
>le ebin reddit face trole :^)
>>
I found a python API that accesses 4chan; might be cool to have my sign read off the latest posts from the roguelike general or something.

Changed around some of the threading stuff so wanted to see if it was still handling multiple communications properly, thanks again guys.

>>51872652

I was posting this on Saturday for a bit after having put it together on Friday. Graduated last May so no I don't got to the same school as you.
>>
>>51872720
shit, must have got my head mixed up with that post from saturday.

project is awesome though, hopefully you can put instructions up sometime.
>>
So say I "know" a programming language, but I'm not creative enough to make stuff with it. What can I do to use the language? Programming projects or something? Is there a website for that?
>>
>>51872826
Websites typically don't have projects good (either difficult or project-y) enough for that... Unfortunately you're pretty much lost until you come up with an idea. It's painful.
You could try https://better-dpt-roll.github.io/ if you want.
>>
>>51872826
CodeEval, Project Euler, Coding Game, /dpt/ roller, the list goes on forever.
>>
>>51872689
Depends on the type of tinkering you want to do. You might be interested in Racket. It's weird as hell for a first language, but it has some pretty potent capabilities for quickly building prototype applications.
>>
>>51872847
>https://better-dpt-roll.github.io/
Neat!
>>51872856
>Project Euler
This is great, thanks.
>>
Okay, I spent a hell of a long time working on this stupid integer averaging, and I think I have a correct solution (C/C++ BTW):

void inline swap(int& a, int& b)
{
a ^= b;
b ^= a;
a ^= b;
}

int avg(int a, int b)
{
if (a < b)
swap(a, b);

int simple_average = (a / 2) + (b / 2);
int leftover = ( ((a % 10) + (b % 10) ) / 2) - ( ((a % 10) / 2) + ((b % 10) / 2));
if (simple_average < 0)
{
simple_average += leftover;
return simple_average - ( (a & 0x1) ^ (b & 0x1) );
}
else
{
simple_average += leftover;
return simple_average + ( (a & 0x1) ^ (b & 0x1) );
}
}


The output seems correct, as compared to a version I wrote that converts to double and uses round(). I print some intro stuff, then a grid showing -5 .. 10 added to -5 .. 10:

INT_MIN is -2147483648
INT_MAX is 2147483647
avg(INT_MIN, 0) is -1073741824
avg(INT_MAX, 0) is 1073741824
avg(INT_MIN, INT_MAX) is -1
-5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10
-5 -5 -5 -4 -4 -3 -3 -2 -2 -1 1 0 1 1 2 2 4
-4 -5 -4 -4 -3 -3 -2 -2 -1 -1 0 1 1 2 2 3 3
-3 -4 -4 -3 -3 -2 -2 -1 1 0 1 1 2 2 3 3 5
-2 -4 -3 -3 -2 -2 -1 -1 0 1 1 2 2 3 3 4 4
-1 -3 -3 -2 -2 -1 1 0 1 1 2 2 3 3 4 4 6
0 -3 -2 -2 -1 1 0 1 1 2 2 3 3 4 4 5 5
1 -2 -2 -1 -1 0 1 1 2 2 3 3 4 4 5 5 6
2 -2 -1 1 0 1 1 2 2 3 3 4 4 5 5 6 6
3 -1 -1 0 1 1 2 2 3 3 4 4 5 5 6 6 7
4 1 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7
5 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8
6 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8
7 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9
8 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9
9 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10
10 4 3 5 4 6 5 6 6 7 7 8 8 9 9 10 10
>>
>>51872922
Project Euler is very math heavy, it barely has anything to do with programming.
If you want something fun, go for Advent of Code, it's only halfway through the month, you're not too late.
>>
>>51872883
Seconding Racket
>>
>>51872964
void swap(int *a, int *b)
{
register int tmp = *a;
*a = *b;
*b = tmp;
}

what's wrong with a temp variable swap you fucking autist
>>
>>51872964
>
void inline swap(int& a, int& b)
{
a ^= b;
b ^= a;
a ^= b;
}

Rewrite that with a temporary variable instead and profile both. You'll discover that the XOR trick is actually slower.
>>
>>51872999
>register
>>
>>51872970
This. Project Euler could be more accurately titled '47,000 different aggregate operations on all the prime numbers smaller than X'.
>>
File: 1428918032128.png (75KB, 600x600px) Image search: [Google] [Yandex] [Bing]
1428918032128.png
75KB, 600x600px
>>51872999
>register
>>
>>51872999
>>> a = 5
>>> b = 10
>>> a
5
>>> b
10
>>> a, b = b, a
>>> a
10
>>> b
5
>>>
>>
>>51872964
look in your grid, it says 1 for (0,-1) for instance which is incorrect (it should be 0)

and don't forget that it's supposed to round toward zero instead of toward negative infinity
>>
>>51873041
w h a t d o y o u t h i n k t h a t d o e s
>>
>>51873028
>>51873038
what's wrong with it?
>>
>>51872999

I don't care? Talk about bikeshedding.

>>51873016
>Rewrite that with a temporary variable instead and profile both.

How about I don't, because I don't care? Now, how about you focus on the meat of the problem instead of giving me your CS101 sage advice.

God, these comments remind me of the retarded shit I've heard coworkers say in code reviews.

>>51873056
>look in your grid, it says 1 for (0,-1) for instance which is incorrect (it should be 0)

No, it shouldn't. The average of (0, -1) is -0.5. Rounded, that is -1.

Rounding moves away from zero, not just "up".
>>
>>51873063

It's $CURRENT_YEAR.
>>
>>51873070
integers are truncated toward zero m8. and it says +1, not -1
>>
>linked lists have no purpose
>lisp, haskell, python, etc
noice
>>
>>51873062
seems pretty simple to me
the value of a is swapped with the value of b, and the value of b swapped with a
>>
>>51873082
pythonfags, everyone
>>
>>51873085
this
>>
>>51873076
>integers are truncated toward zero m8

The goal isn't to truncate, that's dirt simple. The goal is to round correctly.

> and it says +1, not -1

Oops, now that I'll grant you.
>>
does $command just summon a subshell?
>>
>>51873070
>that first and second reply
No need to be upset anon
>>
>>51873096
averaging with truncation is harder than you would expect for signed ints.
>>
File: a.png (18KB, 1096x441px) Image search: [Google] [Yandex] [Bing]
a.png
18KB, 1096x441px
>>51871127
15min
>>
>>51873085
>hurr python
Explain what's wrong with it, then, smart ass.
>>
>>51873136
computing doesn't work by magic. "the snake" does something like >>51872999 behind the scenes and that's what >>51873062 was referring to.
>>
>tfw woke up late
>just finished AoC Day 15
>according to the leaderboard, I would have made it had I woken up on time
Fuck my life lads, I knew I shouldn't have stayed up late memeing with you
>>
>>51873085
>>51873092
You are now aware that x86 assembly has instructions for swapping without using temp storage.
>>
>>51873148
Well, yeah.
That's kinda the entire point of python though, the programmer doesn't have to worry about what's going on behind the scenes.
>>
>>51873150
it doesn't matter anyway. some pleb came up with that game and you're shaping your life around it like the good goy you are
>>
>>51873070
>CS101 sage advice
Sure, how about I explain to you WHY the XOR trick is slower then?
Modern CPUs can execute multiple instruction in parallel IF they do not depend on each other, this is called INSTRUCTION PIPELINING. The XOR trick involves 3 interdependent operations, which throws it out the window.

Profile it to confirm, and stop fucking premature "optimizing" with 40+ year-old tricks designed for fucking mainframes.
>>
>>51873163
which is absolutely disgusting and python is unsuitable as a first language
>>
>>51873164
Some pleb came up with 4chan and you're wasting your time on it like the good goy YOU are
>>
>>51873123

Uh. It's easy compared to what I was working on:

// Average with truncation
int avg(int a, int b)
{
if (a < b)
swap(a, b);

int simple_average = (a / 2) + (b / 2);
int leftover = ( ((a % 10) + (b % 10) ) / 2) - ( ((a % 10) / 2) + ((b % 10) / 2));
simple_average += leftover;

return simple_average;
}


output:
INT_MIN is -2147483648
INT_MAX is 2147483647
avg(INT_MIN, 0) is -1073741824
avg(INT_MAX, 0) is 1073741823
avg(INT_MIN, INT_MAX) is 0
-5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10
-5 -5 -4 -4 -3 -3 -2 -2 -1 -1 0 0 0 1 1 2 3
-4 -4 -4 -3 -3 -2 -2 -1 -1 0 0 0 1 1 2 2 3
-3 -4 -3 -3 -2 -2 -1 -1 0 0 0 1 1 2 2 3 4
-2 -3 -3 -2 -2 -1 -1 0 0 0 1 1 2 2 3 3 4
-1 -3 -2 -2 -1 -1 0 0 0 1 1 2 2 3 3 4 5
0 -2 -2 -1 -1 0 0 0 1 1 2 2 3 3 4 4 5
1 -2 -1 -1 0 0 0 1 1 2 2 3 3 4 4 5 5
2 -1 -1 0 0 0 1 1 2 2 3 3 4 4 5 5 6
3 -1 0 0 0 1 1 2 2 3 3 4 4 5 5 6 6
4 0 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7
5 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7
6 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8
7 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8
8 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9
9 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9
10 3 3 4 4 5 5 5 6 6 7 7 8 8 9 9 10
>>
>>51873174
it's great as a third language, you can learn it in a single evening
>>
What's the best documentation/basic tutorial on LLVM IR? I want to add support for it to my Brainfuck compiler and would prefer not going through some obscure 4000 page reference or something
>>
>>51873169
He's insecure because he spent so much time on the meme and didn't get his epeen stroked like he expected
:^(
>>
>>51873169

Hey, dipshit, did you skip the part where I said I don't care?

Literally, I do not care. Performance is of absolutely zero consequence in this application. It is literally the first thing that popped out of my head. If you don't like it, I do not care. I'm sorry I even posted that function, since clearly it has just derailed your simple, autistic mind.
>>
>>51873136
python is a language that abstracts many concepts away from the user: it simplifies things in such a way that obscures what's going on underneath

this reply >>51873062 which i'll grant is tongue-in-cheek is, from my perspective, trying to point out that the underlying method of >>51873041 which isn't as explicit in python as in, say, c, is the same as earlier replies >>51872999

my comment >>51873085 was pointing out that (some) users of python aren't familiar with what goes on "behind the scenes" in their code

yes, i have autism
>>
>>51873174
I don't see what the issue is.
It seems perfectly fine as a beginner language to me.
There are many libraries available, so you can accomplish just about anything without having to reinvent the wheel, and it teaches the basic concepts just fine.
>>
>>51873216
Alright then python boy, why don't you implement >>51871127 without using any builtin string libraries?
>>
>>51873279
>>51873134
>>
>>51873279

>2015
>being this obsessed with string manipulation

Not GP, but what's your point? You don't like productive tools?
>>
>>51873199
It's okay anon, we know you're mad because you got called out for using a trick that's actually slower, but shouting I don't care over and over again won't fix that. Just accept that you made a dumb mistake and move on
>>
>>51873279
>without using any builtin libraries
Why?
What's the point?
Why should I not use the resources available to me?
>>
>>51873182
int avg_round_up(int a, int b)
{
if((a < 0) == (b < 0)) {
return a / 2 + b / 2 + (a % 2 | b % 2);
}
if(a % 2 != b % 2) {
return (a + b) / 2 + ((a + b) > 0 ? 1 : -1);
}
return (a + b) / 2;
}
>>
>>51873216
>There are many libraries available, so you can accomplish just about anything without having to reinvent the wheel
and as soon as you go beyond consuming other people's wheels you don't have a clue what to do
>>
>>51873348
>a + b
nice overflow
>>
>>51873309

Uh, okay, if that amount of projection makes you feel better, go ahead.
>>
>>51873362
I can only assume such based on your angry reply to the anon who was just trying to give you some nice advice
>>
>>51873361
>if((a < 0) != (b < 0))
>>
Is there a way to change a specific value in a .txt file using c++? Can I then make an entire new column within the text file?
>>
>>51873374

>angry

What is with your projection?
>>
>>51873385
FILE *out = fopen("filename string", "a+");
>>
>>51873362
XOR
>>
>>51871127
I see you reposted my OC (just the output)

Here's the code from last thread:

import System.Environment
main = getArgs >>= putStr . memeString3 . (!!0)

memeString3 s = unlines $ inOrder ++ [s ++ drop 1 (reverse s)] ++ reverse inOrder
where inOrder = zipWith aLine (take (len - 1) s) [1..]
aLine c n =
let divider = replicate (len - n - 1) ' '
in replicate (n - 1) ' ' ++ [c] ++ divider ++ [c] ++ divider ++ [c]
len = length s
>>
What are some good uses for the goto statement?
I can't think of any cases where an if/else loop wouldn't look cleaner, but then again I haven't been at this for very long.
>>
>>51873417
>XO
get >>>/out/
>>
>>51873407
I'm not angry though
Just read the second reply in this >>51873070 and tell me you weren't unnecessarily upset
>>
>>51873362
Code review
>>
>>51873385
You can change characters, but I'm pretty sure not insert new ones in the middle. If you want to do that, you'd have to create a new file.
>>
>>51873348

Nope.

INT_MIN is -2147483648
INT_MAX is 2147483647
avg(INT_MIN, 0) is -1073741824
avg(INT_MAX, 0) is 1073741824
avg(INT_MIN, INT_MAX) is -1
-5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10
-5 -5 -5 -4 -4 -3 -3 -3 -2 -2 -1 -1 1 2 2 3 3
-4 -5 -4 -4 -3 -3 -2 -2 -1 -1 0 1 1 2 2 3 3
-3 -4 -4 -3 -3 -2 -2 -2 -1 -1 1 2 2 3 3 4 4
-2 -4 -3 -3 -2 -2 -1 -1 0 1 1 2 2 3 3 4 4
-1 -3 -3 -2 -2 -1 -1 -1 1 2 2 3 3 4 4 5 5
0 -3 -2 -2 -1 -1 0 1 1 2 2 3 3 4 4 5 5
1 -3 -2 -2 -1 -1 1 1 2 2 3 3 4 4 5 5 6
2 -2 -1 -1 0 1 1 2 2 3 3 4 4 5 5 6 6
3 -2 -1 -1 1 2 2 2 3 3 4 4 5 5 6 6 7
4 -1 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7
5 -1 1 2 2 3 3 3 4 4 5 5 6 6 7 7 8
6 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8
7 2 2 3 3 4 4 4 5 5 6 6 7 7 8 8 9
8 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9
9 3 3 4 4 5 5 5 6 6 7 7 8 8 9 9 10
10 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
>>
>>51873433
You could put the rest of the file starting from that point into a buffer and then overwrite the file after inserting the new character.
Don't forget to
fflush()
>>
>>51873439
ok faggot but integer operations get truncated toward zero unless otherwise specified
>>
>>51873428
>Just read the second reply in this >>51873070 (You) and tell me you weren't unnecessarily upset

Seriously, what is wrong with you?

Is there anything you don't wildly misinterpret? So, because I dismissed your dumb bikeshedding, you just decide I'm angry?
>>
>>51873448
Well, yes, you could do that, but that would most likely stop working when you feed it large files.
>>
>>51873454

How is that relevant? The provided code doesn't do anything like truncation, either.

And, yet again, the goal is to do a properly rounded result, NOT truncated.
>>
>>51873457
CS101
>>
Advent of code Day 15 solution.
For part 1, you can comment out the calories check near the bottom

from re import search

data=open("Advent15.txt").read().split("\n")

capacity,durability,flavor,texture,calories=[],[],[],[],[]

for i in data:
p=search(r"(-?\d+).*?(-?\d+).*?(-?\d+).*?(-?\d+).*?(-?\d+)",i)
capacity.append(int(p.group(1)))
durability.append(int(p.group(2)))
flavor.append(int(p.group(3)))
texture.append(int(p.group(4)))
calories.append(int(p.group(5)))

def calcScore(x,y,z,a):
cScore,dScore,fScore,tScore=0,0,0,0
for i in range(len(capacity)):
m=(x,y,z,a)[i]
cScore+=m*capacity[i]
dScore+=m*durability[i]
fScore+=m*flavor[i]
tScore+=m*texture[i]
if cScore<=0 or dScore<=0 or fScore<=0 or tScore<=0:
return 0
else:
return cScore*dScore*fScore*tScore

maxScore=0
for x in range(0,101):
for y in range(0,101):
if x+y>100:
break
for z in range(0,101):
a=100-(x+y+z)
if (a<0):
break
if x*calories[0]+y*calories[1]+z*calories[2]+a*calories[3]==500:
maxScore=max(maxScore, calcScore(x,y,z,a))
print maxScore


It's currently tailored to the problem, knowing that there are 4 ingredients. Next revision will not need arguments to my function or the whole nested for loop. Had to come up with something quick and dirty before I go
>>
>>51873457
You most definitely are making angry posts. I do not know if you are really angry or not, but if you're not actually angry maybe you should not be writing angry posts.
>>
>>51873462
then copy to a new file in chunks and then erase the old one and rename your new file to the old name.
>>
>>51873464

Oh, did I hurt babby's feelings, so he decided people are just mean ol' angry meanies?
>>
>bikeshedding
I don't like this meme
>>
>>51873439
int avg_round_up(int a, int b)
{
if(a == -b) {
return 0;
}
if((a < 0) == (b < 0)) {
return a / 2 + b / 2 + (a % 2 | b % 2);
}
if(a % 2 != b % 2) {
return (a + b) / 2 + ((a + b) > 0 ? 1 : -1);
}
return (a + b) / 2;
}
>>
>>51873457
>So, because I dismissed your dumb bikeshedding, you just decide I'm angry?
Well, yeah. He didn't even say anything inflammatory and you just went off on him.
Mind as well quit now anon, you're most definitely not changing anyone's mind at this point
>>
>>51873480
No I'm another guy from another thread checking back on your argument every now and then and trying to fuel the flames
>>
>>51873477
>You most definitely are making angry posts

Why are you whiny faggots so terribly upset by even vaguely coarse language? Seriously, take your dumb "my feelings" whining and drown it in a big bag of dicks.

By the way, this sentence pairing is probably the dumbest thing I've read all day:

>You most definitely are making angry posts. I do not know if you are really angry or not

What a dumbfuck.
>>
>>51873463
>And, yet again, the goal is to do a properly rounded result, NOT truncated.
YOU ARE THE ONLY ONE WHO HAS ASSUMED THIS FUCKING AUTIST

THE PROBLEM IS TO "AVERAGE TWO INTS IN C" AND THAT'S IT. AND THE "PROPER" ROUNDING IN TERMS OF INTS IS TRUNCATION. AND "PROPER" ROUNDING IN OTHER CONTEXTS DOESN'T ALWAYS MEAN ROUNDING AWAY FROM ZERO, IT CAN BE TRUNCATION OR ALTERNATING TOWARD/FROM ZERO OR ALTERNATING TOWARD/FROM POSITIVE INFINITY.
>>
>>51873377
that's not even in there and wouldn't prevent an overflow lmao
>>
>>51873496
A U T I S M
U
T
I
S
M
>>
>>51873496
It just looks so silly when someone is wrong and gets very angry about it, and tries to make "but it's culture" as excuse.
>>
>>51873496
>I'm gonna keep insulting everyone to try to cover up my dumb mistake and the fact I got called out on it
>I'm not actually mad though
You're not convincing anyone anon
>>
>>51873507
FUCKING RETARD FUCK OFF FUCKING DUNNING KRUGER PYTHON PISS KID

>if((a < 0) == (b < 0))
IT ONLY DOES A + B IF THE SIGNS ARE DIFFERENT, PREVENTING OVERFLOW
>>
>>51873520
dude
relax
lmao
>>
class Point2d

or
class Point2D

??
>>
File: unicorn.webm (3MB, 640x360px) Image search: [Google] [Yandex] [Bing]
unicorn.webm
3MB, 640x360px
Ask your beloved programming literate anything.
>>
>>51873422
int *asd = malloc(123);
if (error) {
free(asd);
return;
else if (otherthing) {
if (othererror) {
free(asd);
return;
}
}
free(asd);
return;

vs
int *asd = malloc(123);
if (error) goto error;
else if (otherthing {
if (othererror) goto error;
}
error: free(asd); return;

Obviously a minimal example that may be able to be formatted better in this specific case, but you get the idea.

And you may have other resources like files that also need to be free'd on exit. The more you have, the more clean the goto alternative becomes.
>>
>>51873528
smoke weed 420 blaze it lol reddit lmao
>>
>>51873520
that doesn't prevent overflow lmao
((((((int is bounded)))))))
>>
>>51873532
class Vec2
>>
>>51873487
>Well, yeah. He didn't even say anything inflammatory and you

Who? You mean this dipshit:

>>51872999
>what's wrong with a temp variable swap you fucking autist

or this one?

>>51873016
>Rewrite that with a temporary variable instead and profile both. You'll discover that the XOR trick is actually slower.

> just went off on him.

I "went off on him" for posting something retarded, fixating on the butthole-simple part of what I wrote.

>>51873509

I R O N Y
R
O
N
Y

>>51873515
>It just looks so silly when someone is wrong and gets very angry about it, and tries to make "but it's culture" as excuse.

I can see how something would seem silly to you when you've made 100% of it up.

"Culture"? No, I just think you're a bunch of pussies. Honestly, I do not understand why this board gets so upset whenever people swear.

>>51873516

K.
>>
File: dude weed lmao.gif (193KB, 400x400px) Image search: [Google] [Yandex] [Bing]
dude weed lmao.gif
193KB, 400x400px
>>51873538
now you're getting it
lmao
>>
>>51873533
That was pretty gay anon. I'd be ashamed to even have that saved.
>>
>>51873532
Up to you, you're the master of your API bb :^)

<<Please capitalize the D>>
>>
>>51873548
IF THE SIGNS ARE DIFFERENT IT'S NOT GOING TO OVERFLOW

-INT_MAX + 3000 OR WHATEVER IT'S NOT GOING TO OVERFLOW
>>
>>51873532
LE AUTISMO CAPITAN 420 LEET STALLMAN NIGGER
>>
>>51873566
if the signs are the same
it will
over
flow

keep tryin dude, you'll get it soon
>>
>>51873558
>"Culture"? No, I just think you're a bunch of pussies. Honestly, I do not understand why this board gets so upset whenever people swear.
Swearing has its place. In a discussion, when you are wrong, or where there is a good possibility you are, is not the time to swear.
Some people, like you, believe it is proper in this place to swear on every occasion. That's incorrect. All you're doing is shitting up the place.
>>
>>51873558
>I "went off on him" for posting something retarded, fixating on the butthole-simple part of what I wrote.
How is what he said retarded when he was right? You just all pissy because you couldn't deny he was right.
>>
>>51873583
FUCK OFF IF YOU'RE TROLLING JUST STOP IT'S JUST A WASTE OF YOUR TIME

>if((a < 0) == (b < 0))
CHECKS IF THE SIGNS ARE THE SAME AND IF THEY ARE THEN IT WILL NOT DO A + B
>>
Find the sign of a number, return 1 with the sign
here's my implementation
int sign_one(int x) {
return x / abs(x);
}
>>
>>51873558
>He's still replying
>>
>>51873609
>sign_one(0)
>>
>>51873598
guess I missed that, sorry dude
>>
>>51873609
sign_one(0)
>>
I gotta give props to the anon who first asked us to average two ints in C, he's singlehandedly managed to ruin us.
>>
>>51873593
>believe it is proper in this place to swear on every occasion. That's incorrect. All you're doing is shitting up the place.

Nah, fuck off.

>>51873595
>How is what he said retarded when he was right?

How are you not getting this? Because he/they offered retarded advice on, as I said, THE BUTTHOLE SIMPLE PART. The one and only reason I put the swap function there is because it's not standard.

There is absolutely no value whatsoever in criticizing that portion. It is bike shedding. Do you understand what bike shedding is?
>>
>>51873619
do I really know C if I can't find the sign of an integer
>>
File: 1438243263120.jpg (47KB, 345x383px) Image search: [Google] [Yandex] [Bing]
1438243263120.jpg
47KB, 345x383px
>>51873622
>>
>>51873635
you could do
return x < 0 ? -1 : 1;
>>
>>51873647
im using C
>>
>>51873657
That is valid C
>>
>>51873647
>sign_one(0)
>1
>>
>>51873633
>>Nah, fuck off.
And apart from shitting the place up, you'll also never get anyone to discuss anything with you seriously.
I guess, as long as you do realize the only thing you're achieving is bringing the quality of the board down, as long as that actually is your aim, you're achieving it.
>>
>>51873662
right sure, I'm just using normal C though
>>
>>51873678
That is normal C
>>
>>51873635
you can make up for it if you can find the average of two ints in C
>>
>>51873666
The problem statement says "return 1 with the sign". What is the sign of 0?
>>
>>51873683
you said it was valid C

>>51873687
which two ints?

>>51873691
0 has no sign
>>
I'm doing this for my java class. How would I go about this?

>>Write a program that uses an array of string objects to hold the 20 names, an array of characters to hold the letter grades, and an array to hold test scores. The test scores can be read from the enclosed excel table. The program can print the final grade with individual scores onto an excel table.
>>
>>51873633
>There is absolutely no value whatsoever in criticizing that portion.
>But it's clearly still important enough that I had to get butthurt over it
Yeah, no. I'm still convinced you're mad for getting called out. The fact that you're still replying proves this
>>
>>51873676
>you'll also never get anyone to discuss anything with you seriously.

Oh, yeah, because fucking commenting endlessly on the particular technique used for a swap function is sure a discussion I want to have.

>I guess, as long as you do realize the only thing you're achieving is bringing the quality of the board down

HOLY FUCKING IRONY, BATMAN.

Fuck off and die. You've contributed absolutely ZERO. This board's idea of discussion seems to revolve around discussing the defecating habits of Indians, saying the words "nigger" and "jew" whenever possible, and now commenting on which swap function is faster instead of focusing on the problem of creating a rounding integer averaging function.

Seriously, take your "advice", and shove it up your ass until you implode.
>>
File: 340xpe.jpg (46KB, 330x381px) Image search: [Google] [Yandex] [Bing]
340xpe.jpg
46KB, 330x381px
>>51873694
>That is normal C
>you said it was valid C
>>
>>51873698
>I'm still convinced you're mad for getting called out.

That's because you're big into projecting. Also, you're a retard who doesn't understand why bikeshedding is stupid, and should be called out for exactly what it is.

You are EXACTLY the same as the cunts out there bitching about "finger" and "touch" being sexually suggestive instead of actually contributing something to the world.
>>
>>51873694
it should be able to handle any two ints
don't forget about overflow and negative numbers
>>
>>51873699
Take a moment to notice that shitposting in this thread directly involves your posts. There's you, and there are people responding to you.
>>
>>51873161
One of the operands must be a register. Swapping two memory locations requires a register as temporary storage.
>>
>>51873707
Projecting would assume I'm angry. I was just pointing out what I was observing.
>>
>>51873694
the average of two ints should get truncated (rounded toward zero)

avg(0, 1) = 0
avg(1, 1) = 1
avg(2, 4) = 3
avg(-1, -2) = -1
avg(-1, -3) = -2
avg(-2, -4) = -3

and it should never overflow because that's undefined behavior in C
>>
>>51873720
>Take a moment to notice that shitposting in this thread directly involves your posts. There's you, and there are people responding to you.

Yeaaaaaaaaah.

>>51871065
>>51871073
>>51871264
>>51871307
>>51871319
>>51871331
>>51871741
>>51871829
>>51871872
>>51872305
>>51872324
>>51872430
>>51872616
>>51872631
>>51872676

And I was kind enough to leave out the drug-related shit because at least that initially tied in to performance and concentration. Also, the end of the last thread was just a bunch of retarded infighting over Python and the inherent stupidity of its users.

So yeah, how about you stop posting and start munching that bag of dicks now?
>>
>>51873598
Hello friend, newbie here. What are these signs you're talking about?

All I know about int overflow is the int upperbound is 2147something and that the underbound -2147something(+1). So when an int overflows it goes directly into the underbound. How is that condition stopping that exactly?
>>
>>51873727
>Projecting would assume I'm angry.

Ah, so we're just going to do the pedantic dick thing now, eh?

> I was just pointing out what I was observing.

Assuming != observing.

Dickbag. Eat it. Now.
>>
>>51873789
And now look at the amount of shit you spawned.
>>
>>51873789
There is literally nothing wrong with Python.
>>
File: cuck nigger c.png (63KB, 449x498px) Image search: [Google] [Yandex] [Bing]
cuck nigger c.png
63KB, 449x498px
hide python threads
ignore python posts
do not reply to python posters
>>
>>51873802
>And now look at the amount of shit you spawned.

You're right, every single response to everything I've posted has been complete shit.

So how about you stop responding, shitbreath?


>>51873803
>There is literally nothing wrong with Python.

Never said there was.
>>
>>51873810
isPrime=lambda x:len(i for i in range(2,int(x**0.5)+1) if x%i==0)==0

:^)
>>
>>51873813
>You're right, every single response to everything I've posted has been complete shit.
>So how about you stop responding, shitbreath?
You do you understand now that you're the one causing all that?
>>
>>51873800
Pedantic doesn't mean I'm wrong. Sorry anon, you're mad for making a dumb mistake
>>
>>51873799
in order for an int to overflow (exceed the upper bound) or underflow (exceed the lower bound) you need to add two positive numbers or add two negative numbers. for example 2147something + 2147something would overflow. but if you have one positive and one negative number, it won't overflow. 2147something - 2147something would just be 0.

the condition stops it because it checks if a is negative (a < 0) and if b is negative (b < 0), and then it checks if the results of those comparisons are equal, so the condition will only be true if both a and b are positive or if they are both negative.
>>
>>51873836
>You do you understand now that you're the one causing all that?

Says the shitposter.

Seriously, just stop. You retards had NOTHING of value to post. All that I got was idiotic bikeshedding and projection around the swap function, a ton of assumption from you and your kind, and now I get to field complaints about shitposting BY SHITPOSTERS.

Oh, and I got at least one completely incorrect averaging function posted, and at least one idiotic argument about truncation when it was clear from the get-go that I'm going for a rounding averaging function.

Face it, you're too fucking stupid to actually contribute to the discussion of a non-overflowing, rounding, purely integer averaging function. Since you can't talk about that, you instead decide to bitch about "muh feelings" like some shithead SJW over at Github.

>>51873840
>Pedantic doesn't mean I'm wrong. Sorry anon, you're mad for making a dumb mistake

You're right, I (may have) misused the word projection. But you have nothing but assumptions to go on, and they're wrong. That doesn't leave me much choice other than to assume projection. See how that works?

Just because you're not aware of your deep-seated anger doesn't mean it's not there, faggot.
>>
>>51873883
All I am doing is calling for civil discussion. I do not admit to being a shitposter.
>>
>>51873883
>taking the average two ints meme THIS seriously
Goddamn anon
>>
>>51873799
INT_MIN and INT_MAX are implementation-defined, overflow is undefined behaviour (the compiler is free to simply assume that it won't happen)
>>
>>51873883
>>
>>51873883
>This entire post
>I'm the angry one
>>
the memes need to go lads
>>
>>51873946
not until we have come up with the perfect way to average two ints in C
>>
>not adding "average" and "avg" into your filters
>>
>>51873956
Are we going to patent it if we do?
>>
>>51873946
agreed
the only good meme is the dressing like a schoolgirl meme
>>
>>51873902

Shitpost.

>>51873908

Shitpost by someone too dumb to even process the problem, so he's just going to now do the whole "y so serious, bro?" thing.

>>51873922

Shitpost, and I don't even know what you're trying to convey.

>>51873939

Aaaaand shitpost. "Dude responded to all responses, man, he's just so AAAAANGRY!!"

Come on, you useless faggots. Put up or shut up. Either come up with a more correct rounding integer averaging function, or take your retarded observations and shove them up your ass while enjoying your bowl of dicks.
>>
File: advent tree.jpg (115KB, 703x657px) Image search: [Google] [Yandex] [Bing]
advent tree.jpg
115KB, 703x657px
well?
>>
>we could be finding the cure to cancer or exploring the stars
>we're arguing about averaging 2 ints in c instead
ffs lads
>>
>>51873983
Naw, I'm fine. I don't have anything to prove on a Taiwanese knitting site
>>
>>51873983
>>Come on, you useless faggots. Put up or shut up. Either come up with a more correct rounding integer averaging function, or take your retarded observations and shove them up your ass while enjoying your bowl of dicks.
I am not in the slightest interested about rounding. My observations still apply.
You seem to think that there are only two possible states for a discussion - either it's an SJW hugbox, or it's a shithole with everyone swearing at each other for no reason. But you need to realize you're wrong. Civil discussion is norm everywhere, including this place, it's not something SJWs are related to. Even Linus knows where it's time to swear and when it's not. You don't.
>>
>>51873967
>>51873956
>>51874018
>>51874015

People who can't even understand the problem. Go back to your Javascript. I heard React is pretty cool.
>>
File: d2d.png (210KB, 600x390px) Image search: [Google] [Yandex] [Bing]
d2d.png
210KB, 600x390px
>See domain name that I want
>Check back later to buy it
>It's not available anymore
>>
File: 4aX1VW1.png (819KB, 1282x722px) Image search: [Google] [Yandex] [Bing]
4aX1VW1.png
819KB, 1282x722px
Can we just make a new thread now and leave the python autists in this thread?
>>
anyone worked with django?
>>
>>51874036
It depends, will you use the correct Yuki image this time senpai?
>>
>>51874022
>or it's a shithole with everyone swearing at each other for no reason.

Therein lies the problem: you think it was for no reason.

Now, go reread my many posts until you can wrap your head around them.

>But you need to realize you're wrong.

Right back at ya, chief.

>Civil discussion is norm everywhere, including this place

Fuck off, that's not even REMOTELY true.

Anyway, get over your hurt feelings, bitch. Swearing isn't a fucking problem. I don't care if it upsets you, you're a whiny cunt with nothing of value to say.
>>
>>51874045
Fine, but you have to post it, i have no yuki pictures on this computer.
>>
Didn't think averaging 2 ints in c was such a serious topic
>>
>>51874038
Yeah it's fantastic >>51874038
>>
File: 1385792865025.png (304KB, 722x768px) Image search: [Google] [Yandex] [Bing]
1385792865025.png
304KB, 722x768px
>>51874057
I don't feel comfy posting a thread so early.

Lets just wait a little.
>>
>>51874048
I read it. You responded with rudeness to polite comment giving you advice. It's clear as day.
>>
>>51874048
>Therein lies the problem: you think it was for no reason.
>I HAD to get upset at him
Yeah, not really.
>>
>>51874074
>You responded with rudeness to polite comment giving you advice.

Dickhead, can I be any clearer?

>>51873699
>Seriously, take your "advice", and shove it up your ass until you implode.

You are an idiot. You are bikeshedding and talking about feelings because you're too incompetent to take a stab at the problem.

You have NOTHING to offer. You are the quintessential shitposter. You are the SJW that haunts the codebase.
>>
>>51874084
> >I HAD to get upset at him

Part two of the misunderstanding.

Really, it would be AWESOME if you retards would drop this whole shitposting crusade you're on.

Yet again, put up or shut up.
>>
>>51874015
>implying there is a singular "the" cure to cancer
>implying exploring the stars is remotely feasible in our lifetime
leave burning money on failed "space exploration" to those smug elon musk and richard branson chode tards
>>
>>51874087
>Contributing to a literal meme that has been shitting up /dpt/ for the past week is somehow offering something.
>>
File: 1419680040383.png (141KB, 586x329px) Image search: [Google] [Yandex] [Bing]
1419680040383.png
141KB, 586x329px
I haven't really been here since the fun image wars and I'm considering making this my new home. I've been looking for a new home since brit/pol/ died.

Is /dpt/ still comfy and do the mods still keep their noses out of the threads?

You see, I like to use generals as glorified chatrooms.

For example, if I asked, "what anime are you currently watching, /dpt/?"

Would a no-fun allowed mod come in and ruin the banter?
>>
>>51874087
Just a post ago you claimed there was a valid reason for your swearing, now you're abandoning that and going back to your swearing for no reason. Well done.

It should be pretty clear to you that I am not interested in rounding.
>>
>>51874121
It's hard to tell, we're all always on-topic. The people talking about crossdressing while coding don't get banned though
>>
>>51874110

Yeah, I never saw it before, and found it to be a surprisingly difficult problem.

If you can't offer a solution, fine. Just don't comment.

>>51874128
>Just a post ago you claimed there was a valid reason for your swearing, now you're abandoning that and going back to your swearing for no reason. Well done.

That... doesn't even make any sense. I have no idea what your retarded brain misread to come to that conclusion, but whatever, retards be retards.

>It should be pretty clear to you that I am not interested in rounding.

And yet you KEEP. FUCKING. SHITPOSTING.
>>
>>51874121
the only thing mods care about is image warring, and that's only if they're awake

sometimes in the mornings (PST), you'll get a janitor who goes full NO FUN ALLOWED mode, but that's it
>>
>>51874133
Alright, I'll give /dpt/ a go.

>>51874142
Kek, the image wars are still a thing?
>>
>>51874149
yeah sometimes I'll post a himegoto pic and some asspained faggot has to make a "non-degenerate" /dpt/ and their thread usually gets deleted
>>
>>51874121
Same here. I don't give a shit about programming since forever.
>>
>>51874140
Let me clear this up for you:

Your post:
>Therein lies the problem: you think it was for no reason.
>Now, go reread my many posts until you can wrap your head around them.

My response:
>I read it. You responded with rudeness to polite comment giving you advice. It's clear as day.
Here's a comment with polite suggestion: >>51873016
Here's your angry response: >>51873070

Your response:
>Dickhead, can I be any clearer?
>Seriously, take your "advice", and shove it up your ass until you implode.
>You are an idiot. You are bikeshedding and talking about feelings because you're too incompetent to take a stab at the problem.
>You have NOTHING to offer. You are the quintessential shitposter. You are the SJW that haunts the codebase.

In your response, there is nothing related to my comment pointing out how your rude response was there for no reason. That's a basis for my reply:
>Just a post ago you claimed there was a valid reason for your swearing, now you're abandoning that and going back to your swearing for no reason. Well done.

Hope that clears it up! Good luck.
>>
File: weq.png (417KB, 800x533px) Image search: [Google] [Yandex] [Bing]
weq.png
417KB, 800x533px
>>51874164
I bet the image wars aren't as fun as they used to be.
>>
>>51871469

Theme song for your meme star
>>
I'm new to Python, what does this mean?

return (x>0)-(x<0)
>>
>>51874228
True is 1, False is 0
>>
>>51874228
returns 1 if positive, 0 if 0 and -1 if negative

you could do:

abs=lambda x:x*((x>0)-(x<0))
>>
>>51874228
python is very gay and that's why you are unable to figure out what it means
>>
>>51874186
>Here's a comment with polite suggestion:

A dumb, uninteresting suggestion about the most simplistic part of the code, you mean.

>>51874186
>Here's your angry response:

Not angry, just expressing how stupid your "polite suggestion" was.

>In your response, there is nothing related to my comment pointing out how your rude response was there for no reason.

I honestly have no idea what you're even trying to say now. What, you think that I need to give you some objective argument as to why a XOR swap is superior or something? Do you think that's what I've been saying this whole time?

If so, please do kill yourself.

Again, in closing,

>You have NOTHING to offer. You are the quintessential shitposter. You are the SJW that haunts the codebase.

I don't care about "muh feelings". If you can't give an improvement to the averaging routine, just shut up. Your dumb swapping suggestion was BIKESHEDDING. Now, your endless moaning about your feelings and assumptions is BIKESHEDDING (actually, it's just wildly off-topic blather, but let's just call it bikeshedding since it accomplishes the same goal: allows you to avoid actual technical discussion).
>>
>>51874244
nah

>>51874242
you again lmao
it also isn't abs, it's sign
>>
>>> def double(list):
... return [elem * 2 for elem in list]
...
>>> double([1, 2, 3, 4])
[2, 4, 6, 8]

ghci> let double list = [elem * 2 | elem <- list]
ghci> double [1, 2, 3, 4]
[2,4,6,8]


pick one
>>
>>51874250
they're multiplying the sign by x. If x was positive, you multiplied it by 1, so it is still positive. Otherwise you multiply it by -1 and it's positive again. If it's 0 it's just 0
>>
>>51874250
>it also isn't abs
clearly, look at my function again, it has more than what he posted

if you multiply a number by its sign, you get the absolute version of that number
>>
>>51874250
if python didn't hide types from the user as much as possible he would have been able to figure it out himself. python is a bunch of hocus pocus
>>
>>51874267
>>51874261
missed the x*, woops, just assumed since anon said "you could do" that he was doing the same thing :\
>>
>>51874228
>what does this mean?
That you need to execute the "clever" person who wrote this
>>
>>51874275
It's cool lad, I sometimes misread code here and get 5-10 replies about it
>>
File: yuki.jpg (113KB, 984x927px) Image search: [Google] [Yandex] [Bing]
yuki.jpg
113KB, 984x927px
why doesn't /dpt/ like python any more?
>>
>>51874249
There is no feelings involved. Call for civil discussion always has place and is not related to feelings. None of what I am saying is related in any way to integer rounding, swapping, or anything else programming.

What happened is clear as day: a person gave you a valid programming-related suggestion in polite language and you called him dipshit for it.

What I want should also be pretty clear, but if it's not: it's for you to not swear for no reason in future.
>>
>>51874300
It's literally one loud mouthed autist. The same one that plagues these threads with anime garbage.
>>
>>51874300
python is a crutch and you will never learn to how to implement the libraries you heavily rely on if you learn it as a first language.
>>
>>51874300
fuck this brings back memories
yes I'm new

/dpt/ hates python because it's now the babby language
I'm learning it now and I like it, although I wish I could just use haskell instead
and haskell had as many libs
but I love python so far. (a few hours into it)
>>
>>51874300
A couple of loud idiots spamming shitposts here, nothing more.
>>
>>51874324
>now
>>
>>51874345
babby as in every babby knows/is learning it, not that it's for babbies, which it's always been you could say
>>
>>51874300
python is disgusting as hell i don't know what you fegs see in it outside of perhaps some tiny little scripts. it's useless for developing serious applications.
>>
>>51874356
>perhaps some tiny little scripts
and this is only because of the availability of (mediocre) libraries. there is nothing in the language itself that entices me.
>>
>>51874356
I'd agree with this if there weren't so many huge libraries for it tbqf
>>
>>51873985
pretty cute tbqh
>>
>>51874356
>serious applications.

Sounds like you're mad it won't let you make some 550k line spaghetti code shit.
>>
>>51874367
I just use C libraries from Rust and hope they don't segfault
>>
>>51874390
>muh 100 LOC "gayms"
>muh 10 LOC "apps"
>>
File: 64D81Wf.jpg (86KB, 500x628px) Image search: [Google] [Yandex] [Bing]
64D81Wf.jpg
86KB, 500x628px
>>51874356
>>
>>51874390
>import 10 million libraries
>write "app" in 2 lines of code, using libraries comprised entirely of other people's code
>no logic or planning to be found, just mindless calls to library functions
fuck off
>>
>>51874435
>i have never used python
what a fucking surprise
>>
NEW THREAD

>>51874414
>>
>>51874454
no more useful discussion can be had in this thread
>>
>>51874446

>>51874207
3/300 get good
>>
>>51874480
kill yourself
>>
What is it called when you have a set of connected nodes rendered with elastic connections?
>>
>>51874692
doubly linked list?
>>
>>51874724
But actually rendered to the display. Also a doubly n-linked list.
>>
>>51871175
damn, that's some tight programming
>>
File: 1446629180636.jpg (72KB, 526x424px) Image search: [Google] [Yandex] [Bing]
1446629180636.jpg
72KB, 526x424px
>messed up some super simple math calculations because i started counting at 0 instead of 1
this shit has damaged me
>>
>>51871708
Python also has similar issues. In the case of haskell, it's genuinely unfortunate because otherwise it would be a really nice language to work in. Ocaml isn't a sufficient substitute because no parallelism and slow development. The strategy in ocaml is to only produce high-quality libraries, but this also means that few libraries are available by comparison.
>>
>>51874950
T-thanks, h-hehe!
>>
>>51870998
>>51870998

Newfag here confirming that after learning C for a week, I have successfully averaged two integers.

I bought a calculator.

>no but serious question:

Can anyone explain in simple terms what overloading actually is and why it's so important for a language to support it?
>>
>>51870998
Why the fuck is there two of these faggot anime programming threads. Sure daily may mean useless threads everyday but comeon. Let the fucking other die.
>>
>>51871339
Arguing about which programming language is best is on par with arguing about katanas.
>>
Learning some C and mysql connections. How do I include
`mysql_config --cflags --libs`

in cmake file?

I can add that to the parameters of GCC and it compiles without errors. I need to point cmake to mysql header.
Thread replies: 312
Thread images: 28
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y / ] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
If a post contains illegal content, please click on its [Report] button and follow the instructions.
This is a 4chan archive - all of the content originated from them. If you need information for a Poster - you need to contact them.
This website shows only archived content and is not affiliated with 4chan in any way.
If you like this website please support us by donating with Bitcoin at 1XVgDnu36zCj97gLdeSwHMdiJaBkqhtMK