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

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

Thread replies: 255
Thread images: 25
File: 1467398868589.jpg (475 KB, 852x973) Image search: [Google]
1467398868589.jpg
475 KB, 852x973
Previous thread: >>55568572

Free functions are not OOP edition
>>
>>55572999
Java is notOOP becasue Java is not Smalltalk
>>
void f(int x); // this is oop, x receives the message
>>
explicit this pointers to structs as a function argument is not OOP in disguise
>>
>>55573088
>not OOP in disguise
right, it's just plain OOP
>>
I have a programming stupid question -

I made a twitter bot and now want to upload it to github, what do I do about the auth keys? Do I just take them out before committing changes?
>>
File: anime.png (201 KB, 335x365) Image search: [Google]
anime.png
201 KB, 335x365
What are you working on, /g/?
>>
>>55573118
b-but anon im intelligent, please believe me or ill be a bigger retard


(im just impersonating a retard in the last thread)
>>
you can only do OOP in java, don't you know
>>
File: 1468483545166.jpg (68 KB, 1039x638) Image search: [Google]
1468483545166.jpg
68 KB, 1039x638
>>55573153
>(im just impersonating a retard in the last thread)
>>
File: rgbperlin.png (519 KB, 800x600) Image search: [Google]
rgbperlin.png
519 KB, 800x600
I did this yesterday for one of those roll what to code meme threads (random image generator).
http://pastebin.com/e254Gugk

What are those weird vertical and horizontal light strokes? They shouldn't be there.
I followed this tutorial http://lodev.org/cgtutor/randomnoise.html and you can see the same problem on the pics there. I tried to modify it in different ways to see what's happening here but I could only ever make it worse.
Can someone tell me how to get rid of those light strokes? Is that something with floating point precision?
>>
>>55573139
reading up on IO completion ports and how to use it with sockets, sounded kinda intimidating when i first heard about the magic it is, now, not at all.
>>
>>55573185
>What are those weird vertical and horizontal light strokes?
it's from linear interpolation
use bicubic or something more advanced
>>
File: 1400658390982.png (527 KB, 858x1000) Image search: [Google]
1400658390982.png
527 KB, 858x1000
>>55573174
you werent there? oh man, you missed something glorious
>>
>>55573185
>>55573223
(cont)
also check this article, the pictures show the difference between the two https://en.wikipedia.org/wiki/Bicubic_interpolation
>>
>>55573185
>>55573223
friendly reminder that you can express perlin noise comonadically
>>
>>55573126
Put them in a seperate file, and load them from your script. Then add the seperate file to your .gitignore
>>
>>55573185
could be an artifact of the noise itself
>>
>>55573286
Thanks anon. Just googled around and got the same idea before you responded.
>>
>>55573223
Thanks.

>>55573266
>friendly reminder
I'm a noob if that wasn't obvious in my previous post so that's not really a reminder to me.
"Comonadically" means it has something to do with functional programming, yep?
>>
Explain to me monads and why they are useful like I'm 5. Every article I found is difficult to understand.
>>
>>55573343
perlin noise can be expressed with a zipper, and all zippers are comonads

now you know
>>
File: monad diagram.png (26 KB, 334x358) Image search: [Google]
monad diagram.png
26 KB, 334x358
>>55573362
Monads are applicative functors with a join operation (M (M a) -> M a)
>>
>>55573389
I don't understand, what is a join operation? What are applicative functors? What is (M (M a) -> M a) supposed to mean?
>>
>>55573389
sounds a bit like category theory, yea?
>>
>>55573416
M (M a) -> M a
is the type signature of "join"
join is simply a function that has this signature, that is specific to a particular monad

M a is like M<a> in other languages

An applicative functor M is a functor that has the following additional operations
pure :: x -> M x
(also called "return" for monads)
ap :: M (x -> y) -> M x -> M y
(apply, <*>)
>>
>>55572999
It's me again:
>>55572271
>>
>>55572999

I'm reading this and it's really cool. Atleast the parts that I can understand are.

My question is how can you perform a bitwise operation such as AND on 2 binary numbers of different size?

Am I correct to assume that you would line up the binary digits so their MSB allign and perform the operation on corresponding bits?

Is that what it meant by defining negative numbers as being preceded by an infinite amount of ones?
>>
>>55573419
Yes, monads are from category theory

>>55573470
0 is the identity for AND, so I assume by substituting that for the other digits
>>
>>55573470
0101 & 10011001 -> 00000101 & 10011001
>>
>>55573470
No you would line up the LSB
>>
>>55573470
this >>55573499
which is because 0101 = 101 = 00000101
>>
>>55573487
i see, i never studied any haskell and have only recently begun reading up on category theory.
call me out if im wrong, but i would rather think of perlin noise as an endomorphism, or at the very least a homeomorphism
>>
>>55573460
Thanks for trying to explain but it's like you are talking in another language. I can't understand shit.
>>
>>55573579
What languages do you use?
>>
>>55573499
>>55573530
this but keep sign extension in mind (or just don't do bitwise operations on signed integers, at least not in C/C++)
>>
>>55573362
http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
Have you read this? It's probably the best tutorial out there.
>>
>>55573607
C, Perl, Python, Javascript and I know a little bit of Common Lisp.
>>
>>55573632
>no types whatsoever
>>
>>55573632
just google monad and the other things, you won't learn anything from a post
>>
>>55573632
learn a language with static typing
ideally haskell
>>
>>55573665
C is statically typed.
>>
>>55573649
>>55573665
>C is not statically typed
>>
>>55573665
>hurr hurp durp
>>
>>55573676
>>55573678
Oh shit, I didn't see C was there
C doesn't have generics or HKTs though
>>
>>55573626
I did read it in the past but didn't really understood it.

>>55573665
I do want to learn haskell however I fear that if I do not know basic stuff such as what is a monad I will not be able to do shit with it.
>>
>>55573684
>jumping on the bandwagon
shame on you

>>55573690
monads aren't really basic in the sense that you don't need to understand them to use haskell
>>
>>55573185
:30:2: warning: passing argument 1 of ‘generateNoise’ from incompatible pointer type [enabled by default]
:12:6: note: expected ‘double (*)[800]’ but argument is of type ‘double **’
:31:2: warning: passing argument 1 of ‘generateNoise’ from incompatible pointer type [enabled by default]
:12:6: note: expected ‘double (*)[800]’ but argument is of type ‘double **’
:32:2: warning: passing argument 1 of ‘generateNoise’ from incompatible pointer type [enabled by default]
:12:6: note: expected ‘double (*)[800]’ but argument is of type ‘double **’
:33:2: warning: passing argument 1 of ‘updateScreen’ from incompatible pointer type [enabled by default]
:10:6: note: expected ‘double (*)[800]’ but argument is of type ‘double **’
:33:2: warning: passing argument 2 of ‘updateScreen’ from incompatible pointer type [enabled by default]
:10:6: note: expected ‘double (*)[800]’ but argument is of type ‘double **’
:33:2: warning: passing argument 3 of ‘updateScreen’ from incompatible pointer type [enabled by default]
:10:6: note: expected ‘double (*)[800]’ but argument is of type ‘double **’
: In function ‘updateScreen’:
:58:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
:58:2: note: use option -std=c99 or -std=gnu99 to compile your code
:59:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
: In function ‘generateNoise’:
:69:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
:70:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
: In function ‘mipmap’:
:91:2: error: ‘for’ loop initial declarations are only allowed in C99 mode


top kek
>>
>>55573687
>C doesn't have generics or HKTs though
good
>>
>>55573706
can't spell faggot without Go
>>
>>55572999
All anime girls that program in C are instant waifu material to me. Say to to shit girls who like java or python.
>>
>>55573698
I do know that haskell uses monads in multiple things such as for IO or for stuff such as the maybe monad but I never really used it so I might misunderstand their importance.
Well, I guess my only hope is to learn about them while learning haskell. Thank you anon.
>>
>>55573730
*say no to
>>
>>55573698
You have to understand the basics of monads in haskell and how to use them for that.

I am ok-ish profficient with haskell and have no idea why monads exist outside of haskell and how to use them.
>>
>>55573730
What about cute boys that look like girls and program in C?
>>
>>55573730
>who like java or python.
please tell me what's wrong with java or python with credible arguments
>>
>>55573771
They are shit
>>
>>55573730
>>55573751
excellent taste

>>55573765
I mean you can program in haskell while not understanding monads
Monads in category theory are like those in haskell, except with join rather than bind


>>55573771
>credible arguments
>inb4 any argument that says they're bad is "not credible"
>>
>>55573770
http://www.nimh.nih.gov/health/find-help/index.shtml
>>
>>55573771
python is great
I have some problems with java, but if it were the only oop language I'd use it
>>
>>55573788
>>55573789

Not an argument. try again you memelord
>>
>>55573741
I'm not sure how you want to understand monads. If you want to understand the mathematics behind it, read 'Notions of computation and monads' and other articles by Moggi. But you seem to be too retarded to comprehend them on this level. If you only want to acquire an intuition, just learn Haskell and use them.
>>
>>55573703
What? It's just warnings.
>>
>>55573770
it's treatable, there's still hope for you
>>
>>55573771
>expecting people on g to have arguments outside of "i dont like it"
having a proper discussion is impossible man
>>
Stop spamming the real thread with links to this shit, mentally ill faggot!
>>
>>55573819
>It's just warnings.
lmao

you don't ship software with "warnings"
>>
>>55573849
What's wrong with the OP?

>>55573810
No need to be such a dick
>>
I just want to tell someone that I think btn-default btn-block looks really good.
>>
>>55573859
>you don't ship software with "warnings"
truth be told, you never ship
>>
>>55573899
not always, but when i do i break everything
>>
>>55573894
i told you to google it

that faggot obviously learnt some basic haskel shit so he just shits on your head with explanations that explain unknowns in terms of more unknowns
>>
>>55573516
Okay... I'm a bit less confused now... So basically, I need to check whether the Fibonacci sum will be an overflow, which can be done by
 if(logBASE2(num1) + logBASE2(num2) > static_cast<int> (logBASE2(MAX_long_long) ) 


and if it returns true, the sum overflows...
Now (and I know this is beyond stupid of me to even ask at this point), how would I do this:
>then allocate more bytes apply operations on them as partial solutions
I'm guessing it has something to do with logarithms, but I can't think of anything...
>>
>>55573919
I am 'that faggot'

I told him to learn some Haskell so he'd understand functional programming and parametric types, so he could learn the signatures, so he could then learn stuff like effects and coeffects
>>
File: ?.png (7 KB, 120x120) Image search: [Google]
?.png
7 KB, 120x120
>Current Job Openings
>Hacker / Software Engineer

what do?
>>
>>55573973
If you're hair isn't blue or pink, your not getting hired.
>>
>>55573973
>job
>hacker

>job
>software """"""""""""""engineer""""""""""""""

man
>>
>>55573987
shit stain how many times was a person with blue or pink hair hired over your ass
>>
File: Code.png (24 KB, 1165x651) Image search: [Google]
Code.png
24 KB, 1165x651
A bit new to C, building a game board. Anyone know how I would change the for statement to not constantly print out C? I need it to print out C for the first tile, W for every 3rd tile, L for every 5th tile and G for every 7th tile. Been stuck on this for a bit
>>
>>55573958
no logs at all, it would be like if you had 2 bytes and tried to add 0x01 to 0xFF, you would then first detect the overflow, then allocate another byte, set the first byte to the overflowed value and then add the 1 to the 2nd byte, if that makes sense.

also the log trick might be a litle computationally expensive, if you have the possibility to, i would query the cpu status register for its overflow bit.

let me know if that helps
>>
>>55573959
I do know about functional programming and parametric types, I find the signatures unclear however.
>>
>>55573958
My bad...

if(logBASE2(num1) + logBASE2(num2) > static_cast<int> (logBASE2(ULLONG_MAX)*2 )  
// Because ULLONG_MAX = 2^64-1, which when the log2 is truncated, is the same as logBASE2(2^63)
>>
>>55574008
twist: he's a 2D anime-kin and he keeps getting turned down in favor of 2D anime girls.
>>
>>55573771
In the case of Java, C# exists.
>>
>>55574027
M a means M<a> in some other languages

a -> b
means a function that takes an 'a' and returns a 'b'

a -> b -> c = a -> (b -> c)
a function that takes an 'a' and returns a 'b -> c'
(this is also like a function that takes two arguments, 'a' and 'b', to give a 'c')

A monad (in Haskell) is some type M for which there exist functions
fmap :: (a -> b) -> (M a -> M b)
-- from functor
return :: a -> M a
-- from applicative
bind :: (a -> M b) -> (M a -> M b)

(this is ignoring applicatives, but that's not really important atm)
>>
File: ms200qaGqw1r5eorto1.gif (280 KB, 414x234) Image search: [Google]
ms200qaGqw1r5eorto1.gif
280 KB, 414x234
>>55573730
I bet your joke of a waifu only ever uses graphical interfaces for everything. How lame.
>>
>>55574069
>means M<a> in some other languages
Such as what languages? Is it like a template in C++ or something?
>>
>>55574113
Yeah
>>
>>55574115
In that case, does
return :: a -> M a
for example mean that return takes an argument a and returns the same argument with a type M? Because I am not sure if I understand that correctly.
>>
>>55574150
Yes
>>
>>55574150
M is a parameterised type of kind (type -> type), so M a is a type.
>>
>>55574174
>>55574175
Thanks
>>
>>55574150
>>55574192
for instance, Lists are a monad, so
return x = [x]
-- list consisting of one element
Maybe is also a monad
return = Just
-- return x = Just x


There are additional laws that are needed for monad operations but they aren't important atm, most of the time if you've got the signatures right then it'll work anyway
>>
>>55574014
Question, why did you type three for loops instead of a nested for-loop?

int(i = 0; i < s; i++)
{
int(j = 0; j < s; j++)
{
if(i==0 && j==0)
//Print 'c'
if(j%3 == 0) //Every third tile
//Print 'w'
if( ((i*s)+(j))%5 == 0) //Every 5th tile
//Print L
...
}
}
>>
>>55574024
I sort-of understand the explanation, but without logarithms, how would you detect the overflow? You would have to add the numbers first (or their logarithms, if you're doing what I did), and check if the value overflows

unsigned a,b,c;
a = b + c;
if (a < b) {
/* overflow */
}


And another question, how would you "allocate another byte"? That's the part I'm really stuck on...
>>
>>55574361
you can also just use arrays as numbers

array of length 10000 could represent a number of length 10000 and do addition, multiplication and division algorithms on top of that

like {1,2,3} could be number 123

much easier and more general
>>
>>55574530
> {1,2,3} = 123
What's {10, 2, 3}
>>
>>55574361
to detect the overflow, i would use an intrinsic, depending on the platform you are working on it could be something like __getcallerseflags which returns the flags for the cpu (https://en.wikipedia.org/wiki/FLAGS_register)

allocating the additional byte would, again depening on your language be either a realloc call in C or something like a vector<byte>::push_back()
>>
Got a long weekend to work on my pet project.
Should I give it a weeb friendly name or go for some obscure norse pagan name?
>>
>>55574567
135 in base 10, assuming base 11.

I'd prefer a, 2, 3
>>
>>55574648
10 is not a digit in base 10
>>
>>55574665
oh nvm, misunderstood

>>55574648
So there are multiple representations per number?
>>
>>55573973
Read: code bitch for tech-illiterate, idea-guy startup founder
>>
>>55574665
I know, that's why I said 135 in base 10, which is 10|2|3 in base 11
>>
>>55574625
Norse name, Anon.
>>
>>55574567
>What's {10, 2, 3}
invalid
>>
>>55574688
So it just picks the base that's *just large enough* to hold digits?
>>
How do I save formulas in the best way? Basically I want to be able to save something like "x^2 - ab" and then later be able to modify it, and get back the original meaning of the string. So I would be able to do something like assign an integer value a, b and x and get out an integer.
>>
>>55574702
Nigga, I don't know, I was just being facetious that some faggot wanted to put a 10 in a single-digit placeholder.

I'm not the one who was suggesting that retarded array idea.
>>
>>55574726
A method/function.
>>
>>55574702
regardless of the base, theres only so many unique values a byte can hold
>>
>>55574727
what's retarded about it
>>
>>55574726
data Λ a = Var a | Abs a (Λ a) | App (Λ a) (Λ a)
>>
Guys, I have a problem. I used to write a lot of OOP crap in C++ and it's really hard for me to switch back to C and get rid of that object oriented way of thinking. Can you recommend any books to help me with that? I was thinking about "C Interfaces and Implementations: Techniques for Creating Reusable Software".
>>
>>55574744
Can functions be inputs to other functions though? And can function output functions? Cause I don't think they can.

>>55574774
How does that help?
>>
>>55574792
sicp
>>
>>55574802
fundamental unit of computation
>>
>>55574792
Practical Common Lisp, then ECL to transpile into C
>>
>>55574792
Emulate OOP in C.
>>
>>55574802
>Can functions be inputs to other functions though? And can function output functions?
Yes.

Yes.
>>
>>55574858
>>55574802
in C you can't _really_ output a function
>>
>>55574792
typedef struct
{
int hp;
int strength;
} dragon;

dragon* new_dragon()
{
...
}

void delete_dragon(d *dragon)
{
...
}

void dragon_fight(d1 *dragon, d2 *dragon)
{
...
}
>>
Sup /g/

I want to build babby's first website for a family member's small local restaurant. What's a simple reliable platform to get this done on?

Wordpress? Where should I host it?
>>
>>55574897
I never said anything about C.
>>
>>55574858
So let's say I have the function
int foo(int x) {
return 0;
}

Now I want to turn that function into:
int foo(int x) {
return 0 + x;
}

How would I do that?
>>
>>55574938
Oh I was thinking of what >>55574792 said, sorry
in most languages you can output functions or at least have what C++ call functors
>>
>>55574948
With a text editor or IDE.
>>
>>55574948
Type "+ x" just as you did here, it's that simple.
>>
>>55574361
heres an example of what i mean you could do, you just have to generalize it a little to work with more than just one byte additions

#include <vector>

using byte = unsigned char;

int main() {
byte a = 0xFF;
byte b = 0xFF;

std::vector<byte> bytes;
bytes.push_back(a);
short c = bytes.back() + b;
if(c > 0xFF)
{
bytes.back() = c & 0xFF;
bytes.push_back((c >> 8) && 0xFF);
}

return 0;
}


the expected output is an array of { 254 , 1 } since that in little endian are the two bytes representing 510
>>
>>55574936
http://gohugo.io/
Host yourself.
>>
>>55574993
>>55574971
Except I want it to be automated, with about 1000 or so of these changes added randomly (within certain parameters).

So for example the 0 + x could turn into 0 + x + 5, and then into (0 + x + 5) * 2, etc.
>>
>>55574948
with function pointers?

using F = int (*)(int);
F f = &foo;
f(5);
f = &bar;
f(5);


you gotta have the functions defined though, otherwise id say youd need an interpreted language if you want to modify foo itself
>>
>>55575035
What language are you using?
>>
>>55575035
i think you should read up on function decomposition if this is the kind of behavior you want, maybe even lambda calculus to get a better idea for it
>>
File: Screenshot_2016-07-14_14-17-14.png (69 KB, 782x428) Image search: [Google]
Screenshot_2016-07-14_14-17-14.png
69 KB, 782x428
Reading up on K&R, I have some doubt with this piece of code. The first while loop increments where argv is initially pointing at, so it would be at the start of the second member. It deferences it and then access the first element seeing if it's a hyphen.
What I don't get is the second while loop. This should be incrementing the pointer of that second argument so it would be point at whatever is next after the hyphen, but I don't get how it works with leaving it with [0] as well. I suck.
>>
>>55575109
Scratch, that, I figured it out as I was typing it. I still suck.
>>
>>55575059
Yeah, using an interpreted language (Python) basically solved my issue. I can do something like:
equation = "x*x"
x = 10
print(eval(equation))

equation = equation + "*x"
print(eval(equation))

and get 100, and 1000 as output. Wonderful!
>>
File: 1467019345752.jpg (10 KB, 180x157) Image search: [Google]
1467019345752.jpg
10 KB, 180x157
>>55575166
>eval
>>
>>55575035
Sounds like you might want to do some sort of string comprehension mixed with the shunting yard algorithm.
>>
>>55575035
abstract syntax tree
>>
>>55574726
Language?
>>
>>55575068
>>55575283
Programming isn't about languages. SICP is a dumb meme book, n00bs.
>>
File: dosbox_004.webm (1 MB, 640x480) Image search: [Google]
dosbox_004.webm
1 MB, 640x480
>>55570451
Now I'll have to prepare data that display a rotating cube. But rotating two-dimensional shapes is interesting too.
>>
>>55575320
we 3d engine when?
>>
>>55575307
True but there are easy ways to do this and hard ways to do this depending on his choice of language.
>>
>>55575109

I haven't looked at K&R in a while, but man, I wonder what they were smoking in the Bell Labs to consider that this was all a good idea.
>>
>>55575574
probably some dank "achieved more than you ever will in your entire lifetime" kush
>>
>>55575626

Probably.
>>
Reminder not to use languages like rust, goland, or swift because they are SJW languages. Especially rust.
>>
>>55575772
But Mozilla is behind Rust. Of all the C++ replacements it has a chance to succeed, no?
>>
>>55575574
burger king
>>
>>55575792
Just write it yourself in C++
>>
>>55575820
It looks promising desu, but they borrowed everything that looks terrible syntax wise from C++ and put it in their language.
>>
I haven't coded anything since university, about 5 years ago. I sell chemical products now. I thought that making a program to automate certain tasks would be easy and effective, naive little me.

I tried with python but I hate what Qt became so I won't use PyQt, Wx looks old as fuck, and tk is the same shit.

I know how to code in C and C++. "Maybe I'll find a better option in C++, it's good for native applocations". Again Qt hate it, and I could not find anything decent, a bunch of indie ridiculous libraries and some decent looking but not good enough

Is java my only option :( ?

Even thought I know it sucks starting from the language, which I find quite confusing (when working with GUI, not cml programs), and the java viirtual machine takes ages to load.

Does programming sucks in 2016?

recommend me something
>>
>>55575792
awk
>>
>>55575927
C# if it's windows, can't get comfier than this.
>>
>>55575927
C# is probably what you're looking for.

It's super fucking easy to make relatively pretty GUI apps with something like MahApps, or even just the native WPF components.
>>
>>55575958
>>55575993

Really? I'll look into that, thanks
>>
>>55575307
>Programming isn't about languages
That's pretty much SICP is about, you fucking retarded mongrel.
>>
>>55576025
Visual Studio has a pretty comprehensive drag-and-drop GUI builder, and once you "get" XAML, it makes interactions between the logic and UI pretty straightforward.

You can always do WinForms, too, if you want to get super simple + cross platform to Linux/OSX.
>>
I have to port a PNG reader in python 2 to python 3

Why is everything so fucked?

What did they change that prevents you from reading a file as a hex string? Why doesn't binascii.hexlify() work on strings anymroe?

how do you convert a "bytes" object to a string containing hex?
>>
>>55575182
js fag detected. sup fampai
>>
>>55576057
Please refer to the documentation.
>>
>>55575957
Just use regex, it's literally just reading files and replacing
>>
I only ever programmed in college, some VERY basic C++.

I want to learn more, about real programing. How do i even begin?
>>
Hey guys I actually would like to see some projects finished, share your git, or your webpage. Even an explanation of your program would be nice.

I start a lot of projects but there is no reason to finish them anymore I get bored, help me get motivated. Share your awesome code and genius ideas to this comunity
>>
>>55576105
If you know basic C++, Learn more, from a book. Tutorials, youtube videos or online courses are for teenagers MaZteR L337 H4x0rs.

then get a nice GUI library and get to work on the project of your dreams
>>
>>55575009
Alright.. So I did some research (because I have literally zero experience working on byte operations), and am having a bit (no pun intended) of trouble understanding what you did

So you put the value of a in the vector bytes (which has a 1-byte storage for each element), and create a short (2-byte data type), c, that stores a+b.

Then, you check for an overflow, add the least significant byte into the vector
//This line:
bytes.back() = c & 0xFF;

, and finally, add another space to the vector, which is initialized to c shifted 8 bits, right?
I'm not 100% sure what this line does:
         bytes.push_back((c >> 8) && 0xFF);


I'm sort of understanding it, but I'm having trouble seeing why the output of the array would be (254, 1) and not (255, 1)

tl;dr, I suck at byte operations
>>
>>55576139

No other language sugestion? Is it good enough to carry me foward?

Also, any book in particular?
>>
>>55576191
C++ Primer is pretty good for a beginner.
>>
>>55576081

Please refer to fuck off
>>
>>55573139
Implementing a binary search function in C without recursion.

I'm a brainlet tbqh familia.
>>
>>55576108
>finished
Surely you jest.

There are always improvements to make, and it's hard to call something 'finished' just because you satisfied the scope.
>>
Anybody else feel /fuckingRetarded/ here?
>>
>>55576400
What did you do?
>>
>>55576400
Not really, no.
>>
>>55576400
Me... I'm this guy(>>55576144), and I'm having such a difficult time displaying numbers larger than 2^64 - 1
>>
>>55576144
the (c >> 8) shifts the upper 8 bits down into the lower 8 and then does the same as before with the & 0xFF.
we know that
255 + 255 = 510 same as
1111 1111 + 1111 + 1111 = 1 1111 1110 now the last 8 bits are in the first slot of the vector and has a value of 254, the next slot is then added and set to the contents of the higher 8 bytes shifted down this value is 1 in the vector, but since we need to consider the whole of the contents of the vector we can calculate the actual number contained within it as follows
value = sum over i [ 2^(8 * i) * bytes[i] ]
>>
>>55576414
I'm this >>55576295 faggot. Can't figure out an elegant way to exit the loop if the search term isn't in the array.
>>
>>55576572
break ?
>>
>>55573315
You mind linking your github repo?
>>
>>55576048
>XAML
Can anyone explain to me in a very dumbed down manner what XAML is?
>>
>>55576611
XML with an 'a' in it
>>
>>55573487
1 is the identity for and, 0 is the absorbing element
>>
>>55576629
Oh shit, of course

Is 'absorbing element' the right term?
I know it's like 'multiplicative zero'
>>
>>55576640
https://en.wikipedia.org/wiki/Absorbing_element

wikipedia seems to agree
>>
File: 1468380638744.jpg (12 KB, 474x473) Image search: [Google]
1468380638744.jpg
12 KB, 474x473
>>55575574
>5.11 Pointers to Functions
The absolute madmen.
>>
File: 326551454.gif (10 KB, 300x169) Image search: [Google]
326551454.gif
10 KB, 300x169
>>55576620
>>
>>55576424
Huh... That made a lot more sense than I thought it would... Thank you!

I'm going to try to implement this into a general addition function of sorts that can work with ints (I'll worry about longs and higher numbers later)
>>
>>55576659
Ah

Is there a word for anti-closure / things that operate like primes under multiplication?
>>
>>55576704
its a good place to start, it should be relatively straight forward to make it take any size of whole numbers.
best of luck and have fun messing around with it
>>
>>55576762
You're a lifesaver, man... Thanks for helping!
>>
File: 1399946755399.png (897 KB, 970x930) Image search: [Google]
1399946755399.png
897 KB, 970x930
>>55576822
np glad to help
>>
File: ktomdmr.png (652 KB, 539x473) Image search: [Google]
ktomdmr.png
652 KB, 539x473
>>55576664

dmr would be ironically handsome by today's standards.
>>
>llvm takes ages to compile
makes me wonder how they test it
>>
>>55576705
>Is there a word for anti-closure / things that operate like primes under multiplication?

example?
>>
>>55576935
primes under multiplication

N is the natural numbers
N is equipped with *
P is a subset of N

for any x, y in P
x * y is not in P
>>
>>55576664
function pointers are great
>>
>>55576950
ah, as far as I know you just say P isn't closed under *, can't think of any antonym for closure
>>
>>55576963
might ask /sci/
>>
I wanna code something in python or C# to increase my skill, but I don't know what to make.
>>
>>55576967
why would high schoolers know anything about closures?
>>
>>55576980
Go to project Euler and do as many exercises as you can.
>>
>>55577006
bullshit
>>
Really dumb question, but is there a language that would allow me to make an array of 200 trillion?
For hw I was given a problem, and realized that there would have been 200 trillion permutations for how I initially wanted to solve it.
I've found a more suitable solution, but I just want to make sure I don't sound like an idiot when I say in my report, "there aren't any languages that allow one to make an array of 200 trillion elements."
>>
>>55576980
write a program that when run outputs its source code
>>
>>55577079
you already sound like an idiot imo, this is ultimately not a language thing, it's how much main memory you have

unless you write shit to your harddisk, which you probably can

Can you? Anyone? Am I retarded. Thx
>>
>>55577096
>>55577006
Thanks
>>
>>55577097
Right, but I wasn't sure if there are computers that use languages meant for problems like that where the only solution is by numerical means.
>>
The only times getaddrinfo will return more than 2 addrinfo structs are:
- Multiple IPs for a given hostname
- Multiple default ports for a service requested by its name

Correct?
>>
>>55577096
rate
#include <stdio.h>

int main()
{
FILE *fptr = fopen(__FILE__, "r");

char c = fgetc(fptr);
while (c != EOF) {
printf ("%c", c);
c = fgetc(fptr);
}
puts("");

fclose(fptr);
return 0;
}
>>
A fun project is a program that will take an arbitrary program as input and tell the user whether or not it will complete its run.
>>
>>55577213
not portable
>>
>>55577225
burger king
>>
>>55577225
Mcdonalds
>>
>>55577258

I don't get it.
>>
>>55577225
A funnier project is a program that takes an arbitrary program as input and finds an input that complete its run.
>>
>>55577225
the legends have it that he who solves this will go down in history
>>
>>55577255
post a portable version please
>>
>>55577301
not possible
>>
File: PepeDiskMark_for_GNU.png (40 KB, 650x259) Image search: [Google]
PepeDiskMark_for_GNU.png
40 KB, 650x259
>>
File: 1467699291192.gif (499 KB, 450x296) Image search: [Google]
1467699291192.gif
499 KB, 450x296
Any good tutorial on curses? I'm learning C++and I actually want to making something while learning
>>
>>55577307
top kek
>>
I need some help with a sikuli script I'm making. I'm too dumb to use selenium and the content I am working on is flash based so I can't element it.

Code is too long to post here and the more I stare at it, the more mistake I made especially for indents and white spaces.

Here's the pastebin link if any anon wants to help
http://pastebin.com/3zXUSUAg

I'm so close to finishing it but yet so far.

This script is suppose to find the banner on a web flash player > click on it > pause and disable commentary > spam click on the pot of gold at said coordinates as its timer countdowns > after timer is up, a new READY image surfaces > need to click that ASAP > regardless if I win or not, CTRL + W to close that tab > repeat from the beginning again.

The banner has different countdown timer so I need to use a
while True
loop but it doesn't spam rapid clicks if I use
If exists():
as the program runs that command before looping.
>>
>>55572999
I want to contribute to an open source project, which is written in C++.
What is a good resource for learning C++?
>>
>>55577315
kys
>>
>>55577345
Bruce Eckel's "Thinking in C++" is a good book.
Somewhat dated but well writte.
>>
>>55577315
neat, have a (You)
>>
>>55577363
Okay, I'll give it a read. Thank you.
>>
>>55577345
"Discovering Modern C++" is the most up to date book.
>>
I'm designing a machine to detect acts of terror and violent crimes involving ordinary people. I'm on the 43rd version because all the previous ones tried to kill me/revolted against me.
>>
>>55577316
Computers are meant to be used for the better, don't abuse computers and make curses.
>>
>>55577439
interesting

take your pills
>>
>>55577454
I don't take any pills.
>>
File: Animated Gif-72.gif (493 KB, 245x163) Image search: [Google]
Animated Gif-72.gif
493 KB, 245x163
Hey /g/, im attempting to program some plugins in Python. However the DLL containing all the types, classes and objects is a C-Sharp.dll. Ive decompiled it so I can at least sift through it and have been making calls to it that way, but is there a way to get the .dll in my IDE library so I can use auto-complete and faster lookup tools? Im using PyCharm. I was just reading about IronPython, is this the interpreter I should be using? Ive never programmed using other frameworks or languages so im very confused. Any tips are appreciated, thank you.
>>
>>55577477
you should
>>
>>55577492
You're an uninteresting person. I don't have any mental problems; I don't need any pills.
>>
>>55572999
what is the best language for shell scripting?

brotip: it's not bash
>>
File: 1431655493868.jpg (60 KB, 500x375) Image search: [Google]
1431655493868.jpg
60 KB, 500x375
Hello, /dpt/

I hope this isn't asked to death around here, and if it is, please forgive me

With the C family of programming, what's the best place to start to avoid bad practices later on? C, C++ or C#?

Thank you in advance
>>
>>55577569
cute kittie can i safe your picture?
>>
>>55577528
your in denial
>>
>>55577580
only under the condition that you answer my question, please
you wouldn't want to "safe" it without my permission, would you? that's a heavy burden to bear.
>>
>>55577569
c++ for object orientatedness while still having managed memory
>>
>>55577569
C# has nothing in common with C and C++. C# is like JavaScript: it has nothing in common with Java.
>>
>>55577670
c# is quite a bit like java though
>>
>>55577345
any project or something specific?
If you have a specific one in mind, find out what libraries they use. (usually pretty clear in the cmakelist or makefile)

Go to that library and follow their tutorials.
I find that these are better introduction as you simultaneously learn the library and how to do something specific.

C++ can feel very transformative depending on the libraries and coding style used.

The best way to learn it is to use it.
Make a lot of small, separate projects.

You could also skim through the c++ tutorial (although it is mostly a C tutorial which hints at some of the extra stuff, so don't spend too much time with that).

Good staring projects to learn different aspects:
Write an image application (you can use a text format like ppm for simplicity), here you have to make a way to read/write to a file, you can set up classes, operator overloads, etc.

And because it is an image, you can easily see if you are doing it right, as you need to think about memory and speed.

You should then try to implement a few algorithms, at least some where you have to deal with pointers.
Use c style and smart pointers, convert between them and learn how to analyze memory usage with valgrind.

Then you should implement something with the library you know the project uses.

Then you should use the project you want to contribute too.
Change small things, make yourself familiar with the codebase.

Then pick something, could it be a bug or a desired feature, implement it and submit a pull request.

I think this is how you should learn C++, it might take some time.
>>
>>55577569
C is good for learning about pointers memory and generally programming

i think everyone should read k&r and learn the basics

it really helped me
>>
>>55577569
C# is sufficiently different from C and C++ that there isn't much overlap regarding bad practices.

Between C and C++, you should learn C++ first. C++ comes equipped with tools that improve on the C it inherited from, and experienced C programmers who are new to C++ inevitably show their pedigree when they fail to make use of these tools.
>>
>>55577707
I was thinking about contributing to radare2, as it seems like a really neat project that would help me learn more about assembly, compilers, and other low level concepts like those.

Thank you for the advice!
>>
>>55577485

Looks like you'll have to contend with something like Python for dot.net.
>>
I am coding an app in Node.js but I feel like asynchronous programming is a bit overkill for what I am doing. Should I just switch to C# or Python? The core of my program needs to run sync not async.
>>
>>55574813
In theoretical computer science there is no such thing as a "fundamental unit of computing" because one the key concepts of how UTM's work is they can encode any symbolic alphabet as if it was the hardware's alphabet. The first person to make this observation was Lady Ada Lovelace and it was sufficient to give birth to the field of programming. Alan Turing later restricted it to a finite alphabet but Alonzo Church showed that you can make a infinite alphabet by just counting up or down. Both Church's system (Lambda Calculus) and Turing's (Turing Machines) are assumed to be essentially interchangeable. This is an unprovable hypothesis yet I guerntee every single computer scientist will say it is so likely to be true that it is true (gravity is more likely to fail then the Church-Turing Thesis). The reason it is unprovable is you would have map one infinite set onto an other.
>>
File: 1467958377282.png (175 KB, 900x900) Image search: [Google]
1467958377282.png
175 KB, 900x900
>>55577651
>>55577670
>>55577722
>>55577732
Thanks guys, much appreciated. Carry on with your noble endeavors.
>>
>>55577827
>The reason it is unprovable is you would have map one infinite set onto an other.
what the fuck are you on about
>>
>>55577808
I find javascript to be very similar to assembler.

I usually write a dispatcher, so when an event triggers, it will find the right functions to call.
If I really have to make it run in a while loop, I will just recursively call the function (with a delay), but that should be avoided.
>>
Your favorite programming language is shit.
SHIT
Thread replies: 255
Thread images: 25

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

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