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

File: K&R c.png (1MB, 1000x1400px) Image search: [Google]
K&R c.png
1MB, 1000x1400px
old thread: >>61882452

What are you working on, /g/?
>>
>>61890565
>What are you working on, /g/?
your mom's anus

also, rolling
>>
what scheme interpreter should I use for sicp? drracket?
>>
>wanna sort my 1000 astolfo pics
>shell script takes longer than doing it manually
why is bash so shit?
#!/usr/bin/env bash

magic=("JPEG" "PNG" "GIF")
ext=("jpg" "png" "gif")
idx=0
for name in *
do
type="$(file $name)"
i=0
n_ext=
for j in "${magic[@]}"
do
if echo "$type" | grep -i "${magic[$i]}" > /dev/null
then
n_ext="${ext[$i]}"
fi
i=$((i + 1))
done
mv -v "$name" "astolfo_00$idx.$n_ext"
idx=$((idx + 1))
done
>>
what compiler did people use before gcc, clang and msvc?
>>
>>61890565
Learn Go:
https://tour.golang.org
https://www.golang-book.com
>>
>>61890565
>>61890446
That's nothing.
Watch:
⍝ Karmarkar's affine scaling algorithm
∇ x ← affine (A b c g); v X V T M i
x←0⍴⍨⍴c⋄T←⍉A⋄M←-A
→0/⍨∧/0≤V←M+.×X←c+.×⍨⌹T+.×A÷[1]×⍨v←b-A+.×x⋄x-←i←X×g×⌈/(V<0)/v÷V⋄→2/⍨∨/⎕CT≤∣i
>>
File: comfy.png (315KB, 414x516px) Image search: [Google]
comfy.png
315KB, 414x516px
>>61890631
>tfw had "fate" folder
>Apo airs
>over 80% of the images are now Astolfo
>>
>>61890634
pcc or borland or one of many others
>>
>>61890631
this can be done in one line of

bash + awk
>>
>>61890634
Borland. For instance. I have a feeling there were more diversity back then.
But that's not older than gcc.
>>
>>61890686
>know bash
>don't know awk
>spend more time learning awk than sorting pics by hand
>>
>>61890717
>has anime shit
>is not a good programmer

imposter
>>
>>61890672
Post magnet link
>>
>>61890565
i'm painting my toenails :3c
>>
>>61890631
ext=("jpg" "png" "gif")
idx=0
for name in *
do
type="$(file $name)"
i=0
n_ext=
for j in "${magic[@]}"
do
if echo "$type" | grep -i "${magic[$i]}" > /dev/null


wtf? why not simply run something like:
for ext in "jpg" "png" "gif"; do
# process files here
done

also, learn how to use ${var##ext} and ${var%%ext}
>>
>>61890820
># process files here
err, I meant,
for ext in "jpg" "png" "gif"; do
for file in *.$ext; do
# process files here
done
done
>>
File: old_hag_langs.png (173KB, 600x355px) Image search: [Google]
old_hag_langs.png
173KB, 600x355px
>learn (((Go)))
>learn """C for retards"""
>>
I'm confused, what am I missing in the print_arr?
#include <iostream>
#include <algorithm>
using namespace std;

//only prints the first two elements

void print_arr(int arr[])
{
for (int i = 0; i < sizeof (arr) / sizeof (arr[0]); i++) {
cout << arr[i] << '\t';
}
cout << endl;
}

int main()
{
int myints[] = {32, 71, 12, 45, 26, 80, 53, 33};
print_arr(myints);

//prints every elements
int scores[] = {84, 92, 76, 81, 56};
for (int i = 0; i < sizeof (scores) / sizeof (scores[0]); i++)
cout << scores[i] << '\t';

return 0;
}
>>
>>61890965
>c++
>not using vector
>>
>>61890965
What error messages are you getting?
>>
>>61890777
https://mega.nz/fm/4HxBjTIA
>>
>>61891022
this
why do people still use fucking c arrays in c++
>>
>>61891048
The function is printing only two elements, not all of them
>>
>>61890965
>sizeof (arr)
arr is a memory address ie an integer
>>
Why do I still need to force myself to code after a year? Is programming just not for me or should I find some interesting stuff to make?
>>
>>61891117
what's your job?
>>
>>61891108
So you are saying that I should pass the pointer to the array and the size of the array to the function?
>>
>>61891108
This works for VLAs, a GNU C and C99 feature.
sizeof arr / sizeof *arr will give you the length of a variable length array
>>
I don't want to touch imperative languages anymore.
>>
>>61891057
>Please log in
>>
>>61891128
IT guy. I don't program at work, though.
>>
>>61890965
your parameter arr decays to a pointer, you loose the size information. sizeof(arr) will give the size of a pointer on your architecture in bytes (which is probably 8).

Either give an additional parameter with the size of the array (C style), or use a vectory<int> for myints and pass it by const& to print_arr.
You could then use a C++11 range-for loop to iterate over the elements.
>>
>>61891170
Fized, thanks
>>
>>61891226
I think you could write int arr[max_index] or int arr[static max_index], but you might have to swap the two arguments.
>>
i'm writting a 4chan scrapper (using the 4chan API) and when a thread has less than 200 replies it works fine but more than and just throws an error
>>
>>61891141
you're right but i think when it's sent over to the function is loses that information
>>
>>61890881
for file in *.{jpg,png,gif}
>>
>>61891170
>tfw that happens even if you pass a pointer to the array

void function(int **p){
printf("sizeof v inside function = %d\n", sizeof(*p)); //prints 8
}

int main(){
int v[20];
printf("size of v = %d\n", sizeof(v)); //prints 80
function(&v);
return 0;
}
>>
>>61891082
Moronic instructors can't tell the difference between C and C++ and always teach legacy C bullshit in the "C++" classes
>>
>>61891313
I think lots of legacy C++ libraries use C style arrays
>>
>>61891150
stay strong brother

one day
>>
>>61891330
You definitely need to know them eventually but you should be learning vectors first since that's what you'll use 90% of the time, especially for trivial shit like the other poster is having trouble with
>>
>>61891155
yeah wrong link, my bad
https://mega.nz/#F!YKImgTxJ!sTA246kM_hrjx1GegY_pKw
>>
>>61891364
Thanks, faggot
>>
>>61891287
I know, the idea would be for him to differentiate jpgs, pngs, etc, without calling 'file'.
calling external programs in bash is expensive...
>>
>>61891082
harm minimization when forced to teach a course in C++
>>
>>61890565
making a script that takes a music album in a youtube video and then slices it according to the video description or a text file. Will try to make metadata right if I have time.
>>
>>61891401
Why would he need to? He's just bulk renaming, mv to $(printf "astolfo_%05d.%s" ${idx} ${file##*.})
>>
>>61891505
just download the real thing
youtube audio quality is compressed to hell
>>
I know basic programming: conditions, loops, variables, functions...
Would it be better to start with K&R or SICP? I've started reading the former and while it's a good resource I don't enjoy C very much.
>>
>>61891524
i download my musics from youtube


fite me
>>
>>61891524
I am not autistic enough / my hearing are way too damaged / I buy the cheapest headphones to even notice the difference.
>>
>>61891262
>but you might have to swap the order of the arguments
Wow. I hope not. That'd be absolutely retarded.
>>
File: duck.gif (23KB, 60x95px) Image search: [Google]
duck.gif
23KB, 60x95px
>>61891548
>>61891572
why did you feel your terrible opinions on music listening were so important that you filled out two captchas to reply to me on a sunday night?
>>
>>61891520
because in the script, he's keeping track of the format, when it's not needded

>mv to $(printf "astolfo_%05d.%s" ${idx} ${file##*.})
which is why I said he should learn how to use ${var##}...

>>61891505
youtube-dl -f 140 youtube.com/watch?list=...
>>
>>61891596
>night
it's afternoon here, euro turd
>>
For real guys what does this mean?

>The next interview will be a general chat about software engineering, theory and practice, and a couple programming exercises

I know that the programming exercises will be the usual CS questions, but what are questions on SE theory and practice? Like.. OOP quiz? Open-ended questions about designing some large scale system? Parallelism? Planning and UML diagrams? What happens when you type google.com in your browser? Networking? Floating point? I googled books on this, and judging by the contents of pic related I have no idea what to expect, and I don't have time to revise all CS curriculum and I'd like to focus on whatever it's expected
>>
>>61891610
go back to work goyim
>>
File: 2017-08-14-004930_474x278_scrot.png (35KB, 474x278px) Image search: [Google]
2017-08-14-004930_474x278_scrot.png
35KB, 474x278px
>>61891618
Lost pic
>>
>>61891618
better know your binary search trees by heart
>>
>>61891596
got no life, and bored as hell

(third captcha)
>>
>>61891618
Could be anything. We don't have context.
But it's likely about understanding of priorities in software development primarily. But leaving a good impression is always good. So present what you know.
>>
>>61891276
>>61891276
>>61891276
BUMP
>>
>>61891276
>>61891695
Bump?
Just debug it. Why would anyone have anything to say to this?
>>
>>61890631
Scripting isn't programming. Please delete this comment immediately
>>
>>61891695
Nowhere near enough information to make a good assessment of the problem.

For starters: what error is being thrown? Post the function it occurs in and point out the line.
>>
>>61891751
>comment
hmmmmmmmmmmmmmmmm relly made me think...............
>>
>>61891630
goyim is plural
>>
>>61891782
(((You))) would know.
>>
>>61890899
>implying Fortran or Pascal would ever let C near them
>C programmers desperately try to pretend they're one of us
Fortran programmer here. We all hate C babies. You're not cool. You can barely even manage basic math problems, you fucking pajeets.
>>
>>implying C or Pascal would ever let Fortran near them
>Fortran programmers desperately try to pretend they're one of us
C programmer here. We all hate Fortran babies. You're not cool. You can barely even manage basic math problems, you fucking pajeets.
>>
>>61891767
Sarcasm isn't programming either. Please delete this comment immediately
>>
>>61891999
Never reply to me again unless you're contributing to the thread.
>>
>>61891999
>comment
what did xhe mean by this????
>>
>>61892042
>xhe
fucking XHITLORD
>>
Learning rust.
Type safety is really busting my nuts, but it's fun.

Should have stuck with Nim for the project I'm working on though.
>>
>i-if I use BSD or MIT or Apache license then m-maybe a big corporation that uses my library will consider giving me a job
Imagine being this cucked.
>>
>>61892299
>use GPL license
>corporations take your code anyway and get away with it
""copyleft"" is a joke, either release your code in real freedom or keep it proprietary
>>
Found out that Mega.nz has a command line client, trying to think of a project or anything to use it for but can't think of shit - suppose it's only actually useful for large data deployments or something
>>
>>61892318
who said that?
>>
>>61892318
What the fuck even is the different between these licenses. How do I choose one for my project, or should I just always choose GPL?
Wait which fucking GPL should I use?
Christ I just want to write code and have people know I wrote it, I don't really give a fuck about copyrights
>>
>>61892406
MIT
>>
>>61892406
If you ask me you should use AGPLv3+ for everything.
>>
>>61891678
>understanding of priorities in software development primarily.

what do you mean?
>>
File: smug.jpg (36KB, 511x509px) Image search: [Google]
smug.jpg
36KB, 511x509px
>>61892318
>implying I even write or share software in the first place
>>
>>61892433
shoo, freeloader

if you want to use my software in a proprietary product then contact me and maybe we can come to an agreement involving you paying me for a separate license
>>
>>61892406
GPL lets people do whatever they want with your code so long as their derivative or distributed version of your project is licenced under the same terms you afforded them. Free access to the source code and it cannot be legally included in a proprietary project.
BSD/MIT licenses let you do whatever the fuck you want and you have no obligation to allow access to your derivative source code or even give credit.
>>
>>61891695
Enjoy your overflows
>>
>>61892072
IDK how reliable Nim is, debugging it will be a massive pain in the ass
>>
>>61890565
Going through Oracle´s Java tutorials.
>>
File: 1495359317161.png (2MB, 1214x1109px) Image search: [Google]
1495359317161.png
2MB, 1214x1109px
Employed Haskell programmer here
>>
>>61892493
?
>>
File: 15026734418.png (513KB, 1214x1109px) Image search: [Google]
15026734418.png
513KB, 1214x1109px
>>61892755
image optimized
>>
>>61892755
I love Haskell!
>>
>>61892755
self employment doesn't count anon.
>>
>>61892433

MIT has no consideration for patents.

You could be using MIT-licensed code that is covered by someone's patent (even the author's) and you would have to pay them if they caught you.
>>
Rate my 10th C++ program, /dpt/
#include <iostream>
#include <utility>
using namespace std;

void print_arr(int rng[], size_t length)
{
for (size_t i = 0; i < length; i++) {
cout << rng[i] << '\t';
}
cout << endl;
}

/*
* Selection sort
*/
void sort_arr(int rng[], size_t length)
{
//declare swap target index, start with 0
size_t swap_at_index = 0;
do {
//find smallest element's index in the rest of the array
size_t smallest_element_index;
for (size_t i = swap_at_index + 1; i < length; i++) {
if (rng[i] < rng[smallest_element_index])
smallest_element_index = i;
}
//swap with target
swap(rng[swap_at_index], rng[smallest_element_index]);
//increase swap target index
swap_at_index++;
} while (length > swap_at_index + 1); //if index == length - 1; break
}

int main()
{
int arr[] = {30, 60, 20, 50, 40, 10};

print_arr(arr, sizeof (arr) / sizeof (arr[0]));
sort_arr(arr, sizeof (arr) / sizeof (arr[0]));
print_arr(arr, sizeof (arr) / sizeof (arr[0]));
return 0;
}
>>
/g/, newfag here. im going through c now. have done marginal python/java/matlab.
current plan: c -> algorithm -> advanced java -> advanced python -> c++ -> machine learning.
will i make it for september career fair? i need to be able to larp as somekind of blockchain/cryptocurrency/machine learning/ai expert fag...
>>
>>61893260
>C
>Java
>C++
>"will i make it for september career fair?"
Which year?
>>
>>61893135
Stallman, stop shilling GPL.
>>
>>61893165
> Iterating with size_t, having a int array.
You're in for buffer overflow m8
>>
>>61893286
this year. im not autistic, and pretty good at talking. thought that if i become "niche" in machine learning it may help
>>
>MFW I live in a software patent free country
>>
>>61893304
Well, I was using sizeof(), which apparently returns size_t. I guess I should just be using int then, but I have a question. In the following snippet I left an uninitialized value, does this mean the compiler might initialize it to a random value? Should I assign it to a null? If so, how? If not, what if the compiler assigns it to a value smaller than any of the elements of the array?
void sort_arr(int rng[], size_t length)
{
//declare swap target index, start with 0
size_t swap_at_index = 0;
do {
//find smallest element's index in the rest of the array
size_t smallest_element_index;
for (size_t i = swap_at_index + 1; i < length; i++) {
if (rng[i] < rng[smallest_element_index])
smallest_element_index = i;
}
//swap with target
swap(rng[swap_at_index], rng[smallest_element_index]);
//increase swap target index
swap_at_index++;
} while (length > swap_at_index + 1); //if index == length - 1; break
}
>>
>>61893304
That use of size_t is fine
>>
>>61892470
I'll just use your code like everybody already does.
>literally only a handful of instances of corporations getting caught stealing GPL code
>even less instances of them getting punished for it
lmao
GPL is cuck license for people who don't want to feel like they're being cucked
>>
>>61891104
its because of pointer decay
void print_arr
is seeing
int arr[]
as
int* arr;

one way common way around this (for using C-style arrays) is to pass the size of the array to the function:
auto print(int arr[], const size_t size) -> void {
for (size_t i = 0; i < size; ++i) {
std::cout << arr[i] << " ";
}
std::cout << std::endl;
}

int main() {
int a[] = {1, 3, 5, 7, 9, 11, 13};
print(a, sizeof a / sizeof a[0]);
return 0;
}


another way would be to use a template, or two (depends on if you want to do something like..) to make a more type-size array
template <typename... T>
constexpr auto make_array(T &&... t) -> std::array<std::common_type_t<T...>, sizeof...(t)> {
return {std::forward<T>(t)...};
}


or, you could use the STL and use an std::array which won't decay to a pointer and provides sane iteration :)
>>
I am to code a c# app which creates Word documents from template and fills it with data. It goes well with Interop, but using a hidden Word application to work with data is such a fucking crap so I have to wrap every block of code into exceptions and checks if the Word is still running. Is there a way to work with Word documents "offline" without starting up Word in background? Probably I will have to support Excel too.
>>
File: museum.gif (1MB, 400x257px) Image search: [Google]
museum.gif
1MB, 400x257px
>>61891912
>Fortran programmer here
for real my dude
>>
>>61893623
Thanks I figured that out. Could you respond to this if you can?>>61893354
>>
>>61891751

>Scripting isn't programming
Categorically wrong.
>>
File: ran's_DMRG.png (1MB, 900x1440px) Image search: [Google]
ran's_DMRG.png
1MB, 900x1440px
>>61891912
Oh cool you use Fortran too? Post your Lancsoz algo.
>>
>>61890565
Trying to revive an old ircII fork, it supports passing off its window management to terminal multiplexers and I'm trying to get dvtm working with it.

It's gonna be comfy as fuck if I ever get it working. I want it to work so badly desu senpaitachi. Everything is set up as it should've worked with tmux and screen but it doesn't work. Just crashes dvtm somehow.

It's supposed to support passing commands to new windows but these either don't output or don't run at all, and I was wrong in assuming that dvtm command in the dvtm environment would try to create a new window which is another issue I need to solve. I don't think it comes with a way to create windows from the command line, which is annoying. I'll integrate a whole fork into the source if I need to though. Nothing's gonna deny me my comfiness.
>>
>>61893626
Sounds like you're in the line of business development hellscape. Do yourself a favor and google a word c# library and an excel c# library. Interop can be useful but is a fucking cancer to deal with.
>>
>>61893698
>Any questions?

Yes. Why is ran so shit?
>>
>>61893728
I googled it for a time, because Interop really sucks sometimes. I'm asking for a good library that anons use.
>>
File: ran_mad.png (159KB, 365x362px) Image search: [Google]
ran_mad.png
159KB, 365x362px
>>61893729
Behave.
>>
>>61890627
DrRacket I've found is pretty good for almost all of your SICP needs.
Just do
 #lang sicp 
(syntax may be wrong, sorry in advance)
and you should be good to go!
>>
File: 1502248454060.png (206KB, 748x639px) Image search: [Google]
1502248454060.png
206KB, 748x639px
I am currently learning C by reading Second Edition The C Programing Language, as I managed to get a physical copy at a cheap book store.

Which compiler do you guys recommend, or should I just use and IDE? Sorry if this comes off as stupid, I am still starting to learn programing and I am used to just doing Java exercises in and IDE. I do really like the language so far, it seems pretty simple.
>>
>>61893781
>>61893698
your waifu a shitsune
>>
>>61893815
I prefer to use Clang for learning since Clang has much more helpful error messages than gcc.
>>
>>61893796
you might as well just use python and import solution
>>
>>61893815
> Sorry if this comes off as stupid
Nah man, compared to all the shitposting here, discussions about compiler discussions are welcome

I would recommend using gcc or clang, but the exercises are relatively simple, so compilers wouldn't really make much of a difference
>>
>>61893772
http://lmgtfy.com/?q=c%23+microsoft+word+library
It was the first result.

I'd go "do the same for Excel" but for some reason EPPlus isn't the top result when "word" is changed to "excel". Use EPPlus for excel documents, but note that it doesn't support .xls/.xlsb files because who the fuck wants to even work with either of those files in 2010. NPOI apparently works with .xls files but that's chinkshit and poorly documented.
>>
What does it mean for me to have a negative pointer?

When I print out the pointer's value (I'm trying to debug something) I get a negative number... Does this mean the pointer is unassigned?
>>
File: only this.png (10KB, 1457x154px) Image search: [Google]
only this.png
10KB, 1457x154px
WNDCLASSA cpp

can someone explain this further?
>>
>>61893847
> npoi
Thats much better
>>
>>61893860
How are you printing it out? What format string are you using?

You're probably formatting it as a signed integer and it's overflowing
>>
>>61893883
Yeah, I am printing it using %d (signed int).

Just looked it up on SO and apparently memory addresses over a certain # will show up as negative. So I guess that's not the problem
>>
>>61893662
I didn't read the whole thread (started at the top) so I was super late.
As for using size_t vs int:
>size_t can store the maximum size of a theoretically possible object of any type
>int is defined as at least 16 bits wide.
ints are signed by default, while size_t are defined to be unsigned.
You should be using size_t for anything related to the size of pointers, data types, or representations of ranges (indices, offsets, etc).

>might initialize it to a random value
From the standard:
>Use of an indeterminate value obtained by default-initializing a non-class variable of any type is undefined behavior (in particular, it may be a trap representation), [...]
It may be random, or it may be 42. Or it could be 12? (It will probably choose something like
ULLONG_MAX
(or whatever the correct climit type is for your platform))
You should always initialize your types, and preferably do it when you declare them.
size_t foo = 0;
(or
size_t foo{0};
) would be a good way of doing so.
>what if the compiler assigns it to a value smaller than any of the elements of the array
I don't understand what you're asking here. If you assign it 0, then that'll be the smallest element (if there are no size-zero elements, then you know you didn't find the smallest element?) And using it as a subscript/index means you'll always start looking at the first item, until you find a larger one.
>>
>>61893868
If you don't give it an HICON. it'll use a system-defined default HICON.

To load an icon you imported/created/whatever with the resource editor:
HICON myIco = LoadIcon(hInstance, MAKEINTRESOURCE(IDC_ICO_FROM_RC));


Win32 does something similar where it defines the default icon as
#define IDI_APPLICATION MAKEINTRESOURCE(32512)


So, passing nullptr / NULL to the WNDCLASS structure will have it choose IDI_APPLICATION for you. Cursors, backgrounds, etc work the same way.
>>
>>61893860
use %p for pointers.
>>
>>61893815
As people have said, clang or GCC are good choices. I would avoid an IDE until you understand how the underlying mechanisms of the IDE work―compiler, linker, etc.

GCC does tend to be a bit more mature than clang, and is typically (though not always) better at optimizing. See pic related; unfortunately, I do not have a copy of the referenced "hyperpoly.cpp".
>>
File: clangvsgcc.png (43KB, 800x600px) Image search: [Google]
clangvsgcc.png
43KB, 800x600px
>>61894002
forgot pic
>>
>>61893796
As I recall, the way #lang sicp displays lists is much harder than just using the Racket language. I would just stick to plain Racket.
>>
File: shame.jpg (35KB, 535x577px) Image search: [Google]
shame.jpg
35KB, 535x577px
>tfw too dumb for haskell
>>
>>61892072

>Type safety is really busting my nuts, but it's fun.
Type safety can be a pain even in C++ sometimes, but it can be worth it. Think about it like this: you are being very explicit and specific about how everything in your program is running. Rust, like C++, is a systems programming language. This has a bit more implications than just "I can run real fast because I have no GC and I run on bare metal." It means, "I can be used in a wide variety of applications, including mission critical programs that cannot tolerate the non-determinism of a garbage collector, or I may need to be the one to decide how memory is allocated in the first place." In such situations, you are the final line in the sand. If things fuck up in your hands, the whole system could crash, people could die, money could be lost, etc... Other programs will likely be depending on you to function. So it's nice to have something there to make sure you're doing exactly what you want, and not making some simple mistake.
>>
I'm going to community college right now but I'm taking classes to become a teacher. Sometimes I feel like I may be better of switching to something CS related but I feel like I'd rather do something I would enjoy and make a little bit less. Am I stupid?
>>
>>61891596
uhm, you do realize thats a goose ye?
>>
>>61894051
Nobody is too dumb for Haskell.

>>61894081
Ruby, what happened to you?
>>
Well, bubble sort was pretty easy, IDK why people call it harder than selection sort
#include <iostream>
#include <utility>
using namespace std;

void print_arr(int rng[], int len)
{
for (int i = 0; i < len; i++) {
cout << rng[i] << '\t';
}
cout << endl;
}

void bubble_sort(int rng[], int len)
{
int count = 0;
do {
for (int i = 0, j = 1; i < len - 1, j < len; i++, j++) {
if (rng[i] > rng[j]) {
swap(rng[i], rng[j]);
}
}
count++;
} while (count < len);

}

int main()
{
const int length(9);
int array[length] = {6, 3, 2, 9, 7, 1, 5, 4, 8};

print_arr(array, sizeof (array) / sizeof (*array));
bubble_sort(array, sizeof (array) / sizeof (*array));
print_arr(array, sizeof (array) / sizeof (*array));
return 0;
}
>>
>>61894111
Do you like math? CS is more about applied math than about computers.
>>
>>61894144
I'm not really sure. I remember finding algebra and geometry enjoyable in school but I eventually dropped out (hence why I have to take a beginning algebra course). Pretty much, I want to choose a career that is enjoyable for me, but I also don't want to be poor. I want to be well off in the sense that I can afford what I want. Growing up I never really had that.
>>
>>61894131
>use length
>pass sizeof (array) / sizeof (*array)
>>
>>61894182
It's more generic approach I want to get used to
>>
>>61894131
you should probably pass size_t to print_arr, instead of int.

what if your array's size can't be expressed in 16 bits? and being that its a signed int, how about about 15 bits?
>>
>>61894130
>Nobody is too dumb for Haskell.
then give me a resource that isn't learn you an autism because my brain hurts figuring it out
>>
File: trashkell_on_suicide_watch.png (448KB, 580x1500px) Image search: [Google]
trashkell_on_suicide_watch.png
448KB, 580x1500px
>>61894051
No such thing.
>>
>>61894254
I've heard good things about haskellbook but it's not free. https://github.com/bitemyapp/learnhaskell has a list of free resources.
>>
>>61890565

How do i convert M-x shell to an elisp function I can place in my init?
>>
>>61894130

What'chu mean what happened to me?
>>
>>61894243
Thanks
#include <iostream>
#include <utility>
using namespace std;

void print_arr(int rng[], int len)
{
for (int i = 0; i < len; i++) {
cout << rng[i] << '\t';
}
cout << endl;
}

void bubble_sort(int rng[], size_t len)
{
int swap_happened = 0;
size_t count = 0;
size_t sorted_array_index = 0;
do {
swap_happened = 0;
for (int i = 0, j = 1; i < len - 1 - sorted_array_index,
j < len - sorted_array_index; i++, j++) {
if (rng[i] > rng[j]) {
swap(rng[i], rng[j]);
swap_happened = 1;
}
}
count++;
sorted_array_index++;
if (swap_happened == 0) break;
} while (count < len);

}

int main()
{
const int length(9);
int array[length] = {6, 3, 2, 9, 7, 1, 5, 4, 8};

print_arr(array, sizeof (array) / sizeof (*array));
bubble_sort(array, sizeof (array) / sizeof (*array));
print_arr(array, sizeof (array) / sizeof (*array));
return 0;
}
>>
>>61894322
You, praising static typing? That doesn't typecheck, Ruby.
>>
>>61894169
So should I switch my intended career path for more money?
>>
>>61894297
>http://www.seas.upenn.edu/%7Ecis194/spring13/lectures.html
i'll probably try this one, thanks senpai
>>
>>61894342
Maybe? I have no idea anon. More money certainly isn't guaranteed.

Do you enjoy programming? Could you cope with sitting at a desk for a dozen hours, typing until your body aches and your mind is exhausted, dealing with last-minute changes from an idiot client and/or trying to track down an inscrutable bug?
>>
>>61894196
Alright then.
    int array[] = {6, 3, 2, 9, 7, 1, 5, 4, 8};
size_t len = sizeof (array) / sizeof (*array);

print_arr(array, len);
bubble_sort(array, len);
print_arr(array, len);

Now the variable is useful.
>>
>>61894361
I mean I feel like I'm going to deal with annoying shit regardless of what career path I choose. I'm just worried that I'll finish my degree program and realize that I'm just going to always be poor because of a shitty choice I made. I guess I'm scared of becoming like the rest of my family.
>>
File: merge_sort_with_without.png (157KB, 963x901px) Image search: [Google]
merge_sort_with_without.png
157KB, 963x901px
Why do pointers make programming so much simpler?
>>
>>61894340

It's a systems language. You can't NOT have static typing in a systems language. Dynamic languages have their own advantages, but they have completely different use cases.

>>61894430

Neither of these are "without pointers".
>>
>>61894493
what about a lisp machine?
>>
>>61894493
>You can't NOT have static typing in a systems language.

>he doesn't program in B
>>
>>61894493
Yeah, I modified the left a bit to use more pointers. My point was to compare some of the logic, for instance in merge_sort, it is much more logically sound because you don't need to keep track of left and right with integers, you can just modify to pointer and treat it as a smaller array.
>>
>>61894511

Lisp machines are dead.

>>61894529

B is untyped. It's also designed for machines where the size of a byte is 9 bits.
>>
>>61894626
Lisp machines aren't dead, they are just taking an absence until people realize that forgetting out them was a mistake.
>>
>>61890565
>Sign up for the BS program in Comp Sci
>Somehow got automatically set in the system as a BA in Comp sci

I heard having a BS (because of the additional math) makes you a better candidate for jobs over a BA, how true is this? Anyone wanna share their own experience post college?

I'm a transfer student with no internships and I'm already worried enough about finding work post-grad.
>>
>fell for the C meme.
Great, thanks /g/.
>>
>>61894678
Now do a Lisp and Haskell.
>>
>>61894541
>>61894430
While I can sort of understand the laziness in not wanting to do it, I can't help but be bothered by the function naming conventions that aren't fully descriptive of what is actually happening inside the functions.

The "merge" function does more than simply merge 2 blocks of data, while "merge_sort" doesn't do the sorting itself, but relies on merge to do it.
>>
ahhh CPP is so comfy
all these safe containers and iterators and real strings, it's like being surrounded by really comfy blankets

And then you can jump back into familiar c territory at any time also it's just very nice
>>
File: 1499339801283.jpg (54KB, 240x320px) Image search: [Google]
1499339801283.jpg
54KB, 240x320px
>>61894678
>C
>meme
>>
>>61894717
The functions do exactly what they say, I don't know what you are thinking. The function merge_sort does exactly what it says, it recursively merge_sorts each half of the array, while the merge function merges both halves together again.
>>
>>61893626
>Progmatically generating a word document
Hahahahhhaha
>>
>>61894743
Uh, look at the bottom half of the "merge" function. Unless my eyes are deceiving me, "merge" also contains the code that sorts the contents of *left and *right into *arr, starting with the line
"while (rlen + llen > 0 {"
. That, imo, is more than merely "merging".
>>
>>61894821
Well if you knew anything about merge sort, you would know that both the left and right are sorted and all merge does is merge both halves so that order is maintained.
>>
>>61890565
How do I avoid stack overflow? The literal makes me angry in every sense
>>
>>61894877

typically languages and frameworks have thorough documentation you can read, but that requires actually investing time in something
>>
Let's be honest here, the new design looks far better than the older one. But the autistic main dev won't agree
>>
>>61894745
Don't say it like it is something bad
>>
>>61894990
I don't know what this is but the old one looks better to me. The only thing I'd change is a tiny bit of extra spacing between sections and maybe the border.
>>
>>61895117
You do realize that looks like ant's penis in HDPi, right??
>>
>>61894047
Racket may have slight inconcistencies with SICP. It uses a lot of Scheme standards (many Racket developers actually helped standardize Scheme), but it isn't supposed to be a subset.
>>
File: tfw too dumb to program.gif (12KB, 250x242px) Image search: [Google]
tfw too dumb to program.gif
12KB, 250x242px
I think I'm slowly starting to get the hang of pointers.

I've been spending the weekend trying to implement Stacks/Queues/Lists in C using pointers, and noticed that it's deceptively easy to make mistakes.

It took me a while to realize that to change the information in a Node, you pass in a Node*, but if you want to change the information in a Node* and have the changes last beyond the function, you pass in a (Node*)*

I'm probably still going to make tons of mistakes, but I'm curious, does this type of thing get easier?
>>
>Learning make is actually a thing
>mfw 220 pages manual
>>
>>61895586
>does this type of thing get easier

Yes. Just don't fucking typedef Node* and Node**.
>>
I'm figuring out an algorithm for resolving scope. Basically, every type is laid out as a tree, for instance we might have the following fully-qualified types:
root.TypeA
root.TypeB
root.TypeB.Nested
root.TypeB.Nested.TypeA

We want to, for instance, be able to tell that in scope "root", the type "TypeA" refers to "root.TypeA", while in scope "root.TypeB.Nested", the type "TypeA" refers to "root.TypeB.Nested.TypeA".
Things become more complicated when the unqualified type name has a path, e.g. in scope "root.TypeC" the type "TypeB.Nested" refers to "root.TypeB.Nested"

I was going to do some sort of tree-traversal algorithm but then I realized that instead I can just do something like

;; break scope 's' into subscopes, e.g.
;; (subscopes "root.pkg.private") = '("root.pkg.private" "root.pkg" "root")
(define (subscopes s) ...)

;; get a type by its fully-qualified name
;; returns #f if no type exists
(define (get-type fq) ...)

;; resolve the unqualified type name in the given scope
(define (resolve uq-name scope)
(ormap (λ (ss) (get-type (string-append ss "." uq-name)))
(subscopes scope)))


Like this is dead simple but it feels like a hack. Yes I would literally do string concatenation
>>
>>61895586
You sound like you're getting the hang of it. When you deal with pointers a lot it becomes more intuitive. Also it helps to limit the degree of indirection (no more than two *'s most of the time; two usually means a pointer to an array) to make it easier to understand what's going on and not get caught in mutation hell
>>
>>61894317
(shell)

The commands found in M-x are just function that are defined with (interactive)
>>
cpp multi threaded booru searching image tagger that uses microsoft trueskill with image vs image competitions to rank the tags in the image as a team game

embeds the tags as iptc data instead of copying all your files to a database like certain python programs
>>
File: ah so it's like that.png (187KB, 500x344px) Image search: [Google]
ah so it's like that.png
187KB, 500x344px
>>61895929
>>
>>61895987
http://www.moserware.com/2010/03/computing-your-skill.html

https://www.microsoft.com/en-us/research/project/trueskill-ranking-system/

http://www.moserware.com/assets/computing-your-skill/The%20Math%20Behind%20TrueSkill.pdf

its rly cool
>>
>>61896148
wait wasn't trueskill in Halo 3 matchmaking?
>>
>>61896167
I think it existed since halo 2 beta, so probably
>>
Why do I get the result 6, whenever I use this?
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
printf("%d,\n", strcmp(days[0], days[1]));
return 0;
}
>>
HTML5. Need to display a table, with headers, containing up to 20000 rows, and allowing x-scrolling. What do?
>>
>>61896207
Sunday is greater than Monday. Therefore you get a positive number greater than zero. The specs don't promise that you will get any particular positive number greater than zero in this case, but it appears the implementation just subtracted the byte values and returned any non-zero difference.
>>
>>61896244
Doesn't strcmp specify -1 for less than, 0 for equal and +1 for greater than?
>>
How do I make a make file for a project like this?
.
.
├── bin
├── headers
│ └── greet.h
├── main.cpp
└── src
└── hello.cpp
>>
File: 1480184600117.png (43KB, 1681x576px) Image search: [Google]
1480184600117.png
43KB, 1681x576px
>>61896268
Nope.
>>
>>61896284
just do it manually

-I /headers
>>
>>61896287
I'm retarded. Where did you get that specification?
>>
>>61896303
What if I keep adding headers and source files? I want a tool that automatically looks for the headers and the sources and includes them
>>
>>61896318
you can do all kinds of macros and scripts inside makefiles, I think the easiest for your situation just amounts to regex to find all .cpp and send to an object file and link them

or you can use automake
>>
>Suckless
The edgy teenagers of the 80's that never grew up
>>
>>61896308
http://pubs.opengroup.org/onlinepubs/9699919799/functions/strcmp.html
also
man 3 strcmp
>>
>>61896335
good goy
>>
>>61896383
Amazingly suck"less" forgets about MSVSC and doesn't give any alternatives
>>
File: nico_nico_nee.gif (735KB, 500x280px) Image search: [Google]
nico_nico_nee.gif
735KB, 500x280px
>>61896361
thanks
>>
>>61896396
conforming to everything doesnt make you a normie senpai, you're still awkward and weird
>>61896411
cutest loli
>>
File: thinking_scratch.gif (172KB, 500x506px) Image search: [Google]
thinking_scratch.gif
172KB, 500x506px
Is my merge sort implementation comfy?
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>


void merge(void *base, size_t ln, size_t rn, size_t size, int (cmp)(const void *, const void *))
{
void *k = malloc((ln + rn) * size);
void *left = (char *) k;
void *right = ((char *) k) + (ln * size);

memcpy(left, base, size * ln);
memcpy(right, ((char *) base) + (ln * size), size * rn);

while (rn + ln > 0) {
if ((rn <= 0 || cmp(left, right) <= 0) && ln > 0) {
memcpy(base, left, size);
left = (char *) left + size;
ln--;
}
else {
memcpy(base, right, size);
right = (char *) right + size;
rn--;
}
base = (char *) base + size;
}
free(k);
}


void msort(void *base, size_t n, size_t size, int (cmp)(const void *, const void *))
{
if (n > 1) {
size_t ln = n / 2;

msort(base, ln, size, cmp);
msort(((char *)base) + (ln * size), n - ln, size, cmp);

merge(base, ln, n - ln, size, cmp);
}
}
>>
>>61896473
>C
>comfy
Nope
>>
>>61896473
cute anime
>>
File: fragzeichen.jpg (88KB, 1280x720px) Image search: [Google]
fragzeichen.jpg
88KB, 1280x720px
>>61890565
For real-time audio processing, is treating audio as floats the standard?

Have I been using 16-bit ints like a brainlet?
>>
>>61896503
Single-precision floats are fast and precise enough these days, as long as you don't let them underflow.
>16-bit brainlet
Will be the new lo-fi in five years, yey
>>
Is there any reason to use raw arrays instead of std::array in C++?
>>
Can someone explain to me how PCM audio streams works and how I can literally average multiple arrays of PCM data together mathematically in order to mix them?
Why does multiplying these arrays make the sound output louder?
>>
>>61896566
nothing comes to mind
>>
File: 1498946571257.png (8KB, 258x258px) Image search: [Google]
1498946571257.png
8KB, 258x258px
I have a project folder that has a basic template and most of the imports I use on a reg basis.

At reboot chron copies the directory to /tmp so I always have a fresh scratch project ready to go
>>
>>61896620
dumb frogposter
>>
>>61896570
A PCM data series represents the sound pressure level at regular sample intervals. You can add them together to mix them, and if you really want to you can scale them up or down to adjust or restore the average magnitude.
>Why does multiplying these arrays make the sound output louder?
Probably because they're integers and that's what integers do when multiplied?

>>61896620
>not creating a project initialization script that does the same
>posting frogs
>2011 + 6
shiggy
>>
>>61890565
who is she?
>>
>>61896672
himegoto
>>
=

assigns value to left variable, no error from compiler

+=

adds values on both sides, then assigns value to left variable

=+

same as =


defend this java users?

why does =+ even exist, is it just there to confuse people?
>>
>>61883574
>>61883660
I asked the question, can someone step me through anons reply. What do I have to do to set this up and what would the process of working on code and commiting to github look like? Sorry I have cmake autism
>>
>>61896705
What does this assign x to?
int x((++a, ++b))
>>
>>61896723
why would anyone write code like that
>>
>>61896734
exactly
>>
>>61896723
what language is this?
>>
>>61896748
C++
>>
>>61896723
int x((++a, ++b))

same as saying
++a;
++b;
int x = b;
>>
>>61896760
I know
>>
>>61896778
>>61896760
therefore it obviously assigns b+1 to x. Then why did you ask fuck face?
>>
I'm building a crypto trading bot in kotlin. So far I've built the trading framework which collects market data, manages performing bids/asks and has backtesting support. In the process of making sure everything is nicely tested.
>>
>>61891537
Bump
>>
>>61897119
K&R do all the programs in it, its super short
>>
File: dreams.jpg (30KB, 540x540px) Image search: [Google]
dreams.jpg
30KB, 540x540px
>>61890565
Ok so I started learning python last weekend.

It was all going great and I was learning a ton. I had a couple books I was learning and I was beginning to understand the difference between basic words like argument and specification.

But then I started writing my own program in between the lessons.

2 weeks later I am about a couple hours of work away from finishing my first project. I built myself a custom alarm clock that uses text to speech to greet me based on the day of the week and fetches news videos from you-tube every morning.

The problem is I have literally no idea what I am doing. I did 90% of this through just looking up modules and figuring out how to make them do what I want.

I havent picked up my books in days . I dont remember what the difference between a list and a tuple is, but I have already built this cool program.

Should I feel proud of myself or like shit for just faking my way through?

This is pretty much how I figured out computers as a kid, but I kinda wanted to actually do it properly this time.

Please motivate me to get back to my books. Tell me how this is all going to byte me in the ass. Tell me how I will get stuck as a low level shit head. Please help.
>>
>>61895929
So you are going to find which tags are objectivly best...

But how do you know which win? I get how you could start ranking them individually once they started wins and losses as parts of various teams, but what its the actually competition?
>>
>>61897431
using matchmaking the images will be competing against eachother, the program will display two images and then I will pick which one is cuter

then two teams will be composed of all the tags in each image, and trueskill rankings will be calculated as if the tags were the players, the team that wins is the one attached to the image I chose as cuter

ive done ELO rankings of cute images like this in the past, it doesnt take too long to get tens of thousands of comparisons done
>>
>>61896503
16-bit is only fine for the final mix
Use 32-bit floats or larger during processing
>>
>>61897460
>using matchmaking the images will be competing against eachother, the program will display two images and then I will pick which one is cuter
>then two teams will be composed of all the tags in each image, and trueskill rankings will be calculated as if the tags were the players, the team that wins is the one attached to the image I chose as cuter

I got all of that except how you were choosing winners.

>then I will pick which one is cuter

Why not just loot at a list of tags and rank them? It would save time.

I thought this would actually be interesting, but its just some neck-beard sorting his own images in the most retarded way possible.

Can I suck your dick while you do it?
>>
File: rustfmt.png (108KB, 1275x986px) Image search: [Google]
rustfmt.png
108KB, 1275x986px
>Write a piet interpreter in Rust
>Do whatever I feel like doing style-wise, pretty readable in my opinion
>Run rustfmt
>Number of line quadruples
Tell me /g/, what's more readable, left or right?
>>
>>61897524
>Why not just loot at a list of tags and rank them? It would save time.

lol im not going to get any good statistics just looking a list of tags and picking which ones I like more

after I have a list of highly ranked tags I can make a booru crawler that finds images with a high total tag value

also the images themselves will be assigned a trueskill score for sorting and searching as well

i dont really see your problem
>>
>>61897538
Languages that impose style restrictions are horrible memes.
>>
if autotools is so good whymst doesn't the kernel use it
>>
>>61897542
you didn't answer my last question.

Thats my only problem.
>>
>>61897606
woah
>>
>>61897559
Wrong, in so many ways
>>
>>61897559
style is irrelevant
>>
>>61897652
Not when you work with others.
>>
mov $1, %eax
mov $13 %ebx
int $0x80
>>
>>61896705
>why does =+ even exist, is it just there to confuse people?
It's there to confuse retards like you who don't know how tokenizers work.
>>
>>61897589
Horses for courses, meine kleine scheißeneger.
>>
File: fragzeichengrab.jpg (88KB, 777x777px) Image search: [Google]
fragzeichengrab.jpg
88KB, 777x777px
>>61890565
What's the best way to keep highly accurate time in C?

I want to simulate a waveform oscillator without actually looping through a wave array at all times. Just when I need to reference the wave I can do some kind of calculation based upon the clock of the program to catch the correct phase of the wave, as if it were oscillating all along.
>>
>>61897922
Stop trying to make efficient things. Just create a thread that will take care of the oscillation in a global array and read it when you need to. Bonus points if you don't use any kind of synchronization.
>>
>>61890627
CHICKEN is always the right answer
except maybe Chez since it recently went FLOSS
>>
>>61891104
>NetBeans
ffs C++ is nowhere near as obnoxious as Java.
if it is, it's in the syntax, not the disastrous libraries.
just use a text editor and a Makefile
>>
>>61896705
What does =+ mean? I've never seen it before.
>>
>>61897962
That's a shit solution
>>61897922
Clock_gettime
>>
>>61898039
x = +5.
You can remove the whitespace if you want to. The plus sign is useless.
>>
super fast threaded booru searching
idk if its wise to make hundreds of simultaneous requests to danbooru rest api though
>>
Hello,
I'm looking for distributed NAS storage solution for big Enterprise project. We'll need more than 2500 NAS with central server(in better case, this one should be as virtual appliance).
Requirements:
Auto-deployment from server/s when NAS connects to network.
SSL or IPSEC VPN.
Encryption of data.
Automation over SSH.
Update deployment from servers (because those NAS-es won't have internet connection).
Secure AD connection.
LDAP connection.
Perhaps connection with zabbix or graylog.
Power management.
Thanks for ideas.
>>
>>61898052
Why the fuck is the OP complaining about then? It is just a unary operator, there are other examples of this like a-->0 which looks like a → 0
>>
>>61898069
Because he doesn't know shit about programming yet.
>>
>>61896723
>>61896760
it's undefined behaviour and should be avoided

Of course it works but you don't have any reasons to use it, and the outcome might not be the same on different compilers. Same as
printf("%d %d\n", x++, x++);
where gcc will print "2 1" to go with the stack order and clang will print "1 2" assuming the programmer wants it in the order they entered the variables in.
>>
What's a good algorithm for reading an array in a random order without shuffling it?
>>
>>61898173
If you want to read each element exactly once I think you need Satolo's algorithm, although I'm not exactly sure.
>>
>>61894002
>>61894016
Source on this? Because clang comes out ahead in every modern comprehensive test I find. Not across the board but throughout the tests that are done. Anyone can find code one or the other failed to optimize well in some aspect. So be weary when looking at a single graph for a single compile.
http://www.phoronix.com/scan.php?page=article&item=gcc7-clang4-jan&num=2
>>
>>61898197
Yes, exactly once.
Also, are you sure that's the right name?
I can't find any algorithms under that name.
>>
>>61898225
Sattolo's is mentionned here: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
>>
>>61892451
Things like don't do premature optimization. How important it is to keep your teams progress a priority over your own (for instance don't let the project wait on you defining an api). Things like that.
It's a big thing and it's not easy to learn. I doubt you're expected to ace. They're probably just looking for someone who's not stubborn and can communicate their opinions without being a dick.
>>
>>61898248
That's a super obvious algorithm, and one which requires a second array to be made.
Better algorithms are possible.
>>
>>61898248
>The modern version of the algorithm is efficient: it takes time proportional to the number of items being shuffled and shuffles themin place.
CS dummies never cease to amaze. Random access on an array is terrible for performance on modern computers. I haven't thought up any alternative algorithms but I'm sure there's way to localize the changes and build up an unbiased random sort over time. While still achieving the measly O(n) time.
>>
>>61898331
Unless you add a "visited" field to your structures and use rand() to access the array (this is an O(∞) algorithm) you'll have to have another array, either to generate the indices in the order you want to access them or in order to prune the indices you already visited.
If you can prove me wrong please let me know.
>>
>>61898372
I do remember once accidentally making a bitwise function which shuffled through every single combination of bits exactly once, in a seemingly random (but always the same) order.
I forget how it worked, but maybe it could have been adapted to use a random key between 1 and n! so that it would be a different random order each time.
>>
>>61898209
Clang is all around better, GNU shills are just spreading a lot of outdated statistics and will go out of their way to call llvm evil and bad etc. because they know it'll eventually cause GCC to be deprecated after the years of negligence and general power abuses they had with it, if not because it's simply better.

http://gcc.gnu.org/ml/gcc/2014-01/msg00247.html

They're literally fighting against open source projects to be relevant, refusing any form of compatibility they could have with it, clinging to their little ideology as the last thing that'll save them (and their funding) from an obviously better, freer compiler.
>>
>>61898401
Well if you remember it post it here, I'm sure it would be interesting to look at.
>>
What should I work on? Someone suggested continuing with procedural programming before moving onto classes using C++.
>>
>>61898435
This desu
>>
>>61898435
t. paid clang shill
>>
>>61898439
I remembered it, though I don't see how it can be adapted to be useful.
It's really just a wonky way of counting.
It seems that if you apply this process to a bit string, it will cycle through all combinations:
>slide all bits right
>create a new bit on the left; if the rightmost two bits are identical, the new bit shall be 1, else 0
>remove rightmost bit
>repeat

Here's an example cycle:
0000 1000 1100 1110 0111 1011 1101 0110 0011 1001 0100 1010 0101 0010 0001

I've only done it by hand, so I haven't done a full cycle beyond 4 bits, but I did part of 5 bits and it seemed to be adopting a similar pattern.
>>
Why does this work
 #include<stdio.h>
int
main(void)
{
int X, x, sum;
scanf("%d%d", &X, &x);
sum = X + x;
printf("%d + %d = %d\n", X, x, sum);
return (0);
}

and this doesn't?
 #include<stdio.h>
int
main(void)
{ int X, x, sum;
scanf("%d%d", &X, &x);
X + x = sum;
printf("%d + %d = %d\n", X, x, sum);
return (0);
}

The only difference is that = sum is on different ends and the error message I get is "lvalue required as left operand of assignment"
>>
>>61898080
The comma operator always evaluates the left first, discards the result, then evaluates the right and returns that. There is nothing wrong with it.
>>
>>61898559
You can't have an expression on the left side of the = .
>>
>>61898493
I fucking wish I was paid for that, shilling for something you actually like sounds like the best job
>>
File: 1499693446864s.jpg (2KB, 125x92px) Image search: [Google]
1499693446864s.jpg
2KB, 125x92px
>>61896721
notice me.
>>
>>61898559
X + x is not a variable. = works only in one direction.
>>
>>61898615
https://cmake.org/cmake/help/v2.8.8/cmake.html#opt:-Ggenerator-name
https://cmake.org/cmake/help/v2.8.8/cmake.html#section_Generators
>>
>>61898435
>the software commies hate llvm
That explains it. Thanks for informing me.
>>61898493
t. unpaid gcc shill
>>
>>61898559
The assignment operator assigns to the left. On the left you have an rvalue (an expression that isn't a single variable that can be assigned to).
It's not declarative equality as it would be in math.
So it doesn't make sense to assign to the sum of something.
>>
>>61898727
Clang can't even compile linux.
Install gentoo... oh wait you can't.
dump applefag
>>
>>61898727
>software commies
It's interesting how apt it is.
In communism competing socialist ideologies are viewed as the biggest threat. That's why these regimes are so oppressive. It's easy to control a capitalist in a communist country but people who just wish to change the system must be executed.
>>
heh, GCC has gotten C++17 support, clang hasn't
>>
>>61898787
>can't even compile on Linux?
Elaborate? I do it just fine. Cmake.
>>61898793
Yeah that is a downside. Personally I don't care. I write a very limited C++ anyway.
>>
>>61898802
>>can't even compile on Linux?
Learn to read maybe apple shill.
>>61898727
Clang can't even compile linux.
Or you don't even know what linux is...
>>
>>61898787
There is a project which is trying to make Clang able to compile linux.
http://llvm.linuxfoundation.org/index.php/Main_Page
>>
>>61898642
Yeah I know, but does that mean I have to generate a GNUMake project or VSProj when ever I want to work on the repo? And when I commit to github how would I translate the VSProj/GNUMake project back into a cmake project?
>>
>>61898823
>can't even compile Linux
Oh. Well sorry I assumed you weren't retarded.
>>
>>61898793
people use clang?
>>
>>61898840
>project which is trying
That means nothing. It's fucking 2017 and clang can't even compile Linux kernel. HOLY FUCKING SHIT!
Fucking nu-male hipster what is so hard about using mature and working software?
I bet you also shill for rust.
>>
>>61898802
Downside for me, I mainly write C++. Clang isn't all that bad though, I use clang-format myself, nice tool.

Although seeing that GCC is going to implement a language server I am pleased with it.

>>61898873
I use it as my formatting tool
>>
>>61898787 >>61898878
Well clang not being able to compile Linux is partially linux's fault for using non-standard c gcc extensions.
>>
>>61893298
There is MPL and Apache, too (as well as GPL). These do consider patents, and offer some form of protection.
>>
>>61898029
Actually netbeans is pretty okay. It has limitations but yet it's pretty okay. Unlike codeblocks and eclipse which crashes every now and then. Qt creator is okay too.

>why not make file
I don't want to read a 220 page manual just now, I'm still new to this
>>
>>61898868
You create your cmake file. On windows, you use it to generate a vs project file. You ignore these files in git.
On unix, you use the cmake file to generate unix makefiles. You ignore these files in git.
Done.
>>
>>61898888
>linux's fault for using non-standard c gcc extensions.
Where was clang when Linus needed them?
>>
File: Screenshot_20170814-135735~01.png (391KB, 867x1695px) Image search: [Google]
Screenshot_20170814-135735~01.png
391KB, 867x1695px
>clang vs gcc
gcc is fine if you're just doing the most basic stuff.
>>
>>61898878
Rustfag myself, but both the compilers are okay. Although I like GCC better for C/C++. (Not him though)
>>
New thread
>>61898971
>>61898971
>>61898971
>>
>>61898936
not much reason to use it over clang though when they're both free
>>
>>61899000
Same could be said about clang
>>
>>61899000
See
>>61898435
RMS disagrees.
>>
>>61899030
GCC is objectively worse than clang, and even if it wasn't, you don't have to deal with the extremist views of the FSF.
>>
>>61899061
>GCC is objectively worse than clang
GCC is more up to date with standards and produces faster binaries for Linux, I'll stick to it instead.
>>
>>61899076
>more up to date
But they're not standard compliant? Isn't that an automatic F?
>>
>>61899095
C++17 is out
>>
>>61899103
Which design decisions made in the past are fixed by that version?
>>
>>61899116
Look it up. I'm not here to argue about the standard itself
>>
>>61899076
>GCC is more up to date with standards
debatable

>produces faster binaries for Linux
neither GCC nor Clang is definitively better in all cases when producing binaries

>GCC
basically forcing all your software to suck on stallman's digusting flaccid dick for ever.
>>
>>61899103
https://clang.llvm.org/compatibility.html#cxx
Doesn't matter.
Do you not comprehend the issues with this? You're making code secretly non-portable.
It's completely in line with the FSFs restrictive ideas of 'freedom' but it's not compliant. I think being up to date with standards means you follow the standard.
I'd rather get C++17 later but correct rather than early and wrong. I don't know what issues gcc has implemented this time but given the track record there's probably some.
>>
>>61899127
Nothing wrong with GCC, GCC was there when it was needed the most

>>61899139
>Doesn't matter.
Why?
>I'd rather get C++17 later but correct rather than early and wrong.
GCC has gotten C++17 earlier and correct. You are literally digging your own grave. As I said, GCC is more up to date with the standards and compiles faster binaries in general which is why I am sticking to it
>>
>>61899175
>correct
Do we have proof of this or is this just an empty claim?
>why doesn't it matter?
Because it's already not following the standard.
>compiles faster binaries in general
It doesn't though. Only if you compare old versions of clang to new versions of GCC.
See: >>61898209
That's a very general test. I wouldn't say I count that as a plus for clang. Because they're so incredibly similar. Neither is notably faster.
And that's ignoring how much slower gcc is in compile times. At some point that will matter for runtime optimization, even if you don't care about how slowly it compiles.
Choose what you wish but don't present the wrong reasons for choosing to others.
>>
>>61899211
What about g++17 doesn't seem standard to you?
>Because it's already not following the standard.
It's not, it's following the C++17 standard syntax
>article
The same article established that GCC is faster too, which means GCC has a proven track record, I simple don't see any reason to believe that g++17 is somehow not standard even though I use standard C++17 syntaxes in it
>>
>>61899248
simply*
>>
>>61899248
>it's the same article that established that gcc is faster too
No. Clearly not. Clang 4.0 is shown to be the best by not having crap average performance and having the best win/loss ratio.
>it's following the C++17 standard
How do we know? We'd need to prove it. There's plenty of tools for that. Given that they've done that poorly in the past we can't trust them anymore.
>which means that GCC has a proven track record
What the are you on about? Performance and standard compliance is completely separate. That article doesn't talk about compliance at all.
>>
>>61899337
>We'd need to prove it.
You need to prove it since you are claiming it's not following the standard C++ and its syntax. You are not pretending to be an idiot, are you?
>>
>>61898887
clang-tidy, clang-check are also quite useful.
cppcheck is still on C++11.
>>
>>61899379
No anon my argument is that it has been poor at following the standard in the past so how can we trust them?
I've already posted this. I hate repeating myself so shut up and read
https://clang.llvm.org/compatibility.html#cxx
for once. That's just their recent missteps. We've had them fail with C for a long ass time.

Until gcc is proven to be standards compliant they should be assumed to not be. There's plenty of language analysis that could be used to prove this.
https://en.m.wikipedia.org/wiki/Compiler_correctness
But it'd be inappropriate for compiler authors other than gcc or independent sources to prove their incorrectness.
C++17 is new. We won't see people proving it just yet.

But if you don't care about them implementing the features right but rather just give you a quick and dirty version of the new standard.

Clang is right now very very close to c++17. And I trust them more to have done it right.
>>
>>61894868
And if my eyes don't deceive me, that's doing more than "merge", the function contains undocumented functionality.

call it
merge_asorted
(ascending order sorted) or something for clarity. "merge" by itself is just a bad choice of name when your function is clearly doing more.
Thread posts: 329
Thread images: 39


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.