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

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

Thread replies: 255
Thread images: 35
File: jsqpBO2.jpg (76 KB, 632x638) Image search: [Google]
jsqpBO2.jpg
76 KB, 632x638
Old thread: >>54957527

What are you working on, /g/?
>>
>>54964446
I can, but then again, I have a pretty big dick...
>>
>>54964554
I really hope you didn't think that was a gotcha moment
>>
>>54964648

i use my big dick to fuck and cum into my computer
>>
>>54964693
I use mine to slap your mouth
>>
Working on your mum, OP.
Reminder that C programmers are good at wanking, all alone.
>>
>>54964614
6th for Go.
>>
>>54964721
More like Go fuck yourself, am i rite?
>>
>>54964685
No, this was obviously UB. But the retards who unironically recommend C don't even know the basics.
>>
>>54964748
It's not UB. Don't question the size of my dick. You don't want to get raped again.
>>
>>54964738
>am i rite?
no
>>
>>54964748
>obviously UB
>obviously
pretty big word for a dipshit that doesn't know C
>>
Is there a better language than C to use in developing my robotic dildo?
>>
Riddle me this batman

#include <iostream>

int main()
{
int x=1;
std::cout << x++ << ' ' << x++ << std::endl;

return 0;
}

output: 2 1


Why is C++ so shit?
>>
>>54964904
haskell
>>
>>54964921
any particular reason?
>>
>>54964904
But seriously, rust. It's pretty much as fast as C, but you don't get memory bugs and you get to work with ML constructs instead of mucking around barely above the ASM level. It also has all the primitives you need for any low-level task, so it's a great fit.
>>
>>54964916
Yeah, that's a part of C/C++ that is just fucking stupid. But then again, it couldn't be easier to avoid.
>>
>"new" dev software for campus computers
> Borland C++ compiler
Its like calling with a rotary dial phone. Who the fuck still uses Borland C++?
>>
Fact: C is undefined behavior.
>>
>>54964866
BTFO
T
F
O
>>
>>54965055

Is it actually Borland C++ or is it the newer Embarcadero tools?
>>
>>54964916
Whats going on here?

Why 1 as the second output?
>>
>>54964916
learn not to be fucking stupid nigger

that's undefined behavior
>>
>>54964446
Any half competent monkey should be able to do that. You can't? Then C is clearly not for you!
>>
>>54964648
>>54964693
>>54964704
could y'all post your dick pics? interested here.
>>
>>54965102
The new Escobar tools. Do they have any relevance today?
I really hoped for access to Intel XE when they announced a "brand new expensive compiler suite"
>>
>>54965189
>Do they have any relevance today?

They're actually pretty good, yeah. The delphi stuff was always better than the C++, because it was Borland's bread and butter, but the RAD tools are nice.
>>
File: Jason Lee Update 1.png (55 KB, 1006x729) Image search: [Google]
Jason Lee Update 1.png
55 KB, 1006x729
I last showed off my level editor program for game maker a few weeks ago. Ive been busy moving so I havent been able to make much progress but I have focused a bit on aesthetics the past few nights and Im pretty happy with how it has been turning out so far. All of the colors are variables so I can change them all very easily. I made it match my windows color so it would blend together more nicely.

So what do you /g/ents think?
>>
>>54964614
What cross-platform GUI framework could I use for linux-based audio applications development? QT is too slow (I need microsecond precision for events) and JUCE's linux support is shit right now
>>
>>54965244
Looks very barren for a map editor.
>>
>>54965244

looks like shit desu jason
>>
>>54965303

Have you considered GTK?
>>
File: Jason Lee Update 1.1.png (73 KB, 1006x729) Image search: [Google]
Jason Lee Update 1.1.png
73 KB, 1006x729
Heres another picture where you can see the properties and tab (thats not finished). I also changed the window color to show how the aesthetics work.

>>54965329
Yeah the objects tab shows the list of spawnable things and I accidentally deselected the default object so you cant see the settings. Fixed in pic related.

>>54965352
:( Any tips for improvements? Also I named the project Jason Lee because its short for JSON LEvel Editor. Its not my name.
>>
>>54965417
STFU OSGTP
>>
>>54965424
looks pretty bad.
>>
File: Jason Lee Demo 1.gif (2 MB, 1032x750) Image search: [Google]
Jason Lee Demo 1.gif
2 MB, 1032x750
>>54965424
Oh and here's a demo of the last update if you missed it. It is uglier but shows how it works.
>>
>>54965485
I prefer this one desu.
>>
>>54965502
Mind if I ask why? What about it do you prefer?
>>
>>54965516
It doesn't hurt my eyes. Can you actually drag stuff around instead of clicking on the coordinates?
>>
>>54965219
Their Delphi stuff looks really useful given that I havn't heard anything about Pascal or Delphi for over a decade.
>>
>>54965545

I don't think Delphi is very popular any more. Still, it'll be fun to tinker with.
>>
>>54965542
Yes you can. You can drag them, click the coordinate to type it in, or scroll the coordinate to make it change by the change amount which is what I prefer to do. In my recent update I added a toggle that combines the X and Y as well as the Xscale and Yscale so you can scroll the x or shift scroll the y. Thats my favorite and feels more like photoshop.
>>
>>54965485
It looks weird when you add the outline to the selected object, the object looks bigger than it actually is. It would be better to put the outline on the edge of the object, not next to it. Or use dotted or dashed lines for the outline.
>>
>>54965598
It's actually quite nice once you see how it works, I'll take my criticism back. But still, I slightly prefer the colors on the GIF.
>>
>>54965594
I think companies will refuse switching to other tools when Delphi even supports Android now
>>
>>54965653
ignore OSGTP
>>
>>54965653

Well, that's the thing -- many places have already switched.
>>
>>54965612
Thats a great idea. The outline was bothering me before so I made it so it would blink white instead of that weird dark color. I am about to record a new demo so you can see what Im talking about. Great suggestion tho; I would love to see it on the inside.

>>54965640
Thanks :D I usually roll with a dark theme on my computer and thats just the colors I grabbed from windows and the material design guidelines. I plan on making the default colors for a light theme but since Im the only one using it at the moment that what I set.
>>
How do I change a 1 dimensional array into a 2D one?
For example I have an array of 100 0s and I want to split it up into 10s
>>
>>54965668

ignore urself u fucken faglord
>>
>>54965694
Stick to the dark layout. the light version will burn your eyes if you work at night without flux
>>
>>54965708
I'm using python if it matters
>>

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

int fact(unsigned int n)
{
if (n == 1 || n == 0) return 1;
return fact(n - 1) * n;
}

int main(int argc, char *argv[])
{
if (argc != 2) {
fprintf(stderr, "%s <int>\n", argv[0]);
exit (1);
}
int i = atoi(argv[1]);
unsigned int j = fact(i);
printf ("!%d = %u\n", i, j);
return 0;
}


I can't get it to go higher than !31 because the number gets too large, what can I do?
(its running on a rpi)
>>
>>54965770
libgmp
>>
>>54965417
I have not. Thx anon :)
>>
>>54965446
But why?
>>
>>54965770
Write or find a bignum library.
>>
>>54965856
Because he is stupid and suck at coding.
>>
>>54964916
>>54965111
Order of evaluation is implementation defined

also
>iostream
>>
>>54965883

Stop shitposting at me you weirdo.
>>
Trying to learn Scala and functional programming
>>
>>54963998
>CannotQuack
>+quack()
The absolute madman!
>>
File: Jason Lee Demo 3.gif (2 MB, 1164x739) Image search: [Google]
Jason Lee Demo 3.gif
2 MB, 1164x739
>>54965729
Yeah the contrast burns my eyes but whatever I just changed it while I recorded the demo. I have the light theme set first then my personal dark overwrites the variables. When I want to switch I just comment out my color change.

Without further ado, I present a demo of the current state of Jason Lee
>>
>>54965770
>>54965792

From http://suckless.org/sucks/:
>GMP - GNU’s bignum/arbitrary precision library. Quite bloated, slow and calls abort() on failed malloc

>Alternatives: libtommath, TomsFastMath, MPI, libzahl (WIP), hebimath (WIP)
>>
>>54965998
Why is all the text in your interface so large and bold?
I think it would look better to use monospace fonts for the object names and properties.
Also,
>/G/
>>
>>54965708
anybody?
>>
>>54965958
STFU
>>
>>54966094
you cycle it appropriately in a for and assign the appropriate values to the new 2D array
>>
>>54966094
you can map 1d indexes to 2d:
arr_2d[y,x] = arr_1d[y * width + x]

where width is the width of the 2d array.
>>
someone explain this

#include <stdio.h>


int main()
{

int a = 1;

printf("%d %d %d %d\n", a++,a++,a++,a++);

return 0;
}


output

4 3 2 1
>>
rewriting C with the haskell kernel
>>
>>54965770
you can compute 1000 factorial in C using strings.


my program runs in a millisecond computing 1000 factorial
>>
>>54966316
go learn assembler and use a disassembler
>>
>>54966316
My guess is that as the parameters get pushed onto the stack, they get evaluated. Stack then looks like this
1
2
3
4
Then they get printed from left to right in the parameter list, resulting in the behavior you see there. Spitballing here though
>>
>>54966359
haha yeah ok lol
>>
File: zzz.jpg (63 KB, 1280x720) Image search: [Google]
zzz.jpg
63 KB, 1280x720
Is this true?

I want to change my job and this looks like a good opportunity.
What are the most useful/requested languages to learn?
I'm currently learning HTML to start with, and plan Java or Javascript next (I know the 2 are not similar despites the name, so which one would be more useful for real situations, like, let's say developping smartphone apps or games)?
>>
>>54966316
Unsequenced modifiers, the exact order of operations in your example is not defined in the standard, so it's up to implementation of the compiler. I think gcc outputs 1 2 3 4. Use -Wunsequenced to warn you when it happens. Easy workaround is to simply split up the line in four lines. It's a little annoying but usually not a big deal.
>>
>>54966402
>>>/g/wdg
>>
File: Jason Lee Font 1.png (75 KB, 1006x729) Image search: [Google]
Jason Lee Font 1.png
75 KB, 1006x729
>>54966075
Tried out Ubuntu Mono nonbold size 11. The issue is that without bold it looks blurry for me for some reason. It is more noticeable with a dark theme under it. There is something in the way that GM:S processes fonts that makes them look stupid.

Recommendations for a different mono font?
>>
File: Screenshot - 070616 - 23:39:08.png (91 KB, 912x661) Image search: [Google]
Screenshot - 070616 - 23:39:08.png
91 KB, 912x661
>>54966400
actually it runs in 0m0.031s

my bad

pic related
>>
>>54966453
post code
>>
>>54965770
Use long (or uint64_t or whatever) to go further or use a library for arbitrary precision like others suggested. Advanced option: Implement a simple one yourself for this purpose. It's simpler than it sounds and very fun in C++. Not so much in C though.
>>
>>54966453

oi lad, what's your font there?
>>
>>54966507
wingdings
>>
>>54966468
its closed source :^)

>>54966507
>oi lad, what's your font there?
in the terminal is "ProFontIIx Regular" size 7

on sublime text in the default one that comes with sublime
>>
>>54966438
Try Bitstream Vera Sans Mono
>>
>>54966545
>inb4 he set a string with the value of 1000!
>>
>>54966545
>in the terminal is "ProFontIIx Regular" size 7

Thanks.
>>
>>54966438
Make a snap to grid toggle m8.
>>
>>54966715
no, just replying to the 2nd question, by telling him to ask there instead
>>
>>54966468
here is something I just did.

int buff[1024];

int main(void){
int i, j, r, t;
buff[0] = 1;
t = 1;
for (i = 1; i < 1000; i++){
r = 0;
for (j = 0; j <= t; j++){
buff[j] = buff[j] * i + r;
r = buff[j] / 100000;
if (r > 0){
buff[j] -= r * 100000;
}
}
if (r > 0){
t++;
buff[t] = r;
}
}
for (i = t; i >= 0; i--) printf("%05d", buff[i]);
return 0;
}


No idea about performance though
>>
>>54966834
Some online compiler says
real    0m0.005s               
user 0m0.003s
sys 0m0.001s
>>
>>54966834
>>54966875
very nice. its better than mine
>>
>>54966834
oh wait, t should be initially 0. it doesn't really matter though.
>>
File: brownfeels.jpg (39 KB, 400x449) Image search: [Google]
brownfeels.jpg
39 KB, 400x449
who /javaEE/ here?
>>
>>54966834
Ugly code, but neat idea. Also it should be
for ( i = 1; i <= 1000; ++i )

it just wasn't obvious with 1000, because the difference between < and <= are just three zeroes. Other than you can probably test whether it's faster with a larger type than int, say uint64_t or something.
>>
>>54967130
Whoops, missed that too.

here is one with long long

#include <stdio.h>

long long buff[1024];

int main(void){
int i, j, r, t;
buff[0] = 1;
t = 0;
for (i = 1; i <= 2000; i++){
r = 0;
for (j = 0; j <= t; j++){
buff[j] = buff[j] * i + r;
r = buff[j] / 100000000;
if (r > 0){
buff[j] -= r * 100000000ll;
}
}
if (r > 0){
t++;
buff[t] = r;
}
}

for (i = t; i >= 0; i--) printf("%05d", buff[i]);
printf("\n%d", t);
return 0;
}


time is a bit chaotic but total time is ~0.012 for 2000! 32 bit version takes ~0.018s

It can go slightly faster if it were using base 0xFFFF instead of base 100000 but that would be a pain to print in base 10 and printing it would probably take more time than actually calculating it.
>>
can someone give the TL;DR version of the argument you had about pointers

why wouldn't it be possible to convert a pointer to an integer and the integer back to pointer
>>
>>54967228
It is possible, the anon who argued otherwise is wrong.
>>
And here is the GMP version, 100x more readable and much faster:

#include <stdio.h>
#include <gmp.h>


int main()
{
mpz_t prod;
unsigned i;

mpz_init_set_ui(prod, 1);
for (i = 1; i <= 1000; i++) {
mpz_mul_ui(prod, prod, i);
}

gmp_printf("1000! = %Zd\n", prod);

return 0;
}


./a.out  0.00s user 0.00s system 0% cpu 0.002 total
>>
>>54967219
should have used %05ll to print buff[i]
>>
>>54967244
And here is the time for 3000!

./a.out  0.00s user 0.00s system 48% cpu 0.007 total


10000!

./a.out  0.02s user 0.00s system 55% cpu 0.036 total
>>
>>54967260
>>54967260
pretty good, it probably uses simd.
>>
>>54967228
It's possible, but:
ptr += offset;

is not guaranteed to be equivalent to:
int iptr = (int)ptr;
iptr += sizeof(T) * offset;
ptr = (T *)iptr;
>>
>>54967244
>And here is the GMP version, 100x more readable and much faster:
using external libraries its piss easy.

we're trying to write a program in raw C

good job tho
>>
>>54966316
you worded your question wrong you meant to say "C++ FAGS WILL DEFEND THIS" for max replies
>>
New fag here and I am trying to make a program that is so simple that has a user input a number and subtracts by rows EX:
UI = 5
54321
4321
321
21
1
This is what I have
#include <stdio.h>
#include <stdlib.h>

int main()
{
int i, j;
int num;


printf("Enter a number: ");
scanf("%d", &num);

for (i = 0; i < num; i ++)
{
for (j = num; j > 0; j = j - 1)
{
printf("%d", num);
}

printf("\n");

}

return 0;
}

I am okay with taking hate bc I suck ass and am new ;-;
>>
>>54967330
no, the guy wanted code that would run on an rpi, rolling your own format for storing big numbers isn't the way to go
>>
>>54967228
>>54967327
In more precise terms, the set of pointers is, in general, a quotient of the set of machine words. Most of the time, they are equivalent, but not always (e.g. on segmented memory architectures).
>>
>>54967260
Funnily enough, using GMP's builtin factorial function performs barely as well (but did use much less cpu)

#include <stdio.h>
#include <gmp.h>


int main()
{
mpz_t fac;
mpz_init(fac);
mpz_fac_ui(fac, 10000);

gmp_printf("10000! = %Zd\n", fac);

return 0;
}


./a.out  0.01s user 0.00s system 18% cpu 0.037 total
>>
>>54967410
Wow, I'm retarded. Just realized most of the time spent was actually printing out the number. The actual time is around 5ms for 10000!.
>>
>>54967353
I don't understand. The user enters 54321 and it prints that output? Or does he enter 5?
>>
>>54967228
it's possible but not portable to all possible implementations; ie. it's implementation defined
>>
>>54967353
The inner loop is almost right. The outer one you are counting up to n instead of down from n. You are also always setting j to start from n. You need it to start from decreasing numbers.
>>
>>54967353
your for loop should be
for (j = num-i; j > 0; j = j - 1)


and you should print
 printf("%d", j); // print j not num here



first you print 54321

then you subtract 1 to num in the for loop starting in 4 and so on

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

int main()
{
int i, j;
int num;


printf("Enter a number: ");
scanf("%d", &num);

for (i = 0; i < num; i ++)
{
for (j = num-i; j > 0; j = j - 1)
{
printf("%d", j);
}

printf("\n");

}

return 0;
}

>>
>>54967353
static void rowSubtractor(int n){
while(n!=0){
int tmp = n;
while(tmp!=0){
System.out.print(tmp);
tmp--;
}
System.out.println();
n--;
}
}

Solution in java, look at it!
>>
>>54967477
>Java
>look at it!
I will never set my eyes on such a peasant language
>>
>>54967465
ty anon
>>
>>54967477
static void rowSubtractor(int n) {
n++;
while (n-- != 0) {
int tmp = n;
while (tmp != 0) {
System.out.print(tmp--);
}
System.out.println();
}
}
>>
>>54967523
>incrementing the variable only to decrement it again
it's shit
>>
>>54967353
I am not a fun of C that much, so I did it on brainfuck

++++[++++>---<]>++.-[--->+<]>++
.++++++.+++[->+++<]>.++++++++++
+++.[-->+++++<]>+++.[->+++<]>+.
-[->+++<]>.+[----->+<]>+.++++++
+.--------.-----------.+++.++++
+++++++++.[-->+<]>+.[-->+<]>+++
.>>>>,.[-<+<+>>]++++++++++.--[-
<------>]+[[-]<[-<.-<+>>]++++++
++++.[-]<<-[->+>+>+<<<]>>>]


Output
Enter a number: 6
654321
54321
4321
321
21
1
>>
SQL question. (Specifically MSSQL, if it matters here)

I have a table, WidgetTypes, and another, WidgetCreators. I need to return each row of WidgetTypes along with a count() of how many WidgetCreators make that WidgetType.

WidgetTypes:
id INT,
foo TEXT


WidgetCreators:
id INT,
type_id INT,
bar TEXT


Desired output:
id | foo   | creators_count
-------------------------
1 | asdf | 2
2 | cxvcd | 0
3 | jkj | 4


I have a mess of joins and subqueries and temp tables and nothing works. I'm clearly missing something.
>>
>>54967578
>>>/wdg/
>>
>>54967555
it isn't.
>>
>>54965055
Well, uhmm... I made a calculator today, since I'm just learning C and programming as well.
>>
>>54967555
Ye I found that strange also!
static void diamond(int size){
char [] [] matrix = new char [size] [size];
int middle = size/2;
for(int i=1; i<middle+1; i++){
for(int j=0; j<size; j++){
if(j> middle-i && j<middle+i){
if(i%2==0){
matrix[i][j] = 'A';
}else{
matrix[i][j] = '*';
}
}else{
if(i%2==0){
matrix[i][j] = '*';
}else{
matrix[i][j] = 'A';
}
}

System.out.print(matrix[i][j]);
}
System.out.println();
}
for(int i=middle-1;i>0;i--){
for(int j=0; j<size; j++){
System.out.print(matrix[i][j]);
}
System.out.println();
}

}
>>
>>54967646
that code is disgusting.
>>
>>54967646
static void diamond(int size) {
char [] [] matrix = new char [size] [size];
int middle = size / 2;
for (int i = 1; i < middle + 1; i++) {
for (int j = 0; j < size; j++) {
if (j > middle - i && j < middle + i) {
matrix[i][j] = (i % 2 == 0) ? 'A' : '*';
} else {
matrix[i][j] = (i % 2 == 0) ? '*' : 'A';
}
System.out.print(matrix[i][j]);
}
System.out.println();
}
for (int i = middle - 1; i > 0; i--) {
for (int j = 0; j < size; j++) {
System.out.print(matrix[i][j]);
}
System.out.println();
}
}
>>
>>54967721
matrix[i][j] = (i % 2 == 0) ? 'A' : '*';

Damn only thought that worked in C#. Learning stuff in DPT, wow.
>>
>>54967866
yeah it works in C, C++, Java, C# and so on..
in other languages is written in a different way though, like python for example.

Also , who is the girl in your picture? is that from instagram?
>>
>>54967646
>>54967721
Pretty much same code in brainfuck

++++++++++[->++++>++++++<<
]>++>+++++>,>++++++++[-<--
---->]>+<<[[->+<<.>]>>[->+
<<<<<.>>>>]>++[-<+>]<<[-<+
<.>>]<-<<[-<+>]>[-<+>]<<[-
>>+<<]++++++++++.[-]>>>]++
>>---[<<[->+<<.>]>>-[->+<<
<<<.>>>>]>--[-<+>]<<[-<+<.
>>]<+<<[-<+>]>[-<+>]<<[->>
+<<]++++++++++.[-]>>>>>+]

Looks a lot readable than java, and probably faster too
>>
>>54967950
but whats the purpose though?

you're not going to use brainfuck in your job
>>
>>54967957
I don't use java in my job either
>>
I'm a noob, is it okay to use Microsoft visual studio?
>>
>>54967957
Shits and gigs
>>
>>54967900
It's a friend of mine, her instagram is locked unfortunately :(

    static int Levenshtein (String a, String b){
int i = 0;
if (a.length() > b.length()) {
for(int c=0; c<b.length()-1;c++){
if(a.charAt(c)!=b.charAt(c)){
i++;
}
}
i += a.length() - b.length();
}
return i;
}
>>
>>54967995
Of course, I'd recommend getting setup with this slightly modified version though
https://www.gentoo.org/downloads/
>>
>>54967999
int blen = b.length() - 1;
int i = a.length() + 1 - blen;
if (a.length() > b.length())
for(int c=0; c < blen ;c++)
i += (a.charAt(c) != b.charAt(c));
return i;
>>
>>54967900
Or are we talking about the redhead?
>>
>>54967999
>It's a friend of mine

so you're from sweden then. nice
>>
>>54968092
whoops, meant
if (a.length() > (blen + 1))
>>
>>54968092
I doubt that java converts booleans to integars
>>
File: 1451346645505.gif (1 MB, 268x274) Image search: [Google]
1451346645505.gif
1 MB, 268x274
>OCaml doesn't have an immediate unsigned integer type
>>
>>54968154
OCaml doesn't even have ad-hoc polymorphism
>>
>>54964916
Are you intellectually challenged?
>>
Shit language:
int x;
uint x;

Good language:

int { > 0 } x;
>>
File: HUNYr7A.jpg (738 KB, 1920x1280) Image search: [Google]
HUNYr7A.jpg
738 KB, 1920x1280
>>54968102
I see your redhead and raise you a pair of cowtits
>>
>>54968399
are you?
>>
>>54968445
sauce?
>>
>>54968442
Best language:
nat x;
>>
>>54968515
trashman
>>
>>54968445
>>
>>54968445
>the pics and vid that come up on reverse image search
N O G F
O
G
F
>>
>>54968511
Natalie Austin
>>
>>54968687
and that's how dpt died.
everyone went to watch porn and masturbate, lel
>>
>>54969213
yeah whenever someone posts a nice pic /dpt/ tends to get quiet for a while
>>
>>54969213
It's Pi AM you faggot
>>
>>54969259
How's France
>>
Is SQL allowed in here?
How do i display columns from two tables but their foreign keys are referenced in another table?
>>
>>54969213

Not me. White women are gross.
>>
>>54969340
>Is SQL allowed in here?
no
>>
>>54969351
Faggot, white women are the best
>>
function fizzBuzz(count) {
for (let i = 0; i < count; ++i) {
const result = (i % 3 ? '' : 'Fizz') + (i % 5 ? '' : 'Buzz') || i;
console.log(result);
}
}
>>
>>54969411

Wrong.
>>
>>54969442

look guys i posted a memebuzz :^))
>>
>>54969580
Treat FizzBuzz with respect or GTFO
>>
Hey I've just decided to get into coding/programming and I'm starting with Free Code Camp.

Are the certificates shown in the very beginning at all relevant to the industry?

Is it a good tool for learning?
I won't be able to take any college courses for about a year so I just want to try learning off the internet.
>>
>>54969625
honestly, I think it should be better to learn from books. a good website to get them is http://it-ebooks.info/ , but usually you can find any book related to programming by simply googling the name
>>
File: text space tactics 1.png (10 KB, 558x180) Image search: [Google]
text space tactics 1.png
10 KB, 558x180
the text space tactics sim rises
>>
>>54966834
tbqh
let fact n =
let rec x i acc :bigint=
match i with
| 0 | 1 -> acc
| _ -> x (i-1) (acc * bigint(i))
x n bigint.One


> fact 1000;;
Real: 00:00:00.000, CPU: 00:00:00.000, GC gen0: 0, gen1: 0, gen2: 0

> fact 10000;;
Real: 00:00:00.073, CPU: 00:00:00.078, GC gen0: 25, gen1: 1, gen2: 0
>>
File: 1462825638517.jpg (525 KB, 1200x1600) Image search: [Google]
1462825638517.jpg
525 KB, 1200x1600
I'm an above-average, self-taught C++ programmer with a stats degree looking to get a programming job with no direct programming experience.

Would some anons kindly give me job titles or niches I should search for - I'm particularly interested in learning how to build, maintain & test a large C++ application, Qt user interfaces would be a plus, some sexy socket stuff would be a bonus too. I basically want to be involved in it all but mainly using C++ on GNU+Linux.
>>
>>54970045
stats degree makes me think you should try to cash in on the big data meme
>>
>>54970045
look for financial businesses/betting/real data shit
these ones usually use c++ meme
>>
c, c++ and java is all I need right?
>>
>>54970254
yes
>>
>>54970254
if you know C++ you can learn java pretty quickly. they're extremely similar. same for the other way around
>>
>>54970290
I should learn in the same order too?
>>
>>54970290
this
>>
>>54970304
java -> C++ -> C
or
C++ -> java/C

i don't recommend starting with C because it teaches you bad habits (programming in C is not the same as programming in C++ or java) and can be a huge time sink with the language lawyering
>>
File: 1462791268280.jpg (429 KB, 654x726) Image search: [Google]
1462791268280.jpg
429 KB, 654x726
>>54970152
forgot to mention I don't really care about money. I don't spend much.

>>54970183
I was a trader. I hate the industry, it's all evil and built on lying to stupid people like people on /biz/.

I'm really looking to get some real experience underneath some experienced C++ developers who know their shit, I just don't really know where to look.
>>
>>54970304
at my university we had our intro course in java, then my first data structures course was in C++, and my second data structures was in java, and now i'm piddling around with C++ again. i'd say learn a little bit of C++ w/o OOP to get started since it's a little bit more hand-holding as an intro language, then learn about low level stuff like threads and such with C, then learn OOP with C++
>>
>>54970254
you one family, you know the other
it's not really hard to switch languages
>>
>>54970329
>not C first
>>
>>54970329
I'm familiar with general programming concepts
C shouldn't be hard then?
All that draws me to C is pointers, speed, and memory management.

>>54970341
wait, c++ has oop?
it heard it was just C 2.0, with templates or something
then really all I actually need is C and C++

I'll put java in the "I have to learn it because it's abundant" list
>>
>>54970394
C++ has OOP it formed the basis for the design of java, java is a simplified C++
>>
Can you believe it, guys? Clinton won which guarantees a Trump presidency.

Programming will be great again.
>>
File: trump h1b.png (83 KB, 591x473) Image search: [Google]
trump h1b.png
83 KB, 591x473
>>54970535
feels good man though i think bernie would've been easier to beat. he was too openly communist when he was younger
>>
File: Screenshot_2016-06-07_22-53-08.png (9 KB, 429x216) Image search: [Google]
Screenshot_2016-06-07_22-53-08.png
9 KB, 429x216
>>54970535
>b-but Bernie was going to make a comeback in California!!!!
>>
>>54970617
Shit, that's just superdelegates.
Whatever, my point still stands
>>
File: 1457909535360.jpg (37 KB, 640x437) Image search: [Google]
1457909535360.jpg
37 KB, 640x437
>work for video player company
>watching pr0n
>using our player
>oh shit
>discover bug

should i bring it up at standup tomorrow?
>>
>>54970696
yes. come on then
>>
>>54970696
ok
is this Plex?
>>
>>54970696
try to replicate bug with sfw vid, k family
>>
i=0
for link in links:
move(links[i])
i+=1


does python have some attribute for the link variable I created that removes the need for incrementing i?
>>
any people knowledgeable about geometry? i have a game with 3D space and i want to be able to give instructions to an entity on what direction to move. how should i go about this? i'm using C++. if there's a convention that exists i'd like to try to follow it. do i pass it 4 values, 3 between 0 and 360 for x and y and z and the last for the distance? how do i go about converting that into an ending location? is there a formula that would be helpful?
>>
>>54970831
You should be able to use just link
>>
>>54970832
maybe you had better start in 2d, eh? Then work your way up
>>
File: poh8_lp_contents1_logo.png (125 KB, 508x257) Image search: [Google]
poh8_lp_contents1_logo.png
125 KB, 508x257
https://paiza.jp/poh/hatsukoi

It's time for another contest.
>>
>>54970869
oh... yes in that instance.

I mean like this:
i=0
for link in links:
links[i]+=i
i+=1


I want to keep my position in the array without using a separate variable (i in this case)
just seems really hacky to use i
>>
>>54970871
how do i do it in 2d? i can just leave z to 0 for now. is the angle idea the right way?
>>
>>54970832
Use vectors
>>
>>54970897
i know little about geometry but this seems right from the wikipedia page. going along the x axis 3 units would be (1, 0, 0, 3) from what i understand. a lot easier than what i was thinking. i can already anticipate what the math will be like for the ending location. thanks
>>
>>54968140
Everything is an integer in the JVM.
>>
>>54970962
Learn some more about vector geometry
3*(1,0,0) is (3, 0, 0)
>>
>>54970982
are longs integers? didn't think so
>>
>>54971001
Two integers on the stack instead of one.
>>
>>54971001
Welllllll, if we wanna get real technical, everything is an integer in a computer
>>
>>54970962
>>54970989
And with vector geometry you can also represent points, e.g. the origin (0,0,0)
So to travel 3 units along the unit* vector (1, 0, 0), from the origin, is
(0,0,0) + 3 * (1,0,0)
When multiplying a vector with a single number (a scalar), multiply every element - e.g. L * (x,y,z) = (L*x, L*y, L*z)
You can't add a vector to a scalar, but you can add two vectors
(A,B,C) + (X,Y,Z) = (A+X, B+Y, C+Z)

(0,0,0) + 3*(1,0,0) = (0,0,0) + (3,0,0) = (3+0, 0+0, 0+0) = (3,0,0)

*unit vector means it has a length of 1
*the length of a vector is sqrt(x^2 + y^2 + z^2)
*you can calculate the unit vector by dividing by the length, i.e. (x/len, y/len, z/len)
*the unit vector can be thought of the direction
>>
C tards

what is the fastest code to compute an array for the factorial from 1 to 10,000

example this is 1 to 10
[1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800]


wanna see it go against rust and haskell
>>
>>54970962
if your starting point in 1 dimension is 0, and the translation vector is 1, you have 0+1=1

if your starting point in 2 dimensions is (1,2) and the translation vector is (3,4), you have (1+3,2+4)=(4,6)

etc
>>
>>54971023
>>54971089
it's too late to digest that but i'll read it tomorrow after work and try to make a function out of it. text based space tactics is NOW. thanks
>>
>>54971089
>>54971023
Oh lol I remember where I learned this

you learn this in your first physics class of college
I sortof stamped that out of my memory but whoever the original guy is you need to actually learn how to do vector multiplication properly if you want to do this.

Because it's quite counter-intuitive iirc.
>>
>>54971079
>C tards
>do my homework!
>>
>>54971111
>>54971124

ab indicates a * b
a(x,y,z) indicates a * (x,y,z)

a(x,y,z) = (ax, ay, az)
(x,y,z)/a = (1/a)xyz =
(x/a, y/a, z/a)


(x,y,z) + (a,b,c) = (x + a, y + b, z + c)
(x,y,z) - (a,b,c) = (x,y,z) + -1(a,b,c)
= (x - a, y - b, z - c)

|(x,y,z)| = sqrt (x*x + y*y + z*z)

unit (x,y,z) = (x,y,z) / |(x,y,z)|
= [let l = sqrt(x*x + y*y + z*z) in ; (x / l, y / l, z / l) ]

|unit (x,y,z)| = 1

|V| where V is a vector is the length of the vector
unit V is the direction of the vector
>>
>>54971168
these all apply for any length vector
>>
>>54971079
you're going to need arbitrary precision for 10,000!
>>
>>54971199
well bigint is available in other languages
>>
>>54971079
Use an approximation.
>>
>>54971168
i can't read it stop you're just posting latin
>>54971124
i don't think it'll be THAT hard but if it is then i can just make the user give directional commands by a point and the distance to be traveled in that points direction. ie if the user enters 0 0 0 5 as the movement command, it won't stay in the current position. it'll move 5 units closer to the origin from wherever it is. and then maybe add a vector-based movement command mode later
>>
>>54971230
if you can't read the most basic linear mathematics (addition + subtraction) you can't do graphics
>>
>>54971218
Actually it doesn't take that long at all. 10000! takes <5ms on my shitty computer using GMP.
>>
>>54971284
how long does it take for 1 to 10,000 with GMP?
>>
>>54971245
i'm not doing graphics. it's a text based 3D space tactics game>>54969975
also i said that jokingly because i'm tired and i'm not going to put it to use tonight, like i said before. but i get that i asked if there was anyone good at geometry in here and you're the physics major so you perked up and thought oh this is my time to shine better call people plebs for not wanting to read my text-wall of math formulas
>>
>>54971245
also you're a faggot
>>
>>54971309
I'm not a physics major
I learned vector maths in like year 10 or something in standard mathematics
That's age 14-15
>>
>>54971284
Well the guy said the fastest and he never said anything about being on the dot accurate so an approximation is gonna be faster than your exact calculation.
>>
>>54971321
reference >>54971320
>>
>>54971320 >>54971335
Calling someone a faggot doesn't make up for literally being a retard. Not understanding vector maths is inexcusable for any adult man
>>
>>54971079
#include <stdio.h>
#include <gmp.h>

mpz_t facts[10001];
int main()
{
int i;
mpz_init_set_ui(facts[0], 1);
for (i = 1; i <= 10000; i++) {
mpz_mul_ui(facts[i], facts[i-1], i);
}

return 0;
}



./a.out  0.03s user 0.04s system 96% cpu 0.079 total


GCC with no optimizations enabled.
>>
>>54971351
Fuck, that code's messed up, here's the correct code:

#include <stdio.h>
#include <gmp.h>

mpz_t facts[10001];
int main()
{
int i;
mpz_init_set_ui(facts[0], 1);
for (i = 1; i <= 10000; i++) {
mpz_init_set_ui(facts[i], 1);
mpz_mul_ui(facts[i], facts[i-1], i);
}

return 0;
}
>>
>>54971351
>>54971376
Haskell can do 10000! quite quickly but I imagine building the list would be slow
>>
>>54971395
The actual time is this:

./a.out  0.02s user 0.03s system 93% cpu 0.039 total


For some reason, not initializing the mpz_t's was slowing it down.
>>
>>54971408
I don't even know if I have a way of forcing haskell to evaluate it and then do nothing with it, and I have no idea as to whether or not haskell has evaluated the list before it's started printing or not


Haskell is really bad for profiling
>>
>>54971427
Do you have Rust's results?
>>
>>54971434
No, I don't use Rust
>>
>>54971434
rust can just use gmp bindings easily
>>
>>54971444
Does Rust not have a bigint built in? That surprises me
>>
>>54971444
True

I did it in ruby too, just to see how it compares:
facts = [1]
1.upto(10001).each do |num|
facts[num] = facts[num-1] * num
end


ruby facts.rb  0.12s user 0.03s system 94% cpu 0.154 total

Much better than I expected.
>>
File: FAG DETECTED WEEOO WEEOO.gif (126 KB, 720x480) Image search: [Google]
FAG DETECTED WEEOO WEEOO.gif
126 KB, 720x480
>>54971347
your wall of text included "ab indicates a * b" - that's like saying " = indicates equals" - and the distributive property as the first 2 things. pardon me for not feeling like reading the rest and trying to make a joke out why i don't want you to continue bc i'm tired instead of telling you the real reason i want you to stop which is because you're being a fag. no offense
>>
>>54971455
it does, don't know if it is better than gmp type solution
>>
>>54971464
btw, ruby has arbirary precision ints, if you did puts facts[-1] it would print out 10000!
>>
>>54971466
Yeah, I had anticipated you were retarded and decided to point out ab = a*b in case you were also unaware of that

By the way, this might seem off topic but I'm sure you agree with ALL users here that the age limit is completely justified
>>
>>54971466
Oh, and
a(x,y,z) = a*(x,y,z)
a*(x,y,z) = (a*x, a*y, a*z)
is not the distributive property

, is not +
>>
>>54971489
the condescension was apparent. you seem like a middle aged guy who angrily jerks himself off at how much intellectually superior to his coworkers he is and yet doesn't get promoted, because everyone at works thinks he's a massive faggot up his own ass
>>
File: v&.png (35 KB, 475x122) Image search: [Google]
v&.png
35 KB, 475x122
>>54971466
>pardon me for not feeling like reading the rest and trying to make a joke out why i don't want you to continue bc i'm tired instead of telling you the real reason i want you to stop which is because you're being a fag. no offense

>>54971489
>By the way, this might seem off topic but I'm sure you agree with ALL users here that the age limit is completely justified

You're right, he's totally underage
>>
File: KYS KYS KYS.gif (48 KB, 2034x1491) Image search: [Google]
KYS KYS KYS.gif
48 KB, 2034x1491
>>54971658
kys
>>
>>54971658
>implying
He could just be American
>>
>>54971308
probably not much longer you're just storing the results in an array
>>
>>54971323
it's completely unreasonable to assume that that you're allowed to approximate integer results
>>
golang:
[De cero] [Vista previa]                                                                                                                      1,1           Todo
package main

import (
"fmt"
"math/big"
)

func main() {
var facts [10001]*big.Int
facts[0] = big.NewInt(1)
for i := int64(1); i <= 10000; i++ {
big_i := big.NewInt(i)
facts[i] = big.NewInt(1)
facts[i].Mul(facts[i-1], big_i)
}
fmt.Printf("%s", facts[10000].Text(10))
}
>>
>>54971710
Jesus christ that looks horrible
>>
>>54971710
>[De cero] [Vista previa] 1,1 Todo
oops, ignore this

>>54971713
kek
>>
>>54971687
this is an american website. i'd tell you to go to a british programming discussion website but i don't know of any so i guess i'll just tell you to fuck off
>>
>>54971723
I'm not British
>>
>>54971728
thanks for sharing
Thread replies: 255
Thread images: 35

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.