[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: 318
Thread images: 23

What are you working on, /g/?

Old thread: >>58856389
>>
First for Haskell
>>
File: tomoko lite uses thinkpaddu2.png (775KB, 1026x1038px) Image search: [Google]
tomoko lite uses thinkpaddu2.png
775KB, 1026x1038px
>fixed bug that's been throwing me off for weeks
>didn't even think twice about the solution
>the bug fix was adding a three star array of pointers to pointers to char arrays

I'm a 3 star programmer now!
>>
First for race conditions.
>>
Should I learn Python, Ruby or Javascript? CS major here I know C and Java and some perl.
>>
>>58860585
Neither, learn a functional language
>>
>>58860585
Ruby.
>>
>>58860585
I'd learn JS or Python. Ruby is only good for one thing (RubyOnRails) It's quite literally a one trick pony.
>>
>>58860563
So what are the instructions?
>>
>>58860613
Could hardly be any simpler:
mov al, 42
ret
>>
>>58860623
Disassembly of section .rodata:

0000000000400748 <main-0x4>:
400748: 00 00 add %al,(%rax)
...

000000000040074c <main>:
40074c: b0 2a mov $0x2a,%al
40074e: c3 retq
>>
>>58860585
>python
lotta people using this today, but it's only real purpose is to learn programming, quickly prototype things, or write small scripts / apps (e.g. bots)
imo doing anything meaningful in the real world there are better languages out there
>ruby
I use this at work a bit as it is central to one of our tools, but I wouldn't use it outside of that. Like pythong, it can be picked up quickly if you have a decent CS education
>Javascript
shit. I say this having written some things in javascript / nodejs. I dislike it, I dislike the community eclectic-ness of standards. Work is repeated everywhere and you spend more time trying to figure out what library / package / tool / paradigm to use to solve your problem than you do actually writing the code to solve it.

you know C, Go would be easy to pick up
you know java, something like Scala / Clojure would be easy to pickup
Erlang mite b cool
>>
>>58860745
This guy is right, Scala and Clojure are good ideas, just don't get too wedded to either of them.
>>
File: sensible arm.png (87KB, 1226x846px) Image search: [Google]
sensible arm.png
87KB, 1226x846px
>>58860551
I'm incredibly bored, and just generally feel like shit right now. Kind of feel like installing debian on my jetson TX1.
>>
I'm trying out pygame for the first time and I'm having some issues. I'm trying to create a list of projectile objects

# Create projectiles , position will be reset later
u_projectile = [Projectile(0, 0) for _ in range(500)]


and then later, in my while loop, accessing those projectiles and setting their position when the space key is hit

# Use arrow keys to move player left & right, space to launch projectiles
key = pygame.key.get_pressed()
if 0 <= user.rect.x <= 800:
if key[pygame.K_LEFT]:
user.move(-1)
if key[pygame.K_RIGHT]:
user.move(1)
if key[pygame.K_SPACE]:
flag = True
if flag is True and pygame.time.get_ticks() - time >= 1000:
u_projectile[j].set_pos(user.rect.x, user.rect.y)
j += 1
time = pygame.time.get_ticks()
flag = False


But for some reason, the
u_projectile[j].set_pos(user.rect.x, user.rect.y)

doesn't work, but I've printed out j as well, and it increments as it should, so I know it's entering the conditional.

Here's set_pos()
def set_pos(self, x, y):
self.rect.move(x, y)


Any help would be appreciated, thanks
>>
>>58860594
So Javascript then?
>>
>>58860695
retq? what the fuck? is at&t syntax so retarded that it defines return for different bit widths?
>>
>>58860849
No anon.
>>
>>58859398
see>>58860878
>>
So I made a .bat build script for interfacing with cmake on windows. It's really simple and serves just to simplify the process even more. For some reason though, whenever cmake is called from the script, cmake will dump its shit in the root of the project folder, not the designated build directory.

here's the revelant snippet from the script
:build__build_debug_x86
rem build__build_out_dir = build
mkdir %build__build_out_dir%
cd %build__build_out_dir%
cmake -G %build__cmake_gen_name% ..\CMakeLists.txt
cmake --build .. --config Debug
cd ..
goto:eof


pastebin: http://pastebin.com/60YiEjxi

I find this weird because if I manually execute the same commands in the shell it just werks and everything is dumped in the build directory
>>
>>58860745
just out of curiosity - what languages do you enjoy working with?
>>
This a good book?
>>
>>58860867
Yes.
>>
>>58860973
I read the first edition of that book, the examples predate ANSI C, so you see lots of K&R-esque obtuse programming techniques and it's really distracting.

The writeups are good tho.
>>
>>58860933
I guess I should've stated that I'd like some insight on this as it's either my retardation or windows sucks more dick than I previously thought
>>
>>58860933
The first line under the label is commented out, but you refer to it in the next three commands.
>>
>>58861063
Fuuuug, I'm retarded, but not in the way you think: I set
build__build_out_dir
at the beginning of the script; thus it's value is indeed set. I made that comment to inform you all what
build__build_out_dir
equals.
>>
>>58860551
a
>>
File: 37837100z.jpg (31KB, 356x475px) Image search: [Google]
37837100z.jpg
31KB, 356x475px
>>58861004
Third edition came out in 1998, so I imagine that's not too much of an issue
Think I might try pic related first anyway, since it looks a lot less dense
>>
I'm working in scheme and was wondering if I had a pair, could I map all the left hand values to the corresponding right hand value?

Like for example if I had:
((a . 8) (b . 6))

could I turn this into:
a = 8
b = 6

I tried with define and let but it doesn't like me using car and cdr
>>
>>58860695
const char main[] = "\x55\x48\x89\xe5\xb8\x0b\x00\x00\x00\xc7\x45\xfc\x00\x00\x00\x00\x5d\xc3";
>>
guys I feel like I'm slowly getting the hang out of the pythonic way

import math
def peaceful_yard(yard, min_distance):
print (yard, min_distance)
ind = [(a, b) for a, i in enumerate(yard) for b, x in enumerate(i) if x in 'LRM']
return all(p >= min_distance for p in
[math.sqrt(pow(ind[0][0] - ind[0 + i][0], 2) + pow(ind[0][1] - ind[0 + i][1], 2)) for i in
range(1, len(ind))])
>>
>>58861138
My eyes
>>
File: a1.png (30KB, 860x611px) Image search: [Google]
a1.png
30KB, 860x611px
>>58860551
I started learning java three days ago.
My tutor gave me a homwork and I'm trying to finish the mini rectangle calculator..
>>
>>58861146
please, please tell you're just shitposting
>>
>>58860551
36th for Go
>>
>>58861156
It works perfectly fine.
I'm totally new to programming so tell me if I did something terribly wrong..
>>
>>58861161
At least you know your place.
>>
>>58861143

thats the point
>>
I spent my first week programming doing stupid shit like calling main() from within main because the teacher though he was doing us a service by not teaching us loops of any kind.

Then I was confused as to why my menu program wouldn't quit every time I selected quit.

Needless to say, i quit that shit after one semester and self-studied from that point forward.
Don't go to college for computers.
>>
>>58861125
Dunno about Scheme, but you can do it in CL with mapcar:
(mapcar (lambda (x)
(cons (cdr x) (cdr x)))
'((a . 8) (b . 6)))
>>
>>58861125
You'll need a macro.
>>
>>58860551
alright /g/, what's should be my next app? I already programmed a calculator and a space shooter gaymen for Android.
>>
>>58861221
suicide methods for android users
>>
>>58861171
just to clarify before making more remarks, are you calculating multiple areas? because I'm confused why you're to multiple widths and lengths
>>
>>58861221
cheese pizza detector
>>
>>58861107
Have you double-checked all your paths, making sure for example that the working directory at that point in the script is what you expect it to be? Because if the wrong value is stored in either build__build_out_dir or in the working directory environment variable, that could have happened somewhere earlier in the script.
>>
>>58861237
No, it's just a simple homework, assuming the user can get the value of the area of one rectangle.

I'm totally a beginner so my tutor wouldn't expect me to write more complicated codes in this first week.
>>
>>58861189
doesn't that just make another pair out of them? I want to create a variable "a" in this case and set it to the number 8

>>58861203
I'm not sure how I'd go about this, psuedocode?
>>
What is the best language to create a Stock Control and Sale program?
>>
>>58861125
>>58861189
The indentation is getting screwed up, so I'm just going to give you a one-liner. Here it is in Scheme:
(map (lambda (x) (cons (cdr x) (cdr x))) '((a . 6) (b . 8)))


There's probably a better solution though.
>>
>>58861237
It looks like it only gets one width and length. Most of the code there is an extremely verbose way of getting just the width from the user.

But to noobanon >>58861146
If you really need this ridiculously verbose code for reading doubles from the command line, you should at least put it in a function so that you can reuse it when you get the length.
>>
>>58861275
Oh, disregard >>58861279 then. I guess you could use let or something.
>>
>>58861286
So, how can I do it? I only started learning code three days ago so I only know few things..Of course I would be expected to make more practical codes later on, but I want to get better.
>>
>>58861251
Here's the full script, if you care to look: http://pastebin.com/Wzhpb5M9. I've comed through it many times, and I'm still at a loss.
>>
>>58860551
https://tour.golang.org
>>
>>58861420
Why would I want to learn Go if I know Lisp?
>>
>>58861286
you're right he's retreiving input in a weird manner

>>58861347
what do you know anon?
>>
>>58861412
>I've comed through it many times

Sounds like you need a girlfriend.
>>
>>58861429
dunno. does it hurt to learn yet another lang, specially one that is quite easy to learn and has some nice features?
>>
>>58861323
diff xs ys = foo xs ys ++ foo ys xs
where foo = foldr (\y -> filter (/=y))

and yes, since you care about unique and not how many it has
>>
>>58861445
Not really. I'm not trying to be a dick about it, it was an honest question.
>>
>>58861347
https://www.tutorialspoint.com/java/java_methods.htm
basically, you write what the function returns, is called, and takes, then you basically copy all the code you have to read the input into the function's body and replace where it currently is with calls to it. think about how you can make the function general-purpose, what would need to change before you could use this function to get any kind of data, and what it would need to take to accomplish that
(I didn't really read through the linked tutorial carefully so it might have some issues, but it's a pretty self-evident concept)
>>
>>58861431
not a lot..just basic stuff like if statement and while loop and continue/break , switch, and scanner object. What did you mean by " put it in a function so that you can reuse" ? How can I do it?
>>
>>58861445
>some nice features
Go has no nice features. Reevaluate your programming choices.
>>
>>58861466
see >>58861461
>>
>>58861472
>If you import a library or declare a variable, but do not use it, your program will not compile even if everything else is valid.
>Composing functions that return multiple types is a mess.
>Go's error type is simply an interface to a function returning a string.
>Go lacks pattern matching & abstract data types.
>Go lacks immutable variables.
>Go lacks generics.
>Go supports the nil pointer. This is similar to C's void *, an enormous source of bugs.
>>
>>58861475
Oh, thank you
>>
>>58861466
What I meant was, you currently just copy your width code almost verbatim to get the length - at least, I assume so.
What would be better would be to do something like:

private static double GetUserDouble(String label) {
double userInput;
System.out.print(label);
//Do your loop, hasNextDouble, etc. to actually place the value in the userInput variable
return userInput;
}

Then your main function can be much simpler, and do something like:
dblWidth=GetUserDouble("Enter the width(cm) : ");
dblLength=GetUserDouble("Enter the length(cm) : ");


I haven't written in Java for years, so you might need to tweak the syntax a bit, but that should give you the idea.

And this way, if you need to change the way the user input works, you don't have to change it in multiple almost identical copies. It's just in one place. Better for readability, maintainability, and extensibility.
If you find yourself copying and pasting a bunch of boilerplate code, it's often a very good sign that you should be moving that code to a function.
>>
>>58861475
Thank you, anon!
My tutor told me to never use other methods or functions that I didn't learn from the lessons with him. He said using few tools to solve a problem would help me to think more computationally. But I think knowing a lot of methods is also important to save time.
>>
>>58861605
your tutor is a retard
>>
>>58860601

>Ruby is only good for one thing
Sinatra
Metasploit
Anything involving creating DSLs...

Rails a shit, but Ruby is nice.
>>
>>58861472
>easy af concurrency + channels
>improved C + features taken from other langs
>gofmt
>no OOP
>[...]

>no nice features
t. elite of /dpt/
>>
>>58861654
Haskell does all of those things better except gofmt, which is pointless.
>>
why should i learn lisp?
>>
>>58861665
There's one thing they're both good at, and that's not being used by anybody!
>>
File: 1373397491536.png (266KB, 640x400px) Image search: [Google]
1373397491536.png
266KB, 640x400px
>>58861665
>Haskell does all of those things better
>>
>>58861653
no bias at all ofc
>>
>>58861674
To make yourself a better programmer.
>>
>>58861665
name 1 popular haskell program
>inb4 popularity != good
also
>compiler requires downloading 1 GB of files
top kek

just keep believing you are an elite programmer m8
in reality, no one gives a shit about you, programming elites, or haskell
>>
>>58861693
Ruby is just her name, she doesn't actually use the language.

>>58861700
>bitter tears of a programlet
>>
>>58861674
Very simple language. Lisp macros can't be beat. Prefix notation.
>>
>>58861705
>>bitter tears of a programlet
>implying I'm a highly specialized technician that prides himself of not even having a social life, aka, a code monkey
I prefer to do useful shit for your clients, laugh at you programmers and make easy money
>>
>>58861734
This, it's amazing how freeing such a simple feature is.
>>
>>58861694
Functional?
>>
>>58861747
>lying on the internet
>>
>>58861589
Okay, that looks good. Thank you so much!
>>
File: e7qu716kbnaod9.jpg (2KB, 157x118px) Image search: [Google]
e7qu716kbnaod9.jpg
2KB, 157x118px
>>58860585
Learn Elixir/Erlang. It just works.
>>
>>58861705
woah I though ruby was a guy (male)?
>>
>>58861764
Yes, as opposed to dysfunctional.
>>
>>58861764
Yes. They all support functional programming.
>>
>>58860551
How do I git gud at lock-free programming /g/?
>>
>>58861790
Read memory-barriers.txt

Then read it again until you understand all the subtleties in it.
See you in a couple years!
>>
>>58861767
>what is infosec
>>
>>58861781
No, she just pretends to be sometimes.
>>
>>58861811
Something you don't work in.
>>
>>58860964
I've written at least a little bit of everything I mentioned sans erlang and clojure

right now I like golang a lot and in the past I was pretty enamored with scala
I still work with ruby, python (work), nodejs javascript (personal web stuff)

mostly I when I want to do a project, work or personal, I try to figure out what language will be best to accomplish the task and then learn / use that
>>
>>58861826
where are da proofs?
>>
>>58860551
Any good books on learning C and assembly? I'm studying to hopefully become a pen-tester one day. Thinking maybe a focus in RE and binary exploitation and that kinda thing. Obviously being able to read and interpet assembly is important for disassembling binaries but C also seems to pop up a lot.
>>
why is it that every time i have a manic i feel this very strong urge to program in common lisp
>>
https://youtu.be/te-H1v-7Rto Trying to do a console application and do a switch statement on console.readykey. Video explain can anyone help? C# issue
>>
>>58861412
Update: I've gotton the script to work right, but it still doesn't make sense to me. Here's what I did:
cd path\to\project_root
mkdir build && cd build
..\build debug-x86
cd ..


Thus by calling the script from the build folder, the project and build files are dumped into it. I've concluded that this must be cmake's retardation, and I'll just have to call my script from the build directory. Such is life.
>>
give me things to program in common lisp
>>
>>58861928
>>58861960
Program a med dispenser so you can stop sperging out
>>
>>58861902
try Modern C by Jens Gustedt
>>
>>58860800
Hello friendo.

Try type(u_projectile)

It might not be a list, but rather an iterable object.

t. Autist
>>
>>58861985
Thanks /g/ent. I'll check it out.
>>
>>58860578
Congratulations! But it probably means you need to restructure your code.
>>
>>58861983
im not sperging out, i am more productive in 1 manic episode than in a whole month, give me something to do, i need to do something with this energy and i can do anything
>>
>>58861960
Do something with clml.
>>
>>58861902
>assembly
https://pacman128.github.io/pcasm/
>>
>>58860585
Racket
>>
>>58862021
I have a hardware project for you. You need an helium tank, a CPAP mask and a hose.
>>
>>58861902
The Shellcoder's Handbook is pretty good from what I remember, but you already need to know the basics.
>>
>>58862021
Write pong.
Oh wait, LISP programmers can't into real-time graphics
>>
File: g.png (186KB, 816x639px) Image search: [Google]
g.png
186KB, 816x639px
updated my previous one
>>
>>58862101
>analy
You fag
>>
i cant focus hard enough to reply to your posts, but thanks for all the ideas

ps fuck you jealous cunt, you will never know this feeling, i am 10x better than you right now, stay mad stay jealous, im off to read 2 books at once while your mind rots
>>
File: IMG_1001.png (464KB, 1334x750px) Image search: [Google]
IMG_1001.png
464KB, 1334x750px
Trying to make it so it leave the switch when I enter a b or c but some reason couldn't get it to work.
>>
>>58862136
You want && instead of ||
Also spell your shit correctly
>>
File: 1437338499539.jpg (174KB, 1083x720px) Image search: [Google]
1437338499539.jpg
174KB, 1083x720px
>>58862127
>>
>>58862171
>he hasn't heard of chat races
>>
>>58862136
>while (T != "A" || T != "B" || T!= "C")
Yeah, nice try buddy.
The operator you're looking for is &&, not ||.
>>
>>58862101
>using proprietary software to defend "GNU + Linux" terminology
HERESY
>>
>>58861125
Sounds like it's macro time.
>>
>>58862088
It's pretty obvious you have no idea what you're talking about.
>>
Yeah I was trying to mock it quickly. Oh sweet thanks guys.
>>
>>58862215
Shazbot.
>>
>>58861985
http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf

And for assembly x86_64?
>>
>>58860551
Sup guys, math grad guy here.

So there's this public website that posts 1 minute daily data online. Can anyone point me one the right direction to write scripts to just essentially copy the tables daily?

I know C, R, and SAS but i have no fucking clue where to begin.
>>
>>58862296
Learning some Python would probably be your best bet. I've written multithreaded scrapping scripts in a couple of hours as a Python beginner.
>>
>>58861902
>>58862263
Guide to Assembly Language Programming in Linux by Sivarama P. Dandamudi
>>
>>58862308
>>58862296
Here's what I'm talking about.

http://www.lrwu.com/rain/DaySelect.aspx

So Python isn't that hard since I've helped my gf with her hw in college. My only question is how do run this script? Like wtf do I use?

All I've used programming before is in MATLAB and R/SAS, but never something like this.


Can you give me some tips as to where to begin? Sorry about my ignorance.
>>
>>58862353
http://data.ceh.vn/Ebook/ebooks.shahed.biz/OS/LINUX/Springer-Verlag%20-%20Guide%20to%20Assembly%20Language%20Programming%20in%20Linux.pdf
>>
>>58861705

1. I'm a guy, not a girl.
2. I do use Ruby as one of my primary programming languages.
>>
>>58862353
IA_32?
>>
>>58862412
You're so fucking autistic
>>
I think .net C# is awesome but I'm going to learn C++ next just for fun.
>>
>>58862412
You're not fooling anyone ruby, everyone's seen your trap pics on 8ch where you wear ruby colored socks :3
>>
>>58862414
aw shit, yeah, my bad
>>
File: 1461286873004.png (275KB, 448x416px) Image search: [Google]
1461286873004.png
275KB, 448x416px
>>58862449
I'm just glad you're having fun anon
>>
>>58862296
>>58862449
→ >>58861420
>https://tour.golang.org
>>
>>58862412
>1. I'm a guy, not a girl.
Proof?
>>
>>58860578
name a single reason to use a 3 star pointer.
>>
>>58862663
2-dimensional array of strings
>>
How do you /g/uys feel about golang? It's set to explode in 2017 if Google goes all in on it like it seems they're going to.
>>
File: titsgtfoorban.jpg (92KB, 782x387px) Image search: [Google]
titsgtfoorban.jpg
92KB, 782x387px
>>58862452

Do you have any evidence of these claims?

>>58862619

All posters on 4chan are male until proven otherwise. If a poster claims to be female, they should provide tits, or otherwise gtfo. I have been on this site for ten fucking years, and this has consistently been the rule.

How about YOU prove me female.
>>
>>58862691
I think the real question is golang vs Scala vs Elixer

Swift as well if you're into the Apple bubble.
>>
>>58862695
>I have been on this site for ten fucking years
I've been here for eleven. My, how the time flies.
>>
>>58862663
void alloc_2D_int_arr(int ***ruby_is_a_male_female, int hlen, vlen)
{
size_t sz = hlen * vlen * sizeof(int);
*ruby_is_a_male_female = malloc(sz);
}

int main(int argc, char *argv[])
{
int **dfc_a_best = NULL;

alloc_2D_int_arr(dfc_a_best, argv[1], argv[2]);
free(dfc_a_best);

return 0;
}
>>
>>58862663

I had an array of char arrays, but since I had to realloc their contents a few times, I'd lose the memory block to the ether, so I had to obtain the specific address of the pointer that points to that block of memory, which results in an array of pointer to array of type char which is something like char **arr[] = { &a->ptr1, ...
>>
>>58862794
shit, let's assume that I magically used atoi() on
argv[1]
and
argv[2]
>>
>>58862705
I want to say that golang and scala aren't really comparable, but then I think about it and they do both set out to solve the same kind of problem domain (distributed, high-performance applications) with very similar mindsets so I guess in that sense they share many similarities
>>
>>58862794
>>58862810
haha yipperz look at me guys i understand pointers and malloc
>>
>>58862879
girl *ruby = (girl *) malloc(sizeof(boy));
>>
I've done the emacs tutorial, what should I do next in order to git gud with it?
>>
>>58862901
>casting malloc
>>
#include "Girl.h"
#include "Boy.h"

Girl<Boy> *ruby = new Girl<Boy>("Ruby");
>>
>>58862911
>what is sepples
>>
>>58862810

Or that you didn't implicitly cast int** to int*** by forgetting to past dfc_a_best by reference

Or that you didn't actually create a fucking one dimensional array by calling malloc only once

Try again:
void alloc_2d_int_ary(int ***ary, size_t hlen, size_t vlen)
{
*ary = malloc(hlen * sizeof(int*));
for (size_t i = 0; i < hlen; i++) {
ary[0][i] = malloc(vlen * sizeof(int));
}
}
>>
>>58862940
why are you salty? gender confused?
>>
What is a good first programming language that is actually usable and beneficial to learn? I spend so much time trying to find the best language to learn rather than actual yearning and I need some one to tel Mme what dot do.
>>
>>58863132
C
>>
>>58863132
Haskell
Scheme
C
>>
>>58863132
>Holy fuck my phone typing is terrible...
What is a good first programming language that is actually usable and beneficial to learn? I spend so much time trying to find the best language to learn rather than actual learning and I need some one to tell me what to do.
>>
>>58863165
Just shut up and learn C.
All other languages become much more simple to understand once you know C.
>>
>>58863150
>>58863146
I can get down with C.
>>
>>58863180
see >>58862263
>>
>>58863180
Don't neglect other paradigms, some of them have good ideas that you can steal.
>>
>>58863199
>OOP
>good design
>>
>>58863217
I did say some, not all.
>>
>>58863227
>implying I'm not just memeing because I have no idea what I'm talking about
that said I do like C++ because I can mix OOP and procedural together
>>
>>58863227
>FP
>good design
>>
>>58863056

I'm salty because you suck at C.
>>
>>58863199
What about C#
>>
>>58863320
Perhaps. I don't know it.
>>
Today i had to c++ homework and my internship
Yearning to work on my side projects ;~;
>>
>>58863319
>you suck at C.
while accurate, I did give an example of using a three deep pointer, mr./ms. bully
>>
What are some good example of programming languages which had a good amount of fanfare but never saw significant "real world" usage?
>>
>>58863408
D
>>
I have a Haskell exam tomorrow, send help. What do I need to know?
>>
>>58863453
It might help if you knew some Haskell.
>>
File: consider_suicide.png (628KB, 1280x620px) Image search: [Google]
consider_suicide.png
628KB, 1280x620px
>>58860551
>turned out the abs function in C++ actually returns the absolute value of the integer part of the floating point
>everything ran smoothly after I replaced abs with fabs
>stumped by something this simple for 2 days
What the fuck even is the point of programming?
>>
>>58863453
https://en.wikibooks.org/wiki/Haskell

I don't know it could be on anything.
>>
>>58863563
most likely you didn't write tests for that. you should write more tests. helps you program faster
>>
File: ddosd my school.png (56KB, 388x152px) Image search: [Google]
ddosd my school.png
56KB, 388x152px
According to a friend in a company I applied for, I am likely to get an internship offer from them in the coming days. However, I have an interview with a company that I'd rather work for next Monday. Is there any tactful way to tell a software company "I need a few days bc someone better than you is interviewing me"?

For what it's worth, they are smaller software outfits.
>>
File: really_implores_you_to_ponder.png (147KB, 231x361px) Image search: [Google]
really_implores_you_to_ponder.png
147KB, 231x361px
>>58863578
>writing more code will help you program faster
>>
>>58863563
>>58863609
This is why you should use C or Haskell.
C++ fags know literally nothing about making a decent language.
>>
>>58863407

You provided an incorrect example.
>>
>>58863623
fabs belongs to math.h dumbass
>>58863629
it drove the point accross, bully
>>
>>58863609
writing code should be the fastest part of programming. the time spent writing tests is less than the time spent searching for bugs or finding regressions in production
>>
>>58863583
this is a common problem anon - search for "delay job interview" and you'll find several strategies.

you can definitely tell your friend's company that you are waiting on other job offers. that's what job seekers naturally do - apply to multiple places and pick the best offer.
>>
>>58863657
>fabs belongs to math.h dumbass
Are you stupid?

>This is why you should use C or Haskell.
>>
File: wasa_cry_tilt.gif (268KB, 1920x1080px) Image search: [Google]
wasa_cry_tilt.gif
268KB, 1920x1080px
>>58863664
I fucking hate debugging
>>
>>58863670
sorry, meant to say "delay job offer"
>>
>>58863578
you shouldn't need to test that abs is abs
>>
>>58863684
so do I anon. that's why I like strongly typed languages, immutability (lets you work with a value substitution model) and tests.
>>
>>58863673
???
>>
>>58863692
you don't. you should test whatever part of your code depends on abs. you are programming with uncoupled, testable units of code, right?
>>
>>58863707
¿¿¿
>>
>>58861245
My input device is cheese pizza detector.
>>
>>58863716
I write Haskell, so I don't need to test most things
Most of the time I'm just composing pre-existing functions in mostly obvious ways
>>
>follow xkcd password strategy
>Super computer can guess it in 2 days
What memes did you fall for /g/?
>>
>>58863752
>using words in your password
fucked up senpai
>>
>>58863752
> His email passwords are considered literally unbreakable by Tianhe
>>
>>58860551
because bloated ugly DE
>>
>>58863657

A correct example would have driven the point across. An incorrect example would further encourage incorrect code.
>>
Guys, Terry is streaming!
>>
>>58863839
nah, my example's goal was to show a use of that desired pointer. you're just being pedantic now
>>
>>58863885

The example was so incorrect that it failed to get its own point across. Next time, run your code through a compiler before posting complete garbage.
>>
>>58863907
>it failed to get its own point across
only you think that, bud
>>
File: c_programming.png (107KB, 792x1023px) Image search: [Google]
c_programming.png
107KB, 792x1023px
I'm learning C, and I'm wondering about compiling with libraries. Say I wanted to do a simple network request so I utilize the existing libcurl library. It's installed and included and all that.

After compiling the executable, will I still need libcurl installed for the program to function correctly?

What I'm wondering is, does the compiler get all the necessary parts into the executable, or will other libraries (external of the executable) still be required for operation?
>>
>>58863962

I have not seen any other anons supporting your nonsensical notion that your broken, incorrect code in some way is an effective means of demonstrating how triple indirection works. But for what it's worth, a broken example is a non-example.
>>
>>58864004
Look up dynamic vs. static libraries
>>
>>58864015
thanks, looks like dynamic libraries are required at run time and static libraries are linked into the executable.

I assume libcurl is a dynamic library since including the whole thing in the executable would be bloated, but I'm still googling
>>
>>58864008
and I haven't seen any other anons supporting you and your assertion lol
>>
>>58860745
Python is useful for tensorflow, but I suppose if you're doing that, you'll have to learn a lot more than a new language.
>>
>>58864033
If you run ldd on the executable, libcurl will show up if it's being linked dynamically
Dynamic libs end in .so, static in .a
>>
>>58864004
>>58864015
>>58864033

One more question - say libcurl is a dynamic library and I've included it with:

#include <curl/curl.h>


What if the library (libcurl) is installed at a different location on a different machine? I guess C is able to find the library no matter where it is, or does it require a specific install location?

I assume C can always find it because requiring everyone to have it in the same PATH would just be stupid.
>>
>>58861138
the real pythonic way would use a lambda statement for ind instead of a variable. noob.
>>
>>58864068
very cool dude, thanks. learned something new
>>
>>58864083
The real pythonic way would be to inject cancer directly into your brain rather than gradually via Python
>>
>>58864083
>the real pythonic way is to use lambda

haha, fuck no.
>>
>>58864072
Google ld search paths, libraries are generally installed in /lib or /usr/lib on Linux while headers are in /usr/include (dunno about Windows).
>>58864090
np
>>
>>58861138
list comprehensions are good but they have their limits. A big part of being 'pythonic' is readability and e.g. this:

ind = [(a, b) for a, i in enumerate(yard) for b, x in enumerate(i) if x in 'LRM']


is too much IMO. it's borderline cluster fuck
>>
>>58864044

My assertion is merely to deny yours -- that you made an effective example of how to use triple indirection. In theory, the burden of proof here should be on you to defend your claim that it was nonetheless a good example, but I will take the liberty of proving my own counterpoint: you didn't use triple indirection. You used a triple pointer argument, but you did not in any way use it as one. In all aspects, you treated it as if it were a double pointer, and yet even if you were to change the first argument to a double pointer, you STILL would have had problems because you effectively passed NULL to alloc_2D_int_arr, thus guaranteeing that in the statement where you made the malloc call, you would have created a segmentation fault.

What pisses me off right now is not the fact that you wrote a bunch of shitty, broken C code. Everyone does that once in a while. Rather, you defend that shitty broken C code as a good example of how to do something.
>>
>pythonic way
>non-pythonic way
What kind of faggotry is this?
>>
>>58864146
A cult
>>
>>58864143
>My assertion is merely to deny yours --
What kind of faggotry follows this first line?
Not even going to bother to read the rest.
>>
>>58864143
>but you did not in any way use it as one
???
but I did. I believe you're either suffering from your gender-dysphoria or you're a tired tripfriend. should get some sleep either way bruh
>>
I need an algorithm to calculate the collision normal when a ball collides with an oriented bounding box in 3D space. Any tips for where to look? I know how to detect the collision itself.
>>
>>58864146
Basically you can program with Python as if you're programming with C, but doing this will result in slower Python code than if you do it the "pythonic way" aka as the language is intended & optimized for. Generators, list comprehensions, etc.

I'll admit that Python does feel like a "toy language" compared to something like C, but Python can also be fairly deep and technical. I've been using it 3 or so years and still learn new things. This is why when people are quick to write off Python, it tells me they haven't actually used the language that much.
>>
>>58864072
Your terminology is confusingly wrong.

> say libcurl is a dynamic library and I've included it with
No, you haven't. You have merely declared existing library functions to the module. No executable code is being included into your program just by that.

> I guess C is able to find the library no matter
C doesn't find anything. The compiler might find it, but only during compile time, not necessarily at runtime. It might compile in some code for you to find it during runtime though. If you want to find it at runtime you'll need to read the documentation of the compiler and/or the operating system.
>>
>>58864219
>No executable code is being included into your program just by that.

Yeah, I know. You have to actually use the library functions for the compiler to care about it.

>C doesn't find anything.

Good point, I shouldn't have worded my post this way
>>
>>58864179

>but I did.
Just because you used a triple pointer does not mean that you used it as one. Beyond the function signature of your function, nothing is used in a way that resembles triple indirection. Let us examine your code thoroughly:

int **dfc_a_best = NULL;

Here we create a double pointer. If we were going to make an example of triple indirection, we would pass the address of this...

alloc_2D_int_arr(dfc_a_best, argv[1], argv[2]);

But noticeably, we do not. We pass it by value. So we're just going to pretend this double pointer is actually a triple pointer. Okay.

Inside the function call, we see even more nonsense:

size_t sz = hlen * vlen * sizeof(int);

We're allocating memory for a buffer of hlen * vlen ints. What we wanted was a 2D array by using a pointer to a buffer of pointers to buffers. Instead, you are again treating things like double indirection, where one might create a 1D array, and set it to the array argument.

*ruby_is_a_male_female = malloc(sz);

Here we make only one malloc, further cementing this notion that we're just doing regular old double indirection. Oh, and we just segfaulted.

Finally, after the call, we're still fucking things up...
free(dfc_a_best);

Instead of a buffer of pointers to buffers, we are just freeing one single buffer. If we actually had a 2D array based on a double pointer (set via a triple pointer), and this were not a main function, you would have leaked memory. Good job!
>>
>>58864274

Ruby, stop taking the bait.
>>
>>58864290

You and I both know that is not something I am capable of doing.
>>
>>58864274
Your mom is a triple indirection
>>
>>58864274
you seem to be missing the entire point which is not surprise for being a tripfriend, and you're merely repeating yourself at this point. get some sleep, xie
>>
>>58864308

I know, but I wanted to say it anyway.
>>
>>58864308
>>58864419
Go get a room already.
>>
>>58864454
they probably shitpost in the same room
>>
>>58864330

You are the one who is missing the point here. Your code is broken in so many ways that it completely fails to demonstrate how triple indirection is used. A new programmer who looked at your example would fail to correctly understand the mechanics of how to do triple indirection. If you are going to post a code example for noobies to learn from, in the future, bother to run it once through a goddamn compiler, so you can know if you're giving them garbage or not.

>>58864477

GTP is in New Jersey
I'm in Washington

Opposite sides of the country.
>>
>>58864520
nah, I'm not. the fact that you're so ignorant of what I'm showing with my example is more evidence that tripfriends can do nothing but shitpost. way to reinforce a stereotype bud
>>
>>58864571

learn C, then you can have a tripcode. :)
>>
>>58864571

>ignorant of what I'm showing
Then please, explain how this is anything but a complete pile of garbage.
>>
File: fd.png (749KB, 746x749px) Image search: [Google]
fd.png
749KB, 746x749px
>>58860551
How can I improve my maze generator? It uses kruskal's algo to make a MST, but it's too easy to solve now.
>>
>>58864599
but my mom said I was really good at C :^)
>>58864607
I'm glad you finally asked instead of just shitposting and insulting code I already admitted to being shitty.
my example shows an alternate way to implement a function that creates a 2D array of integers by passing an already existing 2D int array to be allocated. (the other way I know of involves create such an array in the function but then returning the address to it.) to be able to accomplish the alternate way you need to have the function's pointer parameter be three deep.

my example
// allocates arr as a 2D array of ints and initializes it such that all elements are equal to 0
void alloc_2D_int_arr(int ***arr, int rows, int cols);

the other way
// returns an allocated 2D array of ints initialized such that all elements are equal to 0
int **alloc_2D_int_arr(int rows, int cols);
>>
>>58864690
Yooo what language are you using?
>>
>>58864810
python for now
could redo it in C
>>
>>58864713

Right, I get what you were trying to do from the function signature, but the problem is, you got everything other than the signature wrong.
>>
>>58864713
>int **
That's not really a 2D array. That's an array of int pointers.
>>
>>58864943

You accepted that the first pointer is an array, but not the second layer?
>>
>>58864911
>I get what you were trying to do from the function signature
then why did you fake ignorance about the point? then why did you bother me with code I admitted was terribad? is it because you feel that this increases your epeen? is it because you feel this thread should be a bastion of brilliance? did you even know that the anon I was responding to with that original piece of code was a probable shitposter? no, you didn't. so congrats anon, you revealed to me that I can be easily baited and angered on an anonymous imageboard. thank you

>>58864943
there are differences between pointers and arrays, yes, but in this context, and a lot of contexts, it doesn't matter.
>>
>>58860585
Just learn Haxe
>>
File: arrays.png (137KB, 1024x768px) Image search: [Google]
arrays.png
137KB, 1024x768px
>>58864957
>>58864969
I can't really be bothered explaining what I'm talking about, so I drew a picture.
>>
>>58860585
Learn Visual Basic
>>
>>58864989
were the apples really necessary
>>
>>58865006
Don't you even know about the GNU/Pepper?
>>
>>58865011
sounds spicy
>>
>>58865006
>apples
I'm calling stallman on you!
>>
>>58865017
good i'll shoot the commie dead
>>
>>58865024
If it rids the world of the GPL then I'll spot ya.
>>
>>58865038
GPL aka Gommie Phidel Lenin iz nod my brogrammmmming licens dD=
>>
>>58864969

>then why did you fake ignorance about the point?
You seem to still be not getting what I'm saying.

I can get what you were trying to do. I'm a more experienced C programmer, and can judge from your function signature what you were trying to do because I've done it before. But I'm not the one you're trying to impart a lesson onto. You're trying to teach it to someone who is much less experienced. This kind of person might not get what you are trying to do purely from the function signature. The implementation of how that function is used is part of the example, and you fucked that up. The implementation of how the function works internally is part of the example, and you also fucked that up. A newer programmer is going to look at these sorts of things and might get confused. And while you may be right in saying that they were probably a shitposter, I have found that in these threads, most of the posters who are not shitposters are beginners, and I believe it is important when we are dealing with beginners, that we show them examples that are both correct and examples of well-written code (or if it is not well-written, make a note of this). My issue isn't merely with the fact that you wrote bad code, but that you defend bad and incorrect code as a good idea to show to a beginner as an example for learning new concepts.
>>
>>58865093
is this copypasta?
>>
Student going into C, what am I in for? An actual useful language?
>>
>>58865116
Yes. C is still used extensively, despite what the Javashit/python/sepples memers tell you, and is arguably one of the most important programming languages.
>>
File: compiler_structure.png (60KB, 537x723px) Image search: [Google]
compiler_structure.png
60KB, 537x723px
>>58865116
Use a Turing complete context-free language.
>>
>>58865150
>Turing complete
inb4 le computers are not turing complete maymay
>context-free
Are there any truly context-free programming languages?
>>
>>58864989

A 2D array as an abstract concept is an array of arrays. Whether this is implemented as contiguous memory or through indirection is more or less irrelevant to its definition. If we can accept that T* is an array, then we can accept that a T** is an array of arrays. Since each int* is representative of an array buffer, we refer to this as a 2D array. Though C has 2D arrays of the first kind (contiguous memory), subscripting it as a 2D array (using 2 separate index operators) requires that the sizes be known at compile time. Where both sizes must be known at runtime, the array of pointers to arrays structure is commonly employed. Contiguous memory is still possible, but in this case, it can only be used with one subscript operator, and the syntactic sugar is lost.
>>
>>58865177
Stop making these yuge posts
>>
>>58865164
I've found this link, may be it will help.
https://news.ycombinator.com/item?id=5141167
>>
>>58865190

4chan rules require that you be at least 18 to post here, even on the "safe for work" boards. Please come back when you can read at at least an 8th grade level.
>>
>>58865177
>Whether this is implemented as contiguous memory or through indirection is more or less irrelevant to its definition
Actually it's completely relevant. Arrays are contiguous by definition.
>Since each int* is representative of an array buffer
Not necessarily, as elements of this array can be null.
>subscripting it as a 2D array (using 2 separate index operators) requires that the sizes be known at compile time
No it doesn't. This is one of the situations where VLAs can be useful.
>Contiguous memory is still possible, but in this case, it can only be used with one subscript operator, and the syntactic sugar is lost.
#include <stdlib.h>

int main(int argc, char *argv[])
{
int x = argc > 1 ? atoi(argv[1]) : 10;
int y = argc > 2 ? atoi(argv[2]) : 10;
int (*arr)[y] = malloc(sizeof *arr * x);

// Do something with arr

free(arr);
}

This is a true runtime sized 2D array. However C's type system does not allow these to be returned from functions, but they can be passed in.
>>
C's array, function and pointer type syntax is inexcusable

>>58865224
Oh be quiet you brony faggot
>>
>>58865239
C's declaration syntax had admiral goals: declare it like it's used.
>>
>>58865249
>admiral
admirable*
>>
>>58865249
Does C allow parentheses in types?
>>
>>58865226

>pointer to VLA
Fuck, I keep forgetting about VLAs. That's actually a pretty good use case for 'em.
>>
>>58865093
no, again you seem to be infering and mistaking shit. why should I and other anons have to cater our posts to beginners? do I have to comment each line so code babies don't get confused? /dpt/ is not a thread soley for beginners. I posted lazy shit I ddin't even bother proof-reading until after the fact, but I didn't feel like submiting it again for I felt it got the point across to most anons. if that shitposter was a beginner and tried to compile, well it would an interesting exercise on how to unfuck my program and probably a good lesson for him

>>58865100
it is now
>>
>>58865262
Yes. I used parenthesis in >>58865226 to change the precedence of operators in that type.
>>
>>58865226
very cool, anon! learn something new something errday
>>
>>58865280

>why should I and other anons have to cater our posts to beginners?
If you're gonna try to teach, do a good job at it or fuck off.

>do I have to comment each line so code babies don't get confused?
Use comments where they are useful in instruction.

>/dpt/ is not a thread soley for beginners.
Right, it's just that the majority of posters here are either retarded shitposters or beginners. There's a few decent programmers mixed in, but we are in the minority.

>if that shitposter was a beginner and tried to compile, well it would an interesting exercise on how to unfuck my program and probably a good lesson for him
As a general rule of thumb, I feel programmers should lead by example and not create shit code that others have to deal with. Let beginners struggle with unfucking their own programs. They get enough of that.
>>
>>58865328
jesus christ. you take posting here way, way too seriously
>teach
I wasn't teaching, just giving an example. I'm not a pedagouge nor did I ever pretend to be. if I see someone wanting an example, and I think I can provide an example, I'm going to do so. there's nothing you can do about it bitch boy
>infering my hyperbole as a serious question
>Right, it's just that the majority of posters here are either retarded shitposters or beginners
okay, you state you know this but you still act like an insufferable faggot about teaching and saying this applies to /dpt/:
>As a general rule of thumb, I feel programmers should lead by example and not create shit code that others have to deal with
that's your assumption and opinion. yet you feel the need to push it down my throat as if its a rule and a fact

I have to ask: if you have such a low opinion of /dpt/, but a high regard for how programmers should act, why do you read and post here? you know damn well this thread won't change no matter what you try to peddle
>>
>>58865386
>I wasn't teaching, just giving an example
How is giving an example not trying to teach the anon how to do it?
>>
>>58865386

>why do you read and post here?
Because I get a kick out of helping out new C programmers and occasionally like to show off whatever project I'm working on. Also, it's pretty much the only programming community on 4chan right now and I refuse to go to Reddit.
>>
how do I get "left" from leXft with regex?

I could do (le).(ft) but how do I combine the groups?
>>
>>58865424
>how do I combine the groups
\1\2
e.g.
echo "leXft" | sed -r 's/(le).(ft)/\1\2/'

However, if it's really a constant string, then you don't even need sub-expression matches, as it's always going to be "left".
>>
>>58865404
I wasn't showing him how he can do it, anon, I was showing him what he can do with dat triple redirection. It is, by definition, teaching; I'll secede that. With that said, if what I did was teaching, then that's an insult to actual teachers. I feel, in my mind, that giving one simple example isn't teaching. It's just answering a question or fulfilling a statement of a shitposter.

>>58865409
If you really are here for just that, then that's cool. Just stick to that and stop lecturing on how and what to post. Also, and I know you're not going to do it, drop the trip. It serves no puprose other than making you look like an attention-seeking faggot. Which, from the way you act, isn't an incorrect assumption.
>>
>>58865487

>It serves no puprose other than making you look like an attention-seeking faggot.
You hit the nail on the coffin there.
>>
>>58865519
Then why do you use it? I know you use to namefag, but why bother having a trip when it just makes others think you're a dick-gobbling homo? If you like having a name so much without that stigma, you really should use reddit or use another forum.
>>
So what's the best textbook to learn Javascript?
>>
>>58865599
tbqh you feed his thirst of attention by replying him.
>>
>>58865599
Problem with namefagging is that some other attention whoring faggots can just use the same name as well.
>>
>>58865599

>why do you use it?
Because I AM an attention whoring faggot.

>you really should use reddit or use another forum
I've been on this site for ten fucking years; it's home to me. Reddit has downvotes, and most of the subreddits are filled with a lot of inane rules, and a lot of the people there are fucking normies.
>>
>>58865622
You're right; I'm enabling his faggotry. I was doing it the whole time. I was baited and hard. What am I doing with my life if I'm arguing with a attention-seeking guy on an anonymous imageboard?
>>
>>58865659

>What am I doing with my life if I'm arguing with a attention-seeking guy on an anonymous imageboard?
Having fun?
>>
>>58862385
Don't bother learning a programming language. Just write a shell script that uses curl to download the page you want.

The url is like this:
http://www.lrwu.com/rain/DailyTotal.aspx?Day=2/8/2017

Just change the date in the url to yesterday's date and you've got the page you want to download today. If you want to pull the data out of that so you don't have to read it in a browser use coreutils like grep and cut. If you're not on a *nix you can probably get a curl executable for Windows or whatever and do batch scripting. If not curl has a C interface since you know C. Writing your own parser in C should be pretty simple. Just look at the html source that curl grabs for you. I'd be surprised if any of those languages you listed didn't have the ability to parse that simple table.

curl http://www.lrwu.com/rain/DailyTotal.aspx?Day=2/8/2017 > 20170208.html
egrep '<td align="center"><font color="Black">[[:upper:]]{4}' 20170208.html |
egrep -o '>[[:upper:]]{4}<|>[[:digit:]]+\.[[:digit:]]{2}<|>[[:digit:]]{1,3}</' |
tr '\n<>/' ' \n' | tr -s ' ' > 20170208.txt


You data ends up in 20170208.txt:
 AFTP 0.00 100 
ASPS 0.00 100
CRPS 0.00 100
CVPS 0.00 100
HRPS 0.00 100
JRPS 0.00 100
LAPS 0.00 100
LFPS 0.00 100
RRPS 0.00 100
FCTP 0.01 100
LMPS 0.00 100


If the page format changes then you'll have to change with it but that's probably true with everything.
>>
>>58865681
Shell is a programming language as well.
>>
>>58865681

>batch scripting
Batch is gross. Please do not recommend its continued usage when Powershell exists.
>>
>>58865681
>Day=2/8/2017
>20170208.html
fuck whoever made someone do this
>>
>>58865696
Yeah but you don't need to learn it to do that. The only shell thing I did there was IO redirection.
>>
>>58865677
/dpt/ is absolutely no fun. I mean, it can even give me panic attacks.

Yet, I still lurk, waiting for challenging posts that would make my day a little less boring...
>>
>>58865795

>it can even give me panic attacks
If this is the case, you need to take shit a lot less seriously. You're on 4chan, mate.
>>
vect struct:
template<typename T>
struct vect {
T x, y;
};

indexable stack code:
template<typename input, typename data, typename index>
class indexable_stack
{
...
data* data_array = 0;
...
}

template<typename input, typename data, typename index>
index indexable_stack<input, data, index>::push(input d)
{
...
data_array[pos] = d;
...
}

indexable stack instance:
indexable_stack<vect<long>, vect<std::atomic<long>>, cid> F;

and I even create type-specific code to perform [struct of atomic int] = [struct of int] in indexable_stack::push()
template<>
vect<std::atomic<long>>& vect<std::atomic<long>>::operator=(const vect<long>&& other)
{
x.store(other.x, std::memory_order_relaxed);
y.store(other.y, std::memory_order_relaxed);
return *this;
}


but I get "/home/.../indexable_stack.cpp:48: error: no match for 'operator=' (operand types are 'cp::vect<std::atomic<long int> >' and 'cp::vect<long int>')
     data_array[pos] = d;
^


help please
>>
>>58865918
Can't you just post something that can be compiled?
>>
>had 3 job interviews for a C# position
>All of them ask if i can program delphi
I never even heard of Delphi before, why is it so popular?
>>
>>58866016
delphi is the meme dream GUI team
>>
>>58865918
>C++
Good luck with that, fag.
>>
New thread:

>>58866073
>>58866073
>>58866073
>>
>>58864198
Learn how into vectors.
Just to clarify: are you looking for the vector that is orthogonal to the side of the BB the ball collided with and has a length proportional to the collision speed?
>>
>>58865918
>>58865941
>>58866069
compilable code:
#include <iostream>
#include <atomic>
#include <cstdlib>

template<typename T>
struct vect {
T x, y;
};

template<typename input, typename data>
class indexable_stack
{
public:

indexable_stack();
int push(input d);
input pop();

private:

int current_size = 0;
data* data_array = 0;

};

template<typename input, typename data>
indexable_stack<input, data>::indexable_stack()
{
data_array = (data*)std::malloc(10 * sizeof(data));
}

template<typename input, typename data>
int indexable_stack<input, data>::push(input d)
{
if (current_size < 10){
int pos = current_size;
data_array[current_size] = d;
current_size++;
return pos;
}
return -1;
}

template<typename input, typename data>
input indexable_stack<input, data>::pop()
{
input d;
if (current_size > 0){
current_size--;
d = data_array[current_size];
}
return d;
}

template class indexable_stack<int, int>;

//I tried to create the missing function
//template<>
//vect<long>& vect<std::atomic<long>>::operator=(const vect<long>& other)
//{
// x.store(other.x, std::memory_order_relaxed);
// y.store(other.y, std::memory_order_relaxed);
// return other;
//}

//template class indexable_stack<vect<int>, vect<std::atomic<int>>>;

int main()
{
//compiles:
indexable_stack<int, int> is_int;
is_int.push(20);
std::cout << "pushed: " << is_int.pop() << "\n";

vect<int> vect_int;
vect_int.x = 10;
vect_int.y = 20;

//does not compile:
// indexable_stack<vect<int>, vect<std::atomic<int>>> is_aiv;
// is_aiv.push(vect_int);
// std::cout << "pushed: " << is_aiv.pop().x << "\n";

return 0;
}
>>
>>58861276
C#
>>
alternatives for rosettacode.org?
>>
Doing a java project.
I have some code that might be shared my some classes, some of this code are general purpose algos.
I don't want to put it in some class that i then have to extend because i feel like this methods should be private if put into those classes and testing is going to be a pain in the ass.
Should i just make a myproject.Util package and stuff that code into various single purpose classes? Seems the cleaner method for testing.
>>
File: collision.png (81KB, 800x600px) Image search: [Google]
collision.png
81KB, 800x600px
>>58864198
1/2
>>
File: vectors.png (68KB, 800x600px) Image search: [Google]
vectors.png
68KB, 800x600px
>>58864198
2/2 explanation how I got the long formula at the end
Thread posts: 318
Thread images: 23


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