[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: 316
Thread images: 34

File: 1503423052994.jpg (44KB, 640x496px) Image search: [Google]
1503423052994.jpg
44KB, 640x496px
What are you working on, /g/?

Old thread: >>62266919
>>
first for fuck opengl
>>
>>62271195
Anime
>>
A systems programming language with features like type constructors, traits, lambdas, and dependent types. Not for safety, though, just code reuse.
>>
File: gaypi.png (122KB, 878x721px) Image search: [Google]
gaypi.png
122KB, 878x721px
>>62271195
doing a api in Flask, duno how I feel about it yet
>>
>>62271211
ATS
>>
>>62271195
I love Betty Boop
>>
>>62271233
ATS is a mess. Note that by dependent types I do not mean interpreted as logical propositions. The only thing dependent about them is their size and alignment and how fields are laid out (e.g. for a struct containing an array whose size depends on a value).
>>
>>62271230
What is this disgusting "language"?
>>
>>62271275
Python.
>>
File: 1504521584826.png (974KB, 942x670px) Image search: [Google]
1504521584826.png
974KB, 942x670px
How do I optimise code for my computer's hardware?
>>
>>62271211
you using llvm?
>>
>>62271230
>using filter and lambda when list comprehensions exist
>>
>>62271286
code it with C and use architecture specific features like simd and stuff
>>
>>62271286
-march=native
>>
>>62271286
take some code
time it
look at the assembly
either rewrite the assembly manually, or rewrite the higher level code until the assembly looks optimized the way you want
time it again
not faster? put it back the way it was
>>
File: fgggg.png (3KB, 396x249px) Image search: [Google]
fgggg.png
3KB, 396x249px
From previous thread
Pic related
>>62271163
This is how it's supposed to look like
Rules:
>all print statements must be used with loops
>only one * sign per print statement


Don't help me too much. After all I am supposed to learn. All I need is a little advice
>>
>>62271295
why would you create a loop and if statement if you only need anon function for a simple if?

less code, more readable

what a n00b cake
>>
File: smc.gif (930KB, 640x480px) Image search: [Google]
smc.gif
930KB, 640x480px
>>
>>62271301
how do you use simd
>>
>>62271335
You can't with C because it was created before SIMD was a thing. The more pathetic thing is you can't with languages created after either, so you have to resort to assembly.
>>
File: 1498089544305.jpg (310KB, 640x892px) Image search: [Google]
1498089544305.jpg
310KB, 640x892px
>>62271332
That's how i also feel Usagi-chan!
>>
>>62271321
>Don't help me too much. After all I am supposed to learn. All I need is a little advice
do it yourself
>>
>>62271321
Write some examples by hand first.
>>
>>62271335
check if the compiler flag is set
if it's set the simd functions are something like __some_stuff_to_vector
You can take reference from some game engines or scientific libraries that do vector math
>>
>>62271288
First party back ends will generate their own machine code.
>>
software engneering or embedded development?
>>
>>62271424
development engineering
>>
>>62271452
negative
>>
>>62271288
>>62271410
Well, object code.
>>
>>62271424
Pick machine learning like all the cool kids. And all the non-cool kids. And everyone else not in either of those two groups.
>>
So just to make sure I get this right, if I use XADD (exchange and add for i386+) nothing would prevent another of my CPU's core to XADD at the same time and fuck shit up right?
>>
>>62271503
I meant i486+
>>
File: IQ 132, practical IQ 32.png (1KB, 388x108px) Image search: [Google]
IQ 132, practical IQ 32.png
1KB, 388x108px
>>62271366
>>62271368

I have been doing that for well over an hour now. Best results I got was pic related.
>>
>>62271424
code artisanship
>>
Is jvm the platform to target?
>can use multiple languages that compile to javabyte code
>can export applications to pc/mobile
>cross platform GUI API with javafx, even for mobile
Compared to native applications/libraries
>every relevant library is sepples shit and doesn't export C API
>no cross platform GUI(none of them run properly on mobile) library unless go some fucky route like using SDL with nuklear+opengl
>linking and compiling is pain in the ass
Sepplesfags can go kill themselves because of them nothing cool works with just C, jvm seems the best option for now...
>>
>>62271503
Yes, this is why there's no point in using xadd without the 'lock' prefix.
>>
>>62271503
Prefixing with LOCK will.
>>
>>62271592
>jvm seems the best option for now.
that'd be javascript
>>
>>62271592
learn C++ brainlet
>>
>>62271599
It's better than XCHG and then ADD.
>>
>>62271321
Make some arrays that specify which positions you want filled in with asterisks based on the row, and then use a for loop or two for the print statements
>>
>>62271576
write a function print_line(int num_stars, int line_length) that prints a single line. be sure to pad the stars with the proper number of asterisks
>>
>>62271609
>js
not programming language
also browser is the shittiest software to run applications on
>>62271619
>sepples
Not portable, does not by default work with other languages, made by nigger Stroutrup
Also no decent GUI library either, QT requires you to sacrifice multiple goats and childrens to get it to work
>>
>>62271683
>complains that all libraries are for C++
>complains that C++ has no libraries
>>
>>62271629
I have gotten to Arrays but they are not to be used. No if or else statements, no methods. Only loops and one print * statement(and " ").
>>
>>62271576
>IQ 132
it shows
>>
>>62271592
So what's the current pay rate for an Oracle shill?
>>
>>62271667
pad the stars with the proper number of spaces, I mean
>>
>>62271691
>c++ has no good GUI library
>c++ libraries don't export API that you could use from other lanaguages
>>
>>62271667
I can't use functions. If I could, it would be much easier
>>62271692

>>62271696
it's seriously my measured IQ, but I always feel like a dumb shit when it comes to things like this
>>
File: diamond.png (30KB, 599x515px) Image search: [Google]
diamond.png
30KB, 599x515px
>>62271321
eyyy
>>
>>62271704
he's right you know.
the only superior target is javascript but js is a nightmare to program in
>>
>>62271704
I don't know but as far as I know oracle doesn't require you to pay if you ship jvm with your application.
Meanwhile cppcon and sepplesfags continue to ruin the world.
Not saying oracle is any better, but sepples is not answer to anything.
>>
What are you trying to do?
>>
>>62271717
>i cant use functions
write it, then inline it before you turn it in
>>
>>62271757
Was for >>62271733
>>
>>62271683
>also browser is the shittiest software to run applications on
What
Why?
>>
>>62271683
>cannot manage to use brainlet-tier Qt
>thinks his opinion matters
>>
>>62271775
>every application needs to ship whole HTTP cliet, HTML renderer and JS interpreter into the application
>js is the worst language ever created
>nobody even follows THE STANDARD
>>
>>62271814
b-but webassembly
>>
File: 1431273610167.png (463KB, 1070x601px) Image search: [Google]
1431273610167.png
463KB, 1070x601px
>>62271733
I'll guess this might work in Java unless return 1 would have any impact
>>
>>62271813
It does not export C api.
It does not exists.
>>
>>62271359
Bloomers are a miracle of the universe.
>>
>>62271745
The whole idea of "cross-platform development" it a meme. If you're developing for server-side, 99% you're targeting Linux, if for desktops - you're targeting Windows and maybe macOS but not really, if you do mobile you're targeting Android and iOs and Java won't help you with the latter. Every platform has its preferred set of tools, and there's no reason to use inferior "cross-platform" ones, because code is unlikely to leave the platform it's written for.
>>62271756
>oracle doesn't require you to pay if you ship jvm with your application
This is where you're wrong, kiddo: https://www.theregister.co.uk/2016/12/16/oracle_targets_java_users_non_compliance/
>>
>>62271825
the trick is to realize that the spaces to the right of the diamond don't need to be printed
>>
>>62271814
>>every application needs to ship whole HTTP cliet, HTML renderer and JS interpreter into the application
And these are shipped with every phone, tablet and computer by default.
>>
>>62271842
So it's better to actually take Swift if you are into iphones and Java for Android? Xamarin is "inferior meme" according to your post, is that so senpai?
>>
>>62271849
well then I doubt there's any need for that in Java as the spaces to the right don't influence anything
>>
>>62271862
Xamarin is fine, but it only targets mobile, which makes sense.
>>
>>62271733
Thanks alot. That worked. Although I wasn't supposed to copy anything and try to learn it by myself, but guess I had no other choice. There was never a requirement that I need to do it completely on my own though :^)
>>
>>62271934
well done anon you learned nothing
>>
>>62271833
Just link your C lib against a C++ Qt application that uses your lib. It's brainlet-friendly as fuck.
>>
>wake up
>modern irc has chrome engine inside of it
weird times desu
>>
>>62271943
He learned to take credit for someone else's work. That's probably the most valuable lesson there is.
>>
>>62271951
qt doesn't export C api, dumbfuck
>>
>>62271934
sure thing
these type of trick problems are a waste of time
instead, the time wasted on this IQ test question can be used to learn something useful
>>
>>62271943
;_;
I will try to use it as reference and try to work on a code that is slightly different but follows similar principles

>>62272000
I just hope I won't get something similarly limiting on my exam
>>
>>62272023
they wouldn't put this shit on an exam unless you're in a top school, and even then I seriously doubt it
an average IQ person wouldn't be able to solve it given the entire length of the test
>>
Rate my code, /dpt/.
int 
high_pow (char number[]) {
int number_len, power, ap_group;

power = 0; ap_group = 0;
number_len = strlen(number);
for(number_len--; number_len < 0; number_len--) {
if (number[number_len] == '\'')
ap_group++;
else {
if (!!ap_group && (ap_group <= power)) return -1;
power = ap_group;
ap_group = 0;
}
}
return power;
}

It is implied that numbers are written in form
1''''2'''3''4'5
or
2'''
so the highest power of the first number should be 4, the highest power of the second number should be 3.
Numbers like
1'2'''3''
are incorrect, so the function must return -1.
Numbers with fractions will be treated the other way, it's not important now.
>>
>>62271993
>export c api from your lib
>link
>use
what's the problem here, why does qt need to export c api?
>>
>>62272083
dumbfuck
>>
>>62271993
I know that, anon. You don't need a C++ API to link a C++ application with a C library. You just expose a C API (for your code) to be used inside a Qt program.
>>
>>62272071
you are fucking with him now aren't you
>>
>>62272131
no
>>
>>62272119
Would still require you to write the gui stuff in sepples fucking retard
>>
>>62272152
Imagine that, using a C++ GUI library requires you to use C++. Better kill yourself, I anon.
>>
>>62272187
The original point was that there's no good native GUI library, dumbfuck.
>>
>>62272071
>an average IQ person wouldn't be able to solve it given the entire length of the test
You mean this is actually a very hard task?
>>
>>62272201
There's Qt.
>>
best way to learn java? the codecademy tutorial was shit
>>
>>62272210
>qt
>good
>not even exporting C API
It's shit beyond the borders
>>
>>62272207
yes
especially the requirement to keep it under 7 lines
the average person, even if they could solve it in time, would do so with 20+ lines
>>
>>62271321
#include <stdio.h>

int main (void) {
int offset[7] = {18, 14, 10, 6, 10, 14, 18};
int stars[7] = {2, 10, 18, 26, 18, 10, 2};
int i, j, k;

for (i=0; i<7; i++) {

for (j=0; j<offset[i]; j++) {
putchar (' ');
}

for (k=0; k<stars[i]; k++) {
putchar ('*');
}
putchar ('\n');
}
return 0;
}
>>
>>62272274
he said arrays are not allowed to be used
>>
>>62272299
oh i did not see that
>>
>>62272274
#include <stdio.h>
int main (void) {
int offset[7] = {18, 14, 10, 6, 10, 14, 18};
int stars[7] = {2, 10, 18, 26, 18, 10, 2};
int i, j, k;
for (i=0; i<7; i++) {
for (j=0; j<offset[i]; j++) putchar(' ');
for (k=0; k<stars[i]; k++) putchar('*');
putchar ('\n');
}
return 0;
}


FTFY
>>
>>62272263
that's actually quite relieving to hear. Thank you
>>
>>62272274
If I could use arrays, it would be far more easier as I could just have added the amount of spaces and stars to the list.
>>
File: 1468882928057.png (199KB, 439x392px) Image search: [Google]
1468882928057.png
199KB, 439x392px
Employed Haskell programmer here
>>
>>62272445
employed at mcdonalds
>>
fuck relational algebra
>>
fuck opengl, though
>>
File: 2017-08-27 03-15-07.webm (1MB, 962x542px) Image search: [Google]
2017-08-27 03-15-07.webm
1MB, 962x542px
>>62271321
I wanted to whip up a rotating rhombus to shit on you and humiliate you, but I only managed a triangle.

When I tried to stitch two triangles into a polygon, my program shit itself
>>
>>62271230
Thanks for making me aware of JWT
I did not know it was a standard
https://en.wikipedia.org/wiki/JSON_Web_Token
>>
>>62271321
C is a whitespace optional language. you could do any program in 1 line
>>
>>62272445
How's your career as a category theory professor going?
>>
does sicp teach lambda calculus? i'm looking for a book on it on amazon and that was in the search results
>>
>>62272505
Do that in TempleOS.
>>
>>62272316
>>62272274
>>62271733
how tf are those <7 lines
>>
>>62272591
What's surprising with it?
>>
>>62272336
Does your prof know that the terminal stores its values as an array of characters?
You'll be putting your data in an array either way, just in a round about way.
>>
>>62272635
they are clearly not under 7 lines
>>
>>62272591
>tf
Retard.
>>
File: 1431628657209.png (631KB, 681x681px) Image search: [Google]
1431628657209.png
631KB, 681x681px
I am never using a fucking struct again.
Absolutely shit tier data structure.
Fiddly syntax, non scaleable, worst case of foregoing DRY.

Want to add one scale your vertex to four points instead of three? Get fucked, time to write an entirely new implementation.
Fuck structs
>>
File: IMG_20170904_171407.png (170KB, 512x512px) Image search: [Google]
IMG_20170904_171407.png
170KB, 512x512px
>>62271284
Why the hate on Python tho?
>>
>>62266214
There are plenty of genetic algorithms with implicit fitness functions, for example ones that have agents which move around/meet each other to reproduce/die when they run out of resources. There's no explicit function to maximize and no direct comparison/selection being made by the computer and yet the system visibly organizes, choosing genes more likely to survive.

That's one of the potential advantages of genetic algorithms - you might not need a fitness function in the first place. Not that they've had a lot of success compared to gradient descent based methods, anyway.
>>
>>62272702
Productivity triggers NEETs
It goes against their way of life
>>
>>62272696
Frogposters have yet to show their intelligence.
>>
>>62272696
Sounds like you need integer generics.
>>
>>62272696
C++ templates can solve your problem without any performance penalty
>>
>>62271841
The fact that they ever actually existed in the context they did is baffling.
>>
>>62272696
What language?
>>
>>62272696
dumb frogposter
>>
what year would a typical university teach polymorphism?
>>
>>62272782
First or second.
>>
>>62271599
>>62271600
Ok, I forgot about that. Thanks!
>>
Got buttfucked by ASP.NET and Knockout MVC today. That was fun
>>
>>62272696
template<unsigned int S>
struct Vector {
unsigned char bytes[S];
};
>>
File: 1428658835576.png (29KB, 594x838px) Image search: [Google]
1428658835576.png
29KB, 594x838px
>>62272781
frog website
>>
>>62272445
What the fuck do you actually do?
>>
>>62271321
dunno if it helps
offset 18 14 10 6 10 14 18
(1 << 4) + 2 = 18
(1 << 4) - 2 = 14
(1 << 3) + 2 = 10
(1 << 3) - 2 = 6
(1 << 3) + 2 = 10
(1 << 4) - 2 = 14
(1 << 4) + 2 = 18
>>
>>62272848
He just shitposts
>>
>>62272680
>>62272316
that is 6 lines which is smaller than 7 without cheating and putting things on the same line you'd never put on the same line in reality
it's also beautiful
def diamond(lines, stars, end, width):
for lines in range(lines, end-1, -1):
print ''.join([' ' for i in range((width-stars)/2)]),
print ''.join(['*' for i in range(stars)]) + '\n',
stars += 8*(lambda x: -1 if x<=0 else 1)(lines)
diamond(5, 2, -5, 80)
>>
>>62272799
what kind of programming concepts do they teach in a 3rd or 4th year course?
>>
>you have to split a string with a delimiter and parse each parts into floats
WELL LET ME SHOW YOU THE ABSOLUTE POWER OF ``MODERN`` C++
    auto start = 0U;
auto end = s.find(delim);
while (end != std::string::npos)
{
std::cout << s.substr(start, end - start) << std::endl;
start = end + delim.length();
end = s.find(delim, start);
}


Oh wait I haven't even parsed them yet

M O D E R N
>>
File: 1502986710668.gif (990KB, 500x300px) Image search: [Google]
1502986710668.gif
990KB, 500x300px
>>62272863
>python
>beatiful
>>
>>62272871
They teach to apply the theory you learned in the first two years.
>>
>>62272873
LITERALLY
str.chars().split(delim).map(|substr|{str as f32}) //done


MAAAH M O D E R N C++
>>
File: 1492803706019.jpg (85KB, 486x608px) Image search: [Google]
1492803706019.jpg
85KB, 486x608px
>>62272899
>that image
>>
>>62272871
Our 3rd year covered numerical analysis and parallel programming
Optional courses included writing a kernel in C++ (sans RTTI, exception handling or the std lib)
and an OpenGL course
>>
>>62272938
fuck opengl, though
>>
>>62272922
Is that rust?
>>
>>62272952
yes
>>
>>62272899
ok kid
>>
>>62272873
Splitting an arbitrary number with regex delimiter in 2 lines of C++
    std::regex re(regex);
std::sregex_token_iterator
first{input.begin(), input.end(), re, -1},
last;

Then just iterate first...last
>>
In SDL, what do:
Renderer
Surface
Texture
do? How are they distinct from one another and how are they used to present things on-screen?
>>
>>62272983
Read a book, nigger.
>>
>>62272969
You haven't parsed them yet
also
>resorting to ragex
>>
>>62272873
Fuck this, I'm going to call a D function to split and parse then return it back to C++
>>
>>62272995
which one
>>
I'll be honest the only real preferences I've developed in regards to programming languages are these.

Strongly Typed > Duck Typed
Bracket Scoping > Indent Scoping
&& > and (apply this to other operators and keywords as well)
>>
>>62272951
I dont know this meme, whats wrong with it? You like paying to use DIRECTX? v
>>
>>62273051
SDL's documentation and/or libgen
>>
>>62273084
>Strongly Typed > Duck Typed
100% correct
>Bracket Scoping > Indent Scoping
also correct, but unimportant
>&& > and (apply this to other operators and keywords as well)
meh
>>
>>62273084
and what anon?
>>
>>62273157
if(x > 10 and y < 100)
{Do shit}

Please don't fuck with me anon, I'll spend hours trying to explain myself if I think someone misunderstands me and I can't stop thinking about it even when I'm trying to sleep.
>>
>>62273128
>>62273084
strong typing is for women who need a strong father figure looking after them
>>
>>62273231
t. jsculpter
>>
>>62273231
I'm just a frail loli, so I need a strong hand to guide me.
>>
>>62273084
>Strongly Typed > Duck Typed
Wrong. Strongly, statically, duck typed languages are the best for serious projects, although strong + dynamic also has its place.

>&& > and (apply this to other operators and keywords as well)
If your language doesn't allow you to define your own operators, then it's not a good language.

The only valid conclusion is: lisp btfo everything else
>>
>>62272073
!!ap_group

For what purpose?
>>
>>62271195
Is it bad that I almost never use a debugger? The vast majority of the time I use print statements and only go to the debugger when I feel I've exhausted every possible consideration and still can't understand the problem. The few times I have used a debugger, I realized I could've saved tons of time by just doing that to begin with, but I still never feel inclined to use one.
>>
>>62273365
breakpoints are nice my dude
>>
Math books or resources that you would recommend for a newcomer?
>>
>>62273396
https://pastebin.com/CGgWCSDM
>>
>>62273421
>Wasting your time making that
Not even that guy, but that's sad.
>>
>>62273331
C90
>>
>>62273365
>I realized I could've saved tons of time
If you're on salary, that time could have been spent on your own interests. If you're paid hourly, that extra money I shelled out could have been used on hookers and blow instead. Either way, yes, it's bad.
>>
>>62272873
std::string str = "1.0 5.53615 8.927";
std::string delimiter = " ";

size_t pos = 0;
std::vector<float> vals;
while ((pos = str.find(delimiter)) != std::string::npos) {
vals.push_back(std::stof(str.substr(0, pos)));
str.erase(0, pos + delimiter.length());
}
vals.push_back(std::stof(str));


>>62272922
C++ is a 30 years old language, of course it's not really modern. When they say modern C++ they mean modern in C++ standard.

t. Rustfag myself
>>
>>62273459
It took me 10 seconds to make that. The result? Feeling good about myself on an anonymous imageboard.
Step it up, senpai.
>>
>>62272922
 string str = "1.0 5.53615 8.927";
str.split.each!writeln;
>>
>>62273563
str.splitter(',').map!(substr => substr.to!float).array;
>>
>>62271203
I'll say it again. OpenGL is godtier.
>>
>>62272873
>>62272969
>>62273480

niggr = "1.0 5.53615 8.927"
vals = map(float, niggr.split(" ")


Get recked fags
>>
>>62273620
>(()
... and what are "recked fags"?
>>
>>62273631
dumb parser poster
>>
>>62273460
So what happens in C90 with
if(2)
>>
>>62271321
You don't even need arrays or for loops:

#include <stdio.h>
void fill_cols(int n, int i) {
putchar(i < n ? ' ' : '*');
if (i != 12) fill_cols(n, i + 1);
putchar(i < n ? ' ' : '*');
}
void fill_rows(int n) {
if (n == 0) {
fill_cols(0, 0);
putchar('\n');
return;
}
fill_cols(n, 0);
putchar('\n');
fill_rows(n-4);
fill_cols(n, 0);
putchar('\n');
}
int main(void) {
fill_rows(12);
return 0;
}
>>
>>62273643
>missing the point of the assignment
>>
File: collatzerr.png (23KB, 638x425px) Image search: [Google]
collatzerr.png
23KB, 638x425px
So what is the difference between using a function or using the exame same text? Im using a loop to do the function and if i write the code it works but if i assign a function with exactly the same code and call the function after callin the loop, it starts by working but then just prints the same over and over again, pic related
>>
>>62273653
Is there a point at all?
>>
File: 1503941933681.jpg (15KB, 480x480px) Image search: [Google]
1503941933681.jpg
15KB, 480x480px
how would you implement a state machine in pure C
>>
>>62273680
because it never leaves the last while loop. move number= int(int(input...
>>
>>62273693
dumb emojiposter
>>
>>62273680
no related to your question but the recollatz function calls collatz three times, when you could just call it once and store the value
>>
>>62273693
you mean an automaton?
>>
>>62273680
>collatz(number)
>number=collatz(number)
hint: these lines do nothing
delete them and your program will be simpler, and the bug will be more obvious
second hint:                                                                                                                                                                                  delete recollatz
>>
Let's say, I have functions:
int a (char arg_a[]);
int b (char **arg_b);

I want function B to change the value of pointer, which points at arg_a inside the function A.
Do i do something like this?
int a (char arg_a[]) {
...
b(&arg_a);
>>
>>62273915
>mutation
>side-effects
HERESY
>>
File: 22o_filtered.jpg (80KB, 798x598px) Image search: [Google]
22o_filtered.jpg
80KB, 798x598px
Recreating a glass material in my c++ renderer whose exitant radiance is not dependent on view angle

TFW you can create a renderer from scratch able to make decent images and still know nothing about templates, move semantics, memory management and every other basic aspect of the language

where do you find motivation for that
>>
>>62273365
desu i didnt use a debugger until my first enterprise project, you can get by without it at some levels, but when you go out on the field, its a must...
>>
>>62273951
C++ is huge, no sane man learned it whole.
If someone learned it whole, he already went crazy.
>>
>>62273987
Wonder how much Bjarne actually knows.
>>
I've used C++ since the early 2000s and I still don't know all of it.
The programs with the most extensive use of language features I've seen were in HPC
Template meta-programming is very useful for expressing vector and matrix operations efficiently
>>
Hello, I want to make a prompt in c that accepts any number or certain special characters, like a or w. How would I create this? I can't scanf for an int, as it returns zero with any chars, and I can't try to get a char and convert it, as it would only cover 0-9.
>>
>>62274035
Does glm use something similiar? I can recognize they make extensive use of templates but nothing else in particular
>>
>>62274053
You check what value gets getch().
If it gets allowed values, you put them on the screen, if it doesn't, you don't, I don't, we don't, they don't.
>>
>>62274064
Just looked at glm.
It doesn't seem to use TMP / Expression Templates
Check out
https://en.wikipedia.org/wiki/Expression_templates

Basically you implement operators not as functions but as templates themselves
The compiler can then collapse complex expressions into simple statements, reducing the number of function calls,
all the while retaining high-level code style

Expression Templates are awful to debug, but once your library is in place, are efficient to work with
>>
>>62274116
>getch
fatal error: 'conio.h' file not found
>>
>>62274158
I've never heard about expression templates, I'll read something on it later
Thanks for your input
>>
>>62274181
you could use ncurses if you want
it has a getch function
>>
>>62273951
What kind of time is that render taking you?
>>
>>62274008
>no SANE man
>>
>>62274257
2 hours on a 9 years old dual core cpu before denoising the result

Was built to be easy to extend instead of performance (not that I would know how to make it performant anyway)
>>
File: Untitled.png (58KB, 741x709px) Image search: [Google]
Untitled.png
58KB, 741x709px
>>62271230
same
>>
I'm learning C++ right now as my first programming language. I've covered most of the basics, and am looking for a FP language to learn alongside it. I'd like to try something compact, with a lower learning-curve(so no Haskell), and preferably practical rather than purely academic.

I'm leaning F#, but have heard good things about Ocaml, Scala, and Scheme.

Can you guys offer any insight that could help me decide?

Is captcha a legitimate suggestion???
>>
>>62274350
nah it's part of the library i'm using to make the api: https://flask-restful.readthedocs.io/en/latest/fields.html
>>
>>62271195
About to go to uni for cs but already know fundamentals such as some algorithms and syntax (variables and what not) as well as oop am I wasting time by taking a college course or is it worth ?
>>
>>62274360
Oh, I see
>>
>>62274350
>>62274361
so do you go into every thread amd reply to random post just to shill your server right after? you've been doing this every day
>>
whats the fucking point of unions in C? if you have to keep track of the type that's in it anyways why not just make a variable for each possibility. what benefit does using a union give
>>
>>62274387
No, I select like 1 thread each day.

We're actually partnered with another Server, too, specifically FOR /dpt/
>>
>>62274402
The fields are aliased so the storage cost is that of the largest field.
>>
>>62274402
Because C needed "duck typing with a label-maker".
>>
>>62274402
I'm not really sure why they exist, but I did find it kind of interesting when I read about it
>>
>>62274402
>>62274469
You can use unions to conveniently access individual bytes of larger values / structs
>>
>>62274361
>/g/
>Discord
Sorry, you seem to get lost.
I can help you.
>>>/v/
>>
>>62274369
I dropped out because of the fact I had to sit through a year or two of classes just to get to things that I haven't learned yet.
Since it seems you're already set, you should give it one or two terms to figure out if you really should stick it out or quit.
>>
>>62274320
I should really get back to messing with my raytracer. I only got as far as stanford bunny shit.
>>
>>62274560
gets very addictive very soon
>>
>>62274523
can you give an example of t h at?
>>
>>62274767
typedef union {
uint16_t word;
uint8_t lowbyte, highbyte;
} u16_u8_t;
>>
>>62274523
undefined behaviour
>>
>>62274813
how would you use that? it can only store either the word, the low byte, or the high byte at a time. i must be missing something
>>
>>62274835
u16_u8_t word = 93;
uint8_t low = word.lowbyte;


however, this is not valid C (it's semantically incorrect, as it is undefined behaviour)
>>
>>62274402
C should really add discriminated unions, call them variants or something.

typedef variant {
float f1;
double d1;
} f1d1;

...

f1d1 value;
value.f1 = 3.f;
switch(value) {
case f1: /* can use value.f1 here */ ;
case d1: /* can use value.d1 here */:
};
>>
>>62274873
I suppose this would work weird if you modified it in the switch.
I guess you could have people do
float f1 = value.f1;
then modify it
and ban accessing it in the same switch after it's modified?
>>
File: 1479844678727.jpg (106KB, 554x439px) Image search: [Google]
1479844678727.jpg
106KB, 554x439px
I successfully solved the pointer magic problem and it feels actually nice to accomplish one more problem.
>mfw if I did this in higher language, I'd already end my task
Logic problems were more dangerous, like
while (**number == '\'' || **number != '\0') (*number)++;

instead of
while (**number == '\'') (*number)++;

I wanted to skip all apostrophes which go one by one, not all characters before the null terminator.
>>
>>62275020
I'm gonna say the default initialization of an int, which is 0.
>>
>21:17 at the East Coast
>thread is ded
>>
>>62275136
aren't burgers back in school?
probably mommy told em to go sleep early
>>
>>62271275
fruitloops
>>
File: file.png (37KB, 259x194px) Image search: [Google]
file.png
37KB, 259x194px
>>62271275
>>
File: 412986880.jpg (31KB, 410x400px) Image search: [Google]
412986880.jpg
31KB, 410x400px
>>62275194
>>
>>62275156
>aren't burgers back in school?
no
schools out cuz category 5 hurricane
>>
>>62275156
Get raped and kill yourself, you retarded fucking faggot sack of nigger shit with down syndrome.
>>
>>62275205
Do not bully the snek.
>>
>>62274347
Scala for practically in terms of employment
>>
>>62275227
take your meds
>>
I want to learn javascript. What resources should I use? Not my first language, but haven't really done anything meaningful either.
>>
>>62275343
>>>/g/wdg
>>
>>62275343
For what purpose? Browser? Server? Automation / general purpose?
Install any meme editor, download node through nvm, install eslint/jshint for your editor, regret every decision you've made up until now.
>>
linked list with function pointers y/n?
>>
>>62275358
im gay
>>
>>62275379
why
>>
>>62275376

Browser. general purpose. Sublime.
Python and C++ weren't that bad.
>>
>>62275343
JavaScript is an extremely simple language, which is why webdev faggots have to fuck it up with node, coffeescript, etc, same as CSS which pajeet wants to use SASS, LESS, etc
All you need to do is go to MDN and look at their JS reference, it's very simple, it's much easier than python or even lua
This is assuming you're coding sane JS, if you're using jquery or something like that then may god have mercy on your soul
>>
File: 1494643808575.jpg (26KB, 481x436px) Image search: [Google]
1494643808575.jpg
26KB, 481x436px
Is there a quick way to convert a unit vector to its corresponding location on the enclosed square? Since either x or y have to be 1, I'm guessing there must be an easy way that involves min(_,1)
>>
>>62275405
So you can chain callbacks and/or add conflict-free extensibility with custom hooks without having to fuck around with dependencies
>>
>>62275379
use C++ senpai
>>
>>62275417
sine and cosine
>>
>>62275417
You want to use the inverse square root
say you have the vector1 = (1, 12)
then you use pythagorean to get 145 and then scale your vector with inverse square root of 145, so you get (.08, .99)
~> bc -l
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
sqrt(145)
12.04159457879229548012
1/12.04159457879229548012
.08304547985373996882
12/12.04159457879229548012
.99654575824487962594
.99654575824487962594^2
.99310344827586206896
.08304547985373996882^2
.00689655172413793103
.00689655172413793103+.99310344827586206896
>>
>>62275453
The last line was supposed to be .99999999999999999999, don't know why 4chan swallowed it
>>
>>62275430
Wouldn't help
I'm thinking of using it to add functionality. You have a starting address like a linked list, that's a function pointer. The function that's pointed on declares a variable (another function pointer) global at the start, then at the end executes it. Or are you saying I should make the functions objects?
>>
>>62275453
That gives me the unit circle coordinate. I want the coordinate on the square.
>>
>>62275417
If you're talking about projecting the point onto the square, then do:

(x', y') = ( x / max(x,y) , y / max(x,y) )
>>
>>62275417
>>62275607 (You)
Wait, shit, wrong formula
(x', y') = ( x / max( |x| , |y| ) , y / max( |x| , |y| ) )
>>
>>62275343
Crockford's JavaScript: The Good Parts is essential reading.
>>
File: 1504563112368.jpg (24KB, 301x267px) Image search: [Google]
1504563112368.jpg
24KB, 301x267px
>>62275624
That's it. Thank you.
>>
>>62275574
oh
just get the angle of the vector then calculate where it should be on the square (break it up into 8 different pieces then map coordinates)
>>
>>62275411
jquery is a cancer.
Have a problem? jquery
Need to implement x? jquery
Want a bigger dick? jquery
>>
Quick bash shell question (not sure if scripting counts here)

I am writing a script to compare one unsorted list of emails to another unsorted list of emails and outputting any matching results to a textfile.

When I do

comm -12 "file1" "file2" > file3


I end up with an empty file3. Suggestions?
>>
>>62275680
remove the parentheses around the filenames
>>
>>62275729
No dice with and without parenthesis.
>>
File: js-good-parts.jpg (832KB, 3264x1836px) Image search: [Google]
js-good-parts.jpg
832KB, 3264x1836px
>>62275411
jQuery is not a language, you can't compare Javascript to jQuery. You don't say you're a "libcurl programmer" if you write a lot of C software that uses the cURL library.
SASS and LESS have objective, measurable benefits over CSS.
It's not the "webdev faggots" who brought in the tools/platforms/etc to get JS *out* of the browser.
The "javascript" of today is not the "interactive browser language" of the 90s and basically you're fucking stupid.

>>62275645
heh
>>
>>62275761
is comm a script you wrote? if so, what do you expect me to tell you?
>>
Is it just me or are there a lot of people posting Java questions and answers online who have a really poor grasp of programming?
>>
>>62275794

comm is supposed to compare two sorted files line by line and write to standard output: the lines that are common, plus the lines that are unique.

Output is in 3 columns
col 1 is unique lines to file1
col 2 is unique line to file2
col 3 is matching lines
>>
>>62275843
It's not just you, and it's not just Java, but it's especially Java because Pajeet must do the needful and revert ASAP.
>>
Is the inner loop log base 2 because it increments by K*2?
>>
>>62275855
Ahh, I think I see now, makes sense with sums/integrals.
>>
What the fuck, how does this work?

public string toRoman(int num)
{
int[] values = new int[] { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 };

string[] numerals = new string[]
{ "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" };

StringBuilder result = new StringBuilder();

// Loop through each of the values to diminish the number
for (int i = 0; i < 13; i++)
{
// If the number being converted is less than the test value, append
// the corresponding numeral or numeral pair to the resultant string
while (num >= values[i])
{
num -= values[i];
result.Append(numerals[i]);
}
}
// Done
return result.ToString();


I have no idea how a numeral would get repeated, like XXX with that for loop, but it does work. I don't get it.
>>
>Optional isn't serializable in Java
Why the fuck not?
>>
>>62275843
Java is really popular and widely used. Makes sense a lot of people are trying to learn it.
>>
>>62275849
the man page says it compares two SORTED files. are they sorted?
>>
>>62275887
Nice leaks.
>>
>>62275904
Yes.
>>
>>62274873
They're called “tagged unions,” and you can (somewhat poorly) emulate them like this:
typedef struct {
enum { FLOAT, DOUBLE } type;
union {
float f;
double d;
}
} f1d1;
>>
>>62275909
gc will clean it up
>>
>>62275887
look at what the inner while loop does. look at its exit condition, and what the inner part of it does. run through it by hand on the number 30
>>
>>62275772
jQuery isn't a language, it's just a lot of shit bolted on to JavaScript that should never have existed in the first place
>SASS and LESS have objective, measurable benefits over CSS.
Yes, but the primary goal was to ensure webdev hipsters got a toolkit like the big guys with compiler etc (grunt)
>It's not the "webdev faggots" who brought in the tools/platforms/etc to get JS *out* of the browser.
node is run by webdev faggots
>The "javascript" of today is not the "interactive browser language" of the 90s
that's not a good thing
>>
>>62275909
I didn't even write it, I'm just curious as to how the fuck does it work. That for loop should only run through the string array once, I have no idea as to how num = 30 prints XXX.
>>
>>62275927
They're called sum types, discriminated unions, variants AND tagged unions, and I know you can EMULATE them
>>
>>62275956
It's not the for loop that gives multiple instances of the same string, it's the inner while loop.
>>
>>62275956
                while (num >= values[i])
{
num -= values[i];
result.Append(numerals[i]);
}


get a piece of paper, and make a column for num. make a place to store the values string. write 30 in the first spot for num, and go through this code line by line until you exit through the bottom
>>
>>62275995
>>62275999
oh wow I'm retarded, I don't know why I couldn't see that...
>>
>>62275971
>not the coproduct in the category of types
>>
>>62276028
>not an ADT
>>
File: 1502289725200.png (507KB, 595x639px) Image search: [Google]
1502289725200.png
507KB, 595x639px
>>62276097
baka
>>
>>62274402
It's useful for when you need to fake polymorphism. Imagine a Tree struct made of Node structs where a node can contain either an int or a string. You need two fields for the Node struct, an enum to state what the Node is holding (int or string) and the data itself with a union.

This is commonly done for ASTs in compilers written with C.
>>
File: 1493596526470.png (364KB, 650x750px) Image search: [Google]
1493596526470.png
364KB, 650x750px
>>62276138
Why is Karen so shit? She ruined the whole episode.
>>
>>62276201
void pointer :^)
>>
>>62276227
Cast it.
>>
>>62276201
oh ok i get it. thanks
>>
>>62276227
That's disgusting and I feel disgusted. Disgusting.
>>
>>62276241
Why would you cast the return value of malloc?!
>>
>>62276201
Oh and to add the Node struct obviously needs to have two pointers to Nodes as members to be a tree.
>>
File: you wouldn't cast malloc.png (119KB, 563x378px) Image search: [Google]
you wouldn't cast malloc.png
119KB, 563x378px
>>62276279
Dressing up as a cute girl does some crazy shit to your brain
>>
>>62275876
>he doesn't use finite calculus to evaluate his sums
>>
>>62276279
>casting

int main(float argarbagecollector, char ****argreatval) {
int x = 200;
double y = x;
char z = y;
void *w = &z;
float *v = w;
return *v;
}
>>
File: 419238413.jpg (50KB, 1024x855px) Image search: [Google]
419238413.jpg
50KB, 1024x855px
>>62276540
>>
>>62276540
>yfw that's still casting, just implicitly
>>
a, b = b, a
arr[1:3] = [a, b]
print(*arr, sep='\n')


Non python programmers will never know this feel.
>>
>>62276658
>mutability
>>
>>62276707
>not mutability
>>
>>62276785
>not mutability
yes please
>>
>>62276658
>arr[1:3] = [a, b]
I didn't know this
neat
>>
>>62273693
pls tell us
>>
it's a comp sci related job so its related
http://www.strawpoll.me/13871583/
>>
>>62277220
>adult human male
>doesn't own a suit
go to macys or something
but whatever you do don't ask /fa/
>>
>>62277220

Just grow a beard, wear thick black classes, and wear flannel and jeans. And for shoes anything Nike will do.
>>
>>62272863
How about this
def diamond(lines, stars, end, width):
for line in range(lines, end-1, -1):
spaces = (width-stars)//2
print(' '*spaces + '*'*stars)
stars += 8*(lambda x: -1 if x<=0 else 1)(line)
diamond(5, 2, -5, 80)
>>
>>62271195
Taking the Nock decrement challenge and learning Hoon.

So fucking comfy.
>>
>>62277220
if it's a programming interview and you show up in a suit you'll absolutely never get hired
>>
New thread:

>>62278156
>>62278156
>>62278156
Thread posts: 316
Thread images: 34


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