[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: 319
Thread images: 41

File: shit font tbh.png (573KB, 587x551px) Image search: [Google]
shit font tbh.png
573KB, 587x551px
What are you working on, /g/?

Previous Thread: >>57989242
>>
What are some good books on computation theory and math behind programming?
>>
>'And what name do you want inscribed?'
>I said, 'I'll write it for you.' I wrote the name down: COBOL.
>'What kind of name is that?'
>'Well it's a Polish name. We shortened it and got rid of a lot of unnecessary notation.'

Howard Bromberg on how he bought the COBOL tombstone
>>
THE DOES IT FOR FREE
>>
>>57997596
Fourth for D
>>
I think I finally figured out how to average 2 numbers.

int add(int a, int b){
int temp2 = a | b;
int temp = a & b;
temp2 &= (temp^INT_MAX);
temp <<= 1;
while (temp & (a^b)){
temp2 &= (temp^INT_MAX);
temp &= (a^b);
temp <<= 1;
}
return temp | temp2;
}

float average(int a, int b){
int i = add(a, b);
if ((i & 1) == 0){
return float(i >> 1);
}
else{ //Deal with rounding error.
float f = float(i);
int l = *(int*) &f;
int l2 = l;
l >>= 23;
--l;
l <<= 23;
l2 <<= 8;
l2 >>= 8;
l |= l2;
return *(float *) & l;
}
}
>>
Damn, this thread got real clean, real quick.

>>57997596
Azure Data Factory management integration in .NET.

I love data.

I love moving data.

I want to rub data on my chest slowly, but firmly.
>>
>>57997835
Nope. overflow if input is INT_MAX and INT_MAX, even though the average is well within the codomain
>>
>>57997863
So just check for that condition and return INT_MAX
is it good now?
>>
If a subclass in Python has the same constructor as the parent class, how do you implement this?

Without typing the constructor all again?
>>
>>57997884
What about INT_MAX and INT_max -1
The average is not INT_MAX
>>
>>57997863
Fuck it, Computer Science is too hard for me.
>>
>>57997906
super
>>
>>57997596
> Dennis was a winfag

How will /g/ ever recover
>>
>>57997835
just divide the numbers by 2 first, dummy
>>
>>57998039
Quite easily, windows is the obvious choice
>>
Dynamically loading libraries is the best thing ever.
>>
>>57998039
>implying /g/ doesn't use gnu+linux ironically
>implying K&R and SICP aren't jokes we play on n00bz
>>

char* foo(){
char stuff[16] = "stuff";
return stuff;
}

void bar(){
char *things = foo();
char container[16] = "";
sprintf(container, "asd+%s", things); // this shit
}



why does this not work? i can't inject the returned char * into the container

pls help
>>
>>57998179
>I've already read K&R
>I'm halfway through SICP
>I use Linux as a daily driver

I think I've been memed.


Linux is a scourge on humanity BTW.
>>
>>57998240
what is variable scope
>>
>>57998240
BECAUSE THAT IS FUCKING WRONG

>>57998262
but no
something that is though
CMAKE AND QT
>>
Currently working on a system integration project using IBM Integration Bus. Most coding done in ESQL.
>>
>>57998270
thanks mate
>>57998291
WELL OBVIOUSLY
>>
>>57998240
you dip, it returns the pointer to the old location on the stack, that isn't valid anymore once you return from foo
please learn how the stack works for the love of god

for such a situation to work you need to use malloc()
>>
>>57998262
>I think I've been memed.
Yep.

Turns out, those are really inefficient ways to quickly be productive, create things, and be employable. On top of that (for better or worse), those things are typically dry and unenjoyable for any potential learner, thus discouraging otherwise potential developers.

Figures that /g/ would recommend them.
>>
>>57998316
i see, thank you
>>
>>57998318
SICP is a bit memey, but at least offers you a new perspective on programming (especially if you come from a C background).
Linux is poor's man Unix to be honest.
And Unix wasn't that great to begin with.
>>
>>57998366
best we've got
>>
File: kigurumi.jpg (142KB, 650x896px) Image search: [Google]
kigurumi.jpg
142KB, 650x896px
>>57997835
kek
int average (const int x, const int y) 
{
if ((x < 0) ^ (y < 0))
return (x + y) / 2;
const int xh = x / 2;
const int yh = y / 2;
const int xhr = x % 2;
const int yhr = y % 2;
return xh + yh + (xhr & yhr);
}
>>
>>57997829

>not "Fourth for fourth"

just kys
>>
>>57998494
>he thinks it's spelled "Fourth"

just kys too
>>
does anyone actually use d
>>
>>57998438

And it's shit. Linux and Windows will crumble under their own weight. OS can be much more simple and robust than the shit we have today.
>>
What's the most sensible sorting algorithm to use when I have a huge number of elements, but there are few unique elements, and identical elements often repeat themselves multiple times in a row?

e.g. something like

54,54,54,54,54,54,1,1,1,1,1123,1123,1123,1123,1123,1123,1123,1123,1123,1123,44444,44444,44444,1123,23,23,23,54,54,54,54,1,1,1,1,1,1,1,1,1,1,54,54,54... and so on for billions of elements

I'm thinking of doing a sort of run-length encoding as a first pass, but any suggestions after that?
>>
>>57998535
Yes
>>
>>57998553
Bogosort. :^)

[spoiler]But seriously, use Bubble sort.[/spoiler]
>>
HtDP is just the less memey version of SICP.
Protip: nobody who learns python in a week is employable with it
>>
>>57998553
Bucket-Sort. O(m+n) complexity where m is your range of values and n is how many values you have.
>>
File: dependently typed.png (5KB, 180x259px) Image search: [Google]
dependently typed.png
5KB, 180x259px
it's working
>>
>>57998682
ish
>>
>>57997637

CLRS


>>57998528

Fair enough.


>>57998535

Your mom.
Quite often, if I may say so.
>>
>>57998907
i mean at least once
i know that
>>
>>57997637
introduction to theory of computation.
>>
>>57998907
there's really only a little bit at the end of clrs that you'd call theory of computation, no?
but maybe he's using the term in a non-technical sense
>>
>>57998440
remy is maximum qt
>>
File: S-1228080-www.kaifineart.com-3.jpg (124KB, 700x913px) Image search: [Google]
S-1228080-www.kaifineart.com-3.jpg
124KB, 700x913px
How losers do selection control:


switch(x){
case 0:
printf("Hello world!\n");
break;
case 1:
printf("C is neato!\n");
break;
case 2:
printf("Jesus sure is nice\n");
break;
case 3:
printf("Let's play a friendly game of hopscotch!\n");
break;
}


How real men do selection control:

[
function(){
console.log("Hail satan");
},
function(){
console.log("Let's go drink beer and perform sodomy");
},
function(){
console.log("Hey kid, you wanna do some JavaScript?");
},
function(){
console.log("That C shit is for goody two shoes!");
}
][x]();
>>
tfw haskell's not powerful enough to work on my wavelength

wish i was still programming in cinnameg
>>
I'm trying to get into databases. Does the size of the database increase read time at all? I'm wondering if I should split it up and by how much.

I'm assuming no, because all the library needs to do is seek and read. But writing (not adding to the end of the list) would be slowed down, because it needs to shift all of the variables down
>>
>>57999073

use ViewPatterns
>>
>>57999073
font and size?
>>
>>57999085
Monoid, 14pt.
>>
>>57999085
fira code retina, size 17
>>57999084
i'll look into it but i'll probably just figure a way to do it with prelude. for some reason i dont want to get used to QOL stuff that's outside of prelude even though i know that sounds stupid
>>
File: 1461724348978.png (203KB, 800x689px) Image search: [Google]
1461724348978.png
203KB, 800x689px
>>57998545
Pssst kid....
>>
File: 1400857966432.jpg (40KB, 500x375px) Image search: [Google]
1400857966432.jpg
40KB, 500x375px
>>57999069
>javascript
>optimizations
>>
>>57999098
thanks pretty
IDE/color scheme?
>>
>>57999118
ViewPatterns is a language extension

before end s = drop (length end) s


toMil(before "AM" -> x)
>>
>>57999128
that wasn't even me
ree_pepe.jpg
>>
>>57999128
>>57999118
>>
>>57999128
and the IDE is atom with the ide-haskell package installed
>>
>>57999138
though for what you want you would change it so before returns a Maybe (Just if it actually ended with that)
so then you get

toMil (before "AM" -> Just x)

I actually used something almost exactly like this a few minutes ago, except I'm grabbing the beginning of strings with bang patterns
>>
>>57999159
nice, thanks bruh
>>57999153
someone's craving some attention it seems :3
>>
class Rodent (Mammal):
def __init__(self):
super(Rodent, self).__init__()


This is how it should work, right?
Because it does not work. Rodent does not inherit the constructor.
>>
File: 4952586576_3e0c73dc44_b.jpg (262KB, 800x800px) Image search: [Google]
4952586576_3e0c73dc44_b.jpg
262KB, 800x800px
What does your programming environment look like /g/?

post a screenshot please
>>
How do I get over the hump of learning basics and actually programming?
>>
any better way of doing this?
my_str= fcontent.replace('\n', '.').replace('?','.').replace('!','.').decode('utf-8','ignore').encode("utf-8").split('.')
>>
>>57999217
close 4chan and do something
>>
what inputs would this not work on? am i missing something?
import Control.Applicative
import Control.Monad
import System.IO


main :: IO ()
main = do
time <- getLine
putStrLn $ toMil time

toMil :: String -> String
toMil (x1:x2:':':y1:y2:':':z1:z2:"AM") = x1:x2:':':y1:y2:':':z1:z2:""
toMil (x1:x2:':':y1:y2:':':z1:z2:"PM") = nx++':':y1:y2:':':z1:z2:""
where nx = show $ read (x1:x2:"") + 12
toMil _ = "incorrect input format"

getMultipleLines :: Int -> IO [String]

getMultipleLines n
| n <= 0 = return []
| otherwise = do
x <- getLine
xs <- getMultipleLines (n-1)
let ret = (x:xs)
return ret


it only worked on half the test cases on hackerrank
>>
>>57999282
Personally, I would use list syntax for toMil, and replicateM for getMultipleLines.

Also note that it will accept erroneously any characters where digits should be (other than the first two characters in an AM time).
>>
>>57999282
nm got it, didn't include special cases for 12:00
>>
File: image.png (99KB, 1680x1050px) Image search: [Google]
image.png
99KB, 1680x1050px
>>57999205
>>
>>57997637
>computation theory
Do you mean formal languages and complexity theory type stuff?
>>
>>57999334
>he hides stuff on 4chan fearing the invisible hand of the hacker
>>
>>57999123
But it's not optimal at all bro.
>>
I started playing with some opengl. How the fuck am I supposed to do a good collision detection? The AABB algorithm seems nice to filter the data, but how do I check for the actual collision?
>>
File: butts.png (18KB, 923x431px) Image search: [Google]
butts.png
18KB, 923x431px
I fucking hate this place.
>>
>>57999327
if it werks it werks nigga
>>
File: ?.png (7KB, 120x120px) Image search: [Google]
?.png
7KB, 120x120px
how good programmer are you, compared to your peers?

Does/Doesn't it bother you that they are better than you?
>>
>>57999385
Use something like seperating axis theorem
What's that got to do with opengl though
>>
>>57999393
>what inputs would this not work on? am i missing something?

Pointed out some inputs it would respond inappropriately to and some things you had missed.
>>
>>57999389
Embrace the gay
>>
>>57999377
and he's right
>>
>>57999399
>What's that got to do with opengl though
I'm drawing 3d stuff and I want to make them collide
>>
>>57999395
My friend is an ultra plen when it comes to coding (basically just a whole lot of hacks and stuff), outside of school stuff he's the only rl guy whose code I've seen.

I just feel pedantic more than anything, especially since he gets way more enjoyment out of it than I can dream of
>>
>>57999434
use GJK
>>
Hi /dpt/. What would be the best language to program a savegame editor in? So far I've just been using really complicated regular expressions, but I want to be able to visualize it and configure it.
>>
>>57999486
javascript
>>
>>57999486
Any modern language will do.

I know C# really well, and it's really easy to scrap up a working GUI in WPF, so that would be my go-to.

If you're familiar with Java, C++, Python, etc., those would all work fine as well.
>>
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0040r2.html

Confirmed, C++17 is completely removing the need for OOP
>>
Made something for my final that finds the shortest path between any given airports using dijkstra's algorithm. It was kind of easier than expected, feelsgoodman
>>
>>57999509
Alright, thanks.
>>
I'm really new to programming, as in I only know the very basics of C and MATLAB (engfag). I want to code a right-click option for my Windows menu that allows me to create a folder containing the files I have selected in the path I have open.

Where the fuck would I even begin with this? Is it better accomplished in Linux?

I apologise if this isn't the correct place to ask for help, is /diy/ more appropriate?
>>
>>57999512
I don't know what you're talking about. It's exposing the implementation of some things, that's all.
>>
File: strc_isn't_free.png (56KB, 1282x767px) Image search: [Google]
strc_isn't_free.png
56KB, 1282x767px
>>57999205
Keep it simple
>>
>>57999576
>tcc
why
>>
>>57999410
i was referencing the test inputs hackerrank provides, which would be correctly formatted. the reason was because the 12:00 hours for AM and PM are a special case. how would you do it? just curious. this was my final code
toMil :: String -> String
toMil ('1':'2':':':y1:y2:':':z1:z2:"AM") = '0':'0':':':y1:y2:':':z1:z2:""
toMil ('1':'2':':':y1:y2:':':z1:z2:"PM") = '1':'2':':':y1:y2:':':z1:z2:""
toMil (x1:x2:':':y1:y2:':':z1:z2:"AM") = x1:x2:':':y1:y2:':':z1:z2:""
toMil (x1:x2:':':y1:y2:':':z1:z2:"PM") = nx++':':y1:y2:':':z1:z2:""
where nx = show $ read (x1:x2:"") + 12
toMil _ = "improper format"
>>
>>57999576
my fucking eyes

god damn, son
>>
>>57999613
I'd use Parsec
>>
>>57999205
>tfw can't screenshot your DE because of all the client-identifying information
>>
How do you explain to a kid whats a string?
>>
>>57999658
a finite sequence of characters.
>>
>>57999634
>implying you're doing anything relevant
>>
>>57999658
A bunch of letters
>>
>>57999658
A character is like the letter "a", the number "1", or even symbols like "+", and a string is multiple of these characters "strung" together.
>>
>>57999658
a pointer to a character
>>
>>57999682
not everything in a string is a letter.
>>
>>57999205
>>
>>57999677
>implying integers are not a finite sequence of characters
>>
>>57999658
A null-terminated byte array
>>
>>57999688
But then they'd think 11 is a string too
>>
>>57999658
> What Is String Theory?

> Strings are all around you. Your clothes are made of strings woven into cloth. Spider webs are string.
> To physicists, who study energy and matter, a string is anything much longer than it is wide.
> The cables that hold up suspension bridges are strings even though they are six inches thick.
> Some people collect string and wind it in a ball. No one knows why.
> A scientist would even call your DNA a string, though it curls up and those curls curl up and so on.
> Your DNA stretched out like a string would be a few meters long.
> To a mathematician a string has no width, only length.
> Scientists are beginning to believe that absolutely everything, from stars to cotton candy, may be made of string, very tiny mathematician’s string.
> This is string theory.
>>
>>57999688
>the number "1"
the number 1 and "1" are two different thing. the number is abstract while "1" is one of its representations (other representations are One, I, .----, ...)

>>57999725
>>57999691
>implementation stuffs
kek
>>
>>57999681
Relevant or not, I'm not going through the trouble to ensure everything is censored, and I'm sure as hell not putting a company name on 4chan.
>>
>>57999754
>>implementation stuffs
You're telling me there's no such thing as a string of bits?

Alright, genius, then what is or isn't a character?
What about a script? That's not really a string, is it? Newline characters are bullshit. Many scripts aren't even really grid based.
>>
>>57999754
>going on the "abstract" route with a kid who just wants to know what are strings
>>
>>57999725
It can be. You'd have to explain how you would use data types, and what the purpose of them is, as well, and that's a different issue.

>>57999754
It's childish of you to think that a child would be this childish.
>>
>>57999754
That child knows more about strings than you do
>>
>>57999699
def _partial_derivative_mse(x, ,y, w):
"""Calculate partial derivatives for MSE"""
return [-2 * np.mean(feature * (y - (_activation(x, w)))) for feature in x ]
>>
After reading Land of Lisp i want more common Lisp what book should i go for next ?
>>
>>57999816
I was trying to stay away from list comprehensions and other pythonic stuff for a bit
>>
>>57999846
Good, Guido hates functional programming
>>
It should be easy to learn C# if I am proficient with both C++ and Java, amirite?
>>
File: nothing.png (350B, 30x25px) Image search: [Google]
nothing.png
350B, 30x25px
why shouldnt our code be beholden to are you sure dialog boxes just like use humans are. like fi each method took an integer and instead of doing anything they immediately made a callback to the calling code asking for the value again confirmed or and "ayou sure?" message

so code like

int result(int one, int two) : IConfirmer{
confirmed return one + two;
}


and you have to call that asshole like
int<IConfirmable> my_result = result(2, 2);
my_result.Am_i_confirmed = true;
int actual_resultnow = my_result.ResponderValue();


so that way the filty commuinst machines have to put up with the same bullshit us humans have to put up with with user software. also no more confirm dialogs for humans; the machine confirms for us

yeah, that'll put 'em in their place
>>
>>57999874
Yeah, it'll be a cakewalk.

Be ready to do things the LINQ way, though, unless you regularly use lambda expressions in Java/C++ already.

Death to for loops
>>
>>57999205
>>
>>57999244
>>57999244
>>57999244
BUMPERINOO
>>
File: shitHNsays.png (8KB, 583x108px) Image search: [Google]
shitHNsays.png
8KB, 583x108px
>>
>>57999994
Use haskell instead.


This is here just for linking purposes.
>>58000000
>>
>>57999244
$ python -c 'import re; help(re.sub)'
>>
File: shitHNsays.png (19KB, 578x165px) Image search: [Google]
shitHNsays.png
19KB, 578x165px
>>
>>58000048
But this is true, studies have shown type safety adds nothing.
>>
File: shitHNsays.png (19KB, 580x158px) Image search: [Google]
shitHNsays.png
19KB, 580x158px
>>
File: shitHNsays.png (26KB, 579x190px) Image search: [Google]
shitHNsays.png
26KB, 579x190px
>>58000030
>>
>>58000018
he just means XML is shit

>>58000048
valid opinion supported by some studies. check An experiment about static and dynamic type systems

>>58000066
not unheard of: http://thephpleague.com/

(i'll stop)
>>
>>57999389
I don't see anything wrong in the picture :3
>>
>>58000094
Paul Graham is clearly not a fan of burritos, or he would understand.
>>
File: shitHNsays.png (64KB, 633x466px) Image search: [Google]
shitHNsays.png
64KB, 633x466px
>>
I've got a problem with AVR
>snprintf variable value to a char buffer
>send it over uart byte by byte
>first few characters are ok, last one/two are garbage
what can be the cause? uart baud rate is good, because sending normal strings works. buffer is big enough
>>
You have 10 seconds to explain to me what's more badass than no-brace single line conditionals and loops in c++?

Protip:

for (auto i : responses) cout << "You can't!" << " ";
cout << endl;
>>
>>57999876
are you a schizo
>>
>>58000235
>not auto&
You're worthless, just uninstall clang
>>
>>58000190
post code
>>
noob question here
how come this works
for i in a:
... if i not in b:
... b.append(i)


but this doesn't
[i for i in a if i not in b]
>>
>>58000235
https://nakedsecurity.sophos.com/2014/02/24/anatomy-of-a-goto-fail-apples-ssl-bug-explained-plus-an-unofficial-patch/
>>
>>58000275
plis!
>>
>>58000263
are you a communist machine?

Get some mccarthy COBOL ADA asm in you
>>
>>58000322
It does
>>
>>57999628
if your way was easier to do, i'd assume it wouldn't take you but a few seconds to convert 6 lines of code to it
>>
>>58000322
What doesn't work about it?
>>> a = [1,2,3,4]
>>> b = [2,3]
>>> [i for i in a if i not in b]
[1, 4]
>>
>>58000322
why would though?

you're creating the list and he doesn't know what b is
b = [i for i in a if i not in b]
^
???
>>
>>57999773
>Alright, genius, then what is or isn't a character?
this is defined by the specification of the language.
>>
how worth it is it to go to tech meet ups like on the site meetups? especially for anyone that lives in nyc like I do
>>
>>58000322
Case 1 is appending to b, case 2 is creating a new list.
>>
>>58000376
a = [1,2,3,1,2,3,3,4,5,8,9]
b = []
for i in a:
if i not in b:
b.append(i)


print b
print [i for i in a if i not in b]


output
[1, 2, 3, 4, 5, 8, 9]
[]
>>
>>58000322
the two code fragments do different things, the first one modifies b and the second one makes a new list
>>> a = [1,2,1]
>>> b = [2]
>>> for i in a:
... if i not in b:
... b.append(i)
...
>>> b
[2, 1]
>>> b = [2]
>>> [i for i in a if i not in b]
[1, 1]
>>> b
[2]
>>>
>>
Why do people like netbeans? It's outdated as fuck.
>>
>>58000401
Yeah, at the time of the last print, a = b, and your list comprehension returns everything that is a but isn't in b, which is nothing, so you get an empty list.
>>
>>58000401
lel
because you already filled b. try swapping order
>>
File: screenshot.png (20KB, 742x178px) Image search: [Google]
screenshot.png
20KB, 742x178px
>>58000400
>>58000376
>>58000384
the lists already exist
a has numbers with duplicates in them
b is empty
however when i do the second piece of code it includes the duplicates aswell
>>
>>58000322
Just do this.

>>>a = [1, 2, 2, 3]
>>>b = list(set(a))
>>
>>58000399
If you're trying to make connections then yea it's good.
>>
>>58000426
The comprehension is evaluated on its own, and then the result is put into b.
e.g., the following two programs are semantically EXACTLY THE SAME
1)
c = [i for i in a if i not in b]
b = c

2)
b = [i for i in a if i not in b]
>>
>>57997596
I'm working in a e-shop wich allows you to define an kind of attribute in a product, providing high customization for any product.
Removed comments because it's long code
protected function syncProductCustomAttributes(ProductRequest $request,\App\Product $product)
{
$relations=[];
foreach ($request->all() as $key=> $input) {
preg_match('/(CA_)(\d+)/', $key, $matches);
if($matches){
$custom_attribute=Auth::user()->member->store
->customAttributes()->where('id',$matches[2])->limit(1)
->first();
//according to the type of the custom attributes $valueColumn
//gets set with the string that represents the column where
//the value should be in
//Ej. $custom_attribute->type=2 (string in CustomAttribute constant)
// THEN $valueColumn<='value_string'(column of metadata
// to store strings)
switch($custom_attribute->type){
case \App\CustomAttribute::INTEGER_TYPE:
$valueColumn=\App\Metadata::INTEGER_COLUMN;
break;
case \App\CustomAttribute::STRING_TYPE:
$valueColumn=\App\Metadata::STRING_COLUMN;
break;
case \App\CustomAttribute::DOUBLE_TYPE:
$valueColumn=\App\Metadata::DOUBLE_COLUMN;
break;
case \App\CustomAttribute::DATE_TYPE:
$valueColumn=\App\Metadata::DATE_COLUMN;
break;
}
$relations[$custom_attribute->id]=[
'type'=>$custom_attribute->type,
$valueColumn=>$request->all()[$matches[0]],
];
}
}
$product->customAttributes()->sync($relations);
}
>>
any recommendations where to go after automate boring stuff whit python

https://automatetheboringstuff.com/
>>
>>58000733
Go automate some boring stuff
>>
>write a service in c# to monitor file changes in a directory with the FileSystemWatcher class
>this class raises an event every time a change in a directory occurs
>everything seems to be working nice and tight
>almost ready to deploy the application
>decide to do one last stress test using a directory with +30k elements in it
>class shits itself under such load and doesn't raise 1/3 of the events that it was supposed to raise
>hours of work into the trash
Who is to blame here, the language, Windows or myself? I even tried multithreading, but it didn't seem to work.
>>
this is seg faulting on a test case, anyone have any idea why?
problem: https://www.hackerrank.com/challenges/circular-array-rotation
int main(){
int n; // size of the array
int k; // number of rotations
int q; // number of queries
scanf("%d %d %d",&n,&k,&q);
int *a = malloc(sizeof(int) * n);
for(int a_i = 0; a_i < n; a_i++){
scanf("%d",&a[a_i]);
}
for(int a0 = 0; a0 < q; a0++){
int m;
scanf("%d",&m);
printf("%d\n", a[(n-k+m)%n]);
}
return 0;
}
>>
>>57998039
Dennis has to pay the bills
>>
>>58000760
Yourself, most likely.

What do you mean it didn't raise the events?

Are the "events" based on your own logic of what the program sees in the folder(s)?

I could probably offer some help here.
>>
>>58000771
also, the same solution works in haskell, except that it times out on different test cases
import Control.Applicative
import Control.Monad
import System.IO


main :: IO ()
main = do
n_temp <- getLine
let n_t = words n_temp
let n = read $ n_t!!0 :: Int
let k = read $ n_t!!1 :: Int
let q = read $ n_t!!2 :: Int
a_temp <- getLine
let a = map read $ words a_temp :: [Int]
forM_ [1..q] $ \a0 -> do
m_temp <- getLine
let m = read m_temp :: Int
print $ a !! ((n-k+m) `mod` n)


the test case it segfaulted on in C passes in haskell, but i think i have to use C to get it fast enough
>>
Dumb question but could databound controls be used to update existing records in a database?
>>
>>58000831
Sure.
>>
File: c-vs-haskell.png (152KB, 1924x1852px) Image search: [Google]
c-vs-haskell.png
152KB, 1924x1852px
>>58000814
>>58000771
pic related
>>
>>58000401
>python2
Found you're problem
>>
>>58000894
>you're
found your problem
>>
>>58000908
>he doesn't get the meme
>>
>>58000919
The first one is more of a pain in the ass to add more logic to.

Also,
>using this
>having a parameter input exactly the same as the field it is related to
>not using a language with auto-properties
>>
>>58000918
>he gets the meme
>>
>>58000918
>>58000953
>he

The programming community is inclusive.

Please do not assume gender, sex, sexual orientation, or species.
>>
Is there a difference between

public void setTeamName(String teamName) {this.teamName = teamName;}


And

public void setTeamName(String teamName) {
this.teamName = teamName;
}


My friend told me the first was horrible and never should do it because my future coworkers would hate me.

>>58000946
thanks family
>>
hello /g/

I could use some help from people educated in CS/Software Engineering. I often find myself writing Powershell scripts for my job (sysadmin), but I have no programming experience or related degree. I've come up against a problem but I have no idea how to solve it or even what terms I should try googling.

Here's some ugly pseudocode:

for ($obj in $objects) {

if ($obj.subject == "foo" && $obj.description == "bar") {
do_thing0
}

if ($obj.subject -match "^[foo]$" && $obj.email == "[email protected]") {
do_thing1
}

if ($obj.subject -like "*foo*") {
do_thing2
}

if ($obj.subject == "foo" && $obj.attachment == "bar.xlsx") {
do_thing3
}

}


Now imagine this but about three times the size. Even someone as uneducated as myself can see that this is a terrible way of doing things, but I don't know what the alternatives are. Case statements don't seem to be much better than the current solution, so I don't think it's worth the effort to rewrite it that way.

What's the right way to do something like this?

Thank you in advance
>>
>>58000919
They are the same code, in the sense that printing the entire contents of a novel on a single line is still the same story.

Formatting is important, your coworkers and future you will appreciate it.
>>
>>58000972
There's no women on the internet bruh.

All the women on the internet are guys, and all women under 18 are FBI agents
>>
>>58000771
can (n-k+m) go negative?
that could cause problems for your little array a
>>
>>58000788
No, the class handles the event entirely, my logic only comes after the event is raise.

static FileSystemWatcher fileWatcher = new FileSystemWatcher();

protected override void OnStart(string[] args)
{
RunFileWatcher();
}

[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public static void RunFileWatcher()
{
fileWatcher.Path = pathToWatch;
fileWatcher.NotifyFilter = NotifyFilters.FileName;
fileWatcher.Filter = "";
fileWatcher.IncludeSubdirectories = true;
fileWatcher.Created += new FileSystemEventHandler(OnChanged);
fileWatcher.Deleted += new FileSystemEventHandler(OnChanged);

fileWatcher.EnableRaisingEvents = true;
directoryWatcher.EnableRaisingEvents = true;
}

private static void OnChanged(object source, FileSystemEventArgs e)
{
FWChangedL.Add(new FileWatcherChanged(source, e));
UseRes();
}


The problem is that my logic (inside UseRes()) takes some to time to be executed and it writes to a log file, so in order to avoid conflict accessing the same file, I'm using a mutex to halt the processing until the last event is done accessing the file.
>>
>>58000972
nice meme, fucker
>>
>>58001035
i'm asexual, faggot
>>
>>58001046
i'm an helicopter, faggot
>>
>>58001028
Before I fuck with your code, what are you actually trying to accomplish with this?

You're just trying to raise events (i.e. do something like an alert) when anything is created or deleted in a folder and its subdirectories?
>>
>>58001020
>>58001020
this is what i needed
int main(){
int n;
int k;
int q;
scanf("%d %d %d",&n,&k,&q);
int *a = malloc(sizeof(int) * n);
for(int a_i = 0; a_i < n; a_i++){
scanf("%d",&a[a_i]);
}
if (k > n) k = k % n; // in case k is larger n
for(int a0 = 0; a0 < q; a0++){
int m;
scanf("%d",&m);
printf("%d\n", a[(n-k+m)%n]);
}
return 0;
}
>>
>>57997596
Something similar to IRC, but for the web browser. It's completely anon and people can create their own rooms and chat with others without signup.

Features include:

Creating rooms for free

Sharing images

Clearing (Each message only has about 20s to live until it's deleted within the room, this includes images as well)

General chat. Basically just the first chat that you see when you get to the home page of the site

Chat Room browser. This is where you can look for chats of your interest

Slight moderation. Due to it being completely anon there will be some moderation going on.


I am using Golang for the backend and just HTML5 for the frontend. Site isn't up and won't be up for a while since it's a rather new project.
>>
>>58001118
>It's completely anon
;^)

Sure it is, buddy.
>>
hey guys I have a great idea
let's make an operating system
and then let's make a command prompt program for that operating system
and for ascii control code characters printed to the command prompt we make it beep for two minutes
>>
>>57999069

const char *strs[4] = {
"You really shouldn't wrap functions in arrays like that",
"You're forcing more, unnecessary work on the interpreter",
"Better to just make an array of strings",
"And make one function call"
};
puts(strs[x]);
>>
>>58001118
>I am using Golang for the backend and just HTML5 for the frontend

why not Node JS and bower and webpack wrapped in Angular JS?
>>
>>58001062
It's basically creating an index of files and folders to be used by another app of mine. So, to avoid avoid this other application from reading a folder several times during its execution (which is slow), it's way faster for my other app to read this log I've created.
Of course, this scenario with +30k elements in a folder with probably never happen, but I can't let go of it. Tests with 10k elements or less seem to work just fine.
>>
File: export.png (7KB, 620x54px) Image search: [Google]
export.png
7KB, 620x54px
>>58000291
I fixed it myself. I wasn't clearing transmit complete flag.
>>
>>58001135
Obviously OP is talking about a situation where each case has more functionality than just a print, but it's true that you shouldn't overengineer your solution if all you're doing is printing different strings.

>>58001086
In lisp this is just
#lang racket
(let* ([n (read)]
[k (read)]
[q (read)]
[a (build-vector n (lambda (_) (read)))])
(for ([m (in-port)])
(displayln (vector-ref a (modulo (- m k) n)))))
>>
>>58001152
Alright, well, I've somewhat ran into that before.

Here's someone talking about the same issue; basically, if that class is processing something, it can miss an event that happens during the processing, so it's not really your fault this time: http://stackoverflow.com/a/33048620/4479934

It's producer/consumer shit, and the consumer has a buffer that will drop anything additional if it gets overflowed.
>>
>>58000190
I've gotten an ESP01 and I just broke out the pins. And I know next to nothing about IOT/electronics/wall pixies.

I'm just wondering where I should go and how much effort I should put into things.

Currently the project is to have a relay controlled remotely. I can probably do all the software stuff OK.
>>
>>58001152
>>58001208
Also, you could just set
FileSystemWatcher.InternalBufferSize
to 64KB in size, and that might alleviate it enough to cover an acceptable stress test case.
>>
>>58001205
go submit it on the hackerrank thing and see if it doesn't time out on any and i'd be mildly impressed
>>
>>58001208
That's what thought.
I'm gonna test what this anon >>58001208
said and see if it changes anything.

Thanks for the input.
>>
File: Untitled.png (8KB, 1230x135px) Image search: [Google]
Untitled.png
8KB, 1230x135px
>>58001298
I do have a lot of trouble with timeouts, but it's usually time complexity issues, not "it isn't bare-bones C" issues.
>>
>>58001326
i thought haskell's !! operator was O(1) but i guess it's O(n). that's really annoying, i guess i'll have to start using the array import more often
>>
>>58001326
>circular array rotation
Lmao just go the other way dawg, just turn around. You can't rotate a circle xD
>>
>>57999613
This reply isn't me: >>57999628

I *wouldn't* break out a parsing library for something so trivial.

As I said, I'd use list syntax to reduce the noise.
Also, if you want to do this 'the right way', you'd have to semantically analyse all of the input to check for invalid times (i.e., call 'read' on all input digits and check they fit into a 12-hour clock).
>>
>>58001217
Controlling a relay is basically setting a pin to low/high. Learn how to send data to your MCU and you're almost done.
>>
>>57997596
With job finding, does anyone have any advice on how to work with a 3rd party hiring agency? I applied for a job on indeed, but the company is just a staffing company, and I'm not really sure if there's something particular I should ask before finding out about it later down the line.
>>
>>58001118
>Clearing (Each message only has about 20s to live until it's deleted
Expect people to use a script to prevent that.
>>
>>58001499
>done
As in everything else I need to know is stuff I make up myself?
I'm gonna do more stuff.
I don't have an MCU, I'm aiming to do everything on the ESP01 (it got that fancy CPU, why not use it?).
Also where can I learn all these terms like uart, MCU etc. Any good summaries? Everything I find concerning electronics seems very poorly documented or it's simply spec sheets. There very little introductory material it seems.
>>
std::bind is pretty neat
>>
>>58001118
>It's completely anon
if this was true you wouldn't be able to ban people
>>
>>58001528
They would only be able to prevent that client-side.
>>
>>58001548
I was referring to that ESP as MCU, microcontroller unit. If it can run a program and has gpio pins, then it's good. If you want to about its capabilities, read the datasheet and google things you don't understand.
You also shouldn't connect output pin directly to relay coil, because current draw might be too big and fry that pin. You should use that esp to control a transistor which will open or close relay coild. And also use a diode, to prevent transistor from getting destructed by inductive kickback.
If you want to learn more about electronics, visit /ohm/ on >>>/diy/
>>
>>58001352
Of course it's O(n), Haskell lists are linked lists.
I bet Haskell wins for brevity for these kind of problems, but not for easy of creating efficient solutions, mainly because a lot rely on stuff like in-place sorting or hash-tables to get better performance.
>>
>>58001142
NodeJS is a meme.
>>
>>58001548
>>58001682
if you don't want to get too deep into the electronics you could also use a relay driver afaik
>>
>>58001528
That would only make the message visible to them for that long. All the other people unless using the same script would not see that. I could also just make the code completely unreadable.
>>
>>58001602
Only ban people for illegal things, much like 4chan. Other than that it's fair play.
>>
>>58001775
>I could also just make the code completely unreadable.
That's not how these things work.

Security through obfuscation is not security.
>>
>>58001790
The point is, if it were actually anonymous, you'd have no way to ban someone.

As in, you would not be able to set an IP address or anything identifiable that would enforce the ban.
>>
File: 1480664267597.jpg (18KB, 500x500px) Image search: [Google]
1480664267597.jpg
18KB, 500x500px
I'm now pretty decent at Java. I'll be studying C++ on my own after this and the next programming course in my engineering program at uni has me learning C next.

My degree will be in Automation & Mechatronics engineering, so robots n shit

What programming language other than Java, C, C++ would make me more attractive to future employers?
>>
>>58001790
yea but it can't be completely anonymous if you CAN ban people if you can ban people you have to have some piece of information unique to them, if the server has unique information to identify you by you're not completely anonymous - a much better wya would be to phrase it as relative anonymity
>>
>>58001813
Fortran
>>
>>58001802
That would be bad on my part. In fact, it could be threatening to me, since there is something illegal on my server. I have played with the idea of not being able to see an IP address, but that could force me to get into some legal issues.
>>
>>58001813
Probably old, painful shit like Cobol and fortran.
>>
>>58001813
Malboge
>>
>>58001793
Well, it is a step. I really don't care if people want to fuck with the site. I just want to make something that i would use on a daily bases.
>>
File: 17424.png (50KB, 286x375px) Image search: [Google]
17424.png
50KB, 286x375px
>>58001775
>I could also just make the code completely unreadable
But anon it already is
>>
>>58001828
I forgot to mention that I'm learning Matlab all throughout my 4 math courses in linear algebra and the like.

Is Foltran still recommended?
>>
>>58001813
rust
>>
File: image.png (129KB, 1680x1050px) Image search: [Google]
image.png
129KB, 1680x1050px
>>57997596
>What are you working on, /g/?

Exploring the deepest, darkest corners of Racket by doing Advent of Code 2016.
>>
File: 1481318569503.jpg (25KB, 250x201px) Image search: [Google]
1481318569503.jpg
25KB, 250x201px
>>58001851
"Malbolge, invented by Ben Olmstead in 1998, is an esoteric programming language designed to be as difficult to program in as possible."

That sounds like fun!
>>
what's the dpt approved book on networking?
>>
>>58001888
There is no approved book on networking.

You have to force yourself to go out and meet people and network there
>>
>>58001871
>faggot flag in text editor
>>
>>58001118
Nigger I'm doing something like this, except it will be free software, and be made in python and C++ [spoiler]and not be shit[/spoiler].
>>
>>58001871
Why do you post the same thing every day?

It's not impressive, and your DE is shit.
>>
File: 14778251741488.png (139KB, 350x346px) Image search: [Google]
14778251741488.png
139KB, 350x346px
>>58001900
you got me there, friendo. so let me rephrase my question:
what is dpt approved book on tcp/ip and everything related to network programming.
>>
>>58001909
>python
>not shit
>board tourist
>""free software""
>>
>>58001909
>n-word
Kill yourself yourself.
>>
File: anal beads.png (31KB, 639x409px) Image search: [Google]
anal beads.png
31KB, 639x409px
>>58001928
>>
>>58001933
>Kill yourself yourself.
Kill yourself yourself yourself


t. kill yourself
>>
>>58001928
This one is good.
http://beej.us/guide/bgnet/output/print/bgnet_A4_2.pdf
>>
>>58001878
>Malbolge was so difficult to understand when it arrived that it took two years for the first Malbolge program to appear. Indeed, the author himself has never written a single Malbolge program.
>A correct 99 Bottles of Beer program, which deals with non-trivial loops and conditions, was not announced for seven years; the first correct one was by Hisashi Iizawa in 2005.

You know you are in for some fun time with it.
>>
God damn it! Anyone who knows Lua?
I'm working on a game and my level format reader just doesn't want me to write it.
Current itteration.
function csvEntry( str, row )
-- extract a table of columns
-- split into lines/rows
dat = {}
for i in string.gfind(str, '\n[^\n]\n') do
-- ignore comments
i = string.gsub(i, '[^%#*\n]', '%1')
for j in string.gfind(i, '%d+\t') do
table.insert( dat[i], tonumber(string.gfind(j, '%d+')()) )
end
end
return dat[row]
end

And an example of the format I want it to read.
# The collumns are seperated by tabs
# Hash symbols delimit a comment to EOL
# A 0 in e denotes a wall
# the fields are
# e x y ...(other data)
0 100 300 1
1 400 500


Fuck you Lua for being so minimal and fast and minimal and making me think.
>>
>>58001970
post game
>>
File: bully.webm (3MB, 720x404px) Image search: [Google]
bully.webm
3MB, 720x404px
>>58001917
>It's not impressive, and your DE is shit.
Please, don't bully. We are all here to share and discuss.

>>58001917
>Why do you post the same thing every day?
because op asked what i am working on and because it's the [daily programming] thread.

>>58001904
It's a rainbow, not a flag.
>>
>>58001871
Break your shit into functions like an actually competent racket programmer
>>
>>58001813
Assembly
>>
>>58001970
Parse the csv into a table then just index the table with row

Now with the string parsing.... just mess around with it longer
>>
>>58001868
>>58001851
>>58001845
>>58001828
Rust looks pretty interesting.

Is there some other language that pretty much any programmer would benefit from knowing? See lots of people talking about Python often. Would that be irrelevant for me?
>>
why?

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

int main(int argc, char **argv)
{
char *line;
line = malloc(sizeof(char));
line[0] = '\0';
printf("%d\n", (int)sizeof(line)); // 8
printf("%d\n", (int)sizeof(char)); // 1
}
>>
>>58002055
Try Crystal
>>
>>58002061
sizeof(char *)
sizeof(char)

pointers are 8 bytes / 64 bits on x64 computers
>>
>>58002061
do sizeof *line
nerd
>>
File: sergey-kolesov-space-station.jpg (196KB, 1600x900px) Image search: [Google]
sergey-kolesov-space-station.jpg
196KB, 1600x900px
>>58001992
I would if I had one. It's only has walls, a single buggy item and not even camera movement yet.
The pains of starting from scratch.

>>58002044
Pretty much what I'm trying to do there. My issue is that I can't figure out how to break up between the individual lines and tabs yet.
Basically I'm making a 2d list that I then construct the objects from.
>>
>>58001682
Thanks for the info. I'll just try to process that.
>>
>>58002121
USE AWK NIGGER
>>
>>58002154
>AWK
sed master race
>>
>>58002165
awk's primary purpose is formatted texts
>>
File: what_did_u_just_say_anon.jpg (381KB, 1857x963px) Image search: [Google]
what_did_u_just_say_anon.jpg
381KB, 1857x963px
>>58002030
Advent of Code is a series of challenges made of two parts where the second part is only revealed after you resolved the first one. The solution for the first part was smaller but then i had to add crap for the second part. Caring about aesthetics for this kind of challenges is a waste of time; Why would you care about readability when you will probably never have to deal with the code again?

>>58002055
>>58001813
SQL
>>
>>58002192
>Why would you care about readability when you will probably never have to deal with the code again?
Developing good habits. But suit yourself.
>>
>>58002082
should I be using for example
char *line;
line = malloc(sizeof(char));
line[0] = '\0';
char[] add = "line";
line = realloc(line, sizeof(*line) + strlen(add) * sizeof(char);
strcat(line, add);

or just
line = realloc(line, sizeof(line) + strlen(add) * sizeof(char);

then?
>>
>>58002154
>>58002165
>>58002184
Bitch. How many scripting languages do you want me to use in one project? 5? 10? Besides, I'm working under the windows monolith.
>>
>>58002212
That code is scary.
>>
>>58002231
any ideas how to merge strings?
>>
>>58002255
In Haskell this is just <>

Protip: as a beginner learning C, try to avoid strings. Why are you malloc()'ing and then realloc() directly after? Why not just one malloc()?
>>
>>57997835
function average(a, b) {
return (a + b) / 2;
};
>>
>>58002212
You use sizeof(*line) in this example
And sizeof(char) is always 1

Prepare yourself for many segfaults since you are using strings and pointers
>>
>>58002288
because in a complete program the function will build a SQL query by merging strings and depending on the user's input

that's just a mere simplification
>>
>>58001208
>>58001260
I just wanted to say that I fixed the problem, anons.
I tried to do what the guy on stackoverflow said and do all the heavy processing on a separated thread, but I was getting a system out of memory exception when creating a new thread after some time.

I fixed the problem by using
ThreadPool.QueueUserWorkItem()
.

I just needed to change one line of code:

        private static void OnChanged(object source, FileSystemEventArgs e)
{
FileWatcherChanged fw = new FileWatcherChanged(source, e);
FWChangedL.Add(fw);
ThreadPool.QueueUserWorkItem(UseRes);
}
>>
>>58002327
>Prepare yourself for many segfaults since you are using strings and pointers
There is fear only in the hearts of the monkeys. Master can handle pointers.
>>
What's the best way of getting a C IDE/compiler on to a USB stick?
I've got Notepad++ and JDK on it at the moment which works well for doing shit on any PC, but I'm not sure how C would work.
>>
>>58002349
does anon seem like a master?
>>
>>58002364
b-but I dream in code...
>>
>>58002364
touché
>>
>>58002288
>goes straight for mappend
Classy bastard.
>>
https://code.visualstudio.com/updates/v1_8
>>
>>58002433
>not replacing all of your ++ with <>
>>
>>58002255
for example like this
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char * merge(const char *str1, const char *str2)
{
size_t str1_length = strlen(str1);
size_t str2_length = strlen(str2);
char *result = malloc(str1_length + str2_length + 1);
strcpy(result, str1);
strcat(result, str2);
return result;
}

int main(void)
{
char foo[] = "this is immutable.";
char bar[] = " but result stored on heap is mutable";
char *merged = merge(foo, bar);
puts(merged);
free(merged);
return 0;
}
>>
>>58002453
Absolutely disgusting.
>>
>>58002453
>not checking malloc return value
>>
>>58002212
Why are you dancing around with this malloc and realloc? I also don't see the point in initialised the line with '\0', since you're never going to use it for anything. What are you trying to do?

char *line
char[] add = "line"

line = alloc(strlen(add))
>>
>>58002006
Please post anime image next time. I don't want to be reminded this world is filled with animals.
>>
>>58002467
>letting poor OS'es have any say over your code
They should work and if they don't work just fuck em.
>>
>>58002453
char arrays are mutable

they copy the string into themselves

otherwise strings are `const char *`
>>
Why is literally any good C code written using OOP concepts
>>
>>58002615
Such as?
>>
>>58002615
OOP isn't bad
TOO much OOP is
>>
>>58002615
>C
>OOP concepts
prepare for a massive laugh, everyone.
>>
File: 1480968379689.png (67KB, 419x248px) Image search: [Google]
1480968379689.png
67KB, 419x248px
>>58002615
Good OOP code is written using functional concepts
>>
File: 1481617492198.jpg (140KB, 705x1000px) Image search: [Google]
1481617492198.jpg
140KB, 705x1000px
Dear math geeks,

I'm using the function Math.Pow(X, Y);
But unfortunately this turned out to be a performance bottleneck

However I know that my X is always between 0 and 1
And my Y is always between 1 and 2.2

Is there a way to get the desired result without using Pow?
>>
>>58002656
I love anime tiddies
>>
>>58002656
Are X and Y completely arbitrary?
>>
>>58002656
>implying programmers need to know maths
>>
File: ugh.png (208KB, 425x425px) Image search: [Google]
ugh.png
208KB, 425x425px
>coworker notices that I use gotos in my error handling code
>"WOAH ANON YOU SHOUDLNT USE GOTO!!! REMEMBER OPENSSL?"
>"you should definitely rewrite that!!"
>>
>>58002686
show us the code so we can judge
>>
>>58002656
>But unfortunately this turned out to be a performance bottleneck

How
>>
File: 1381854504574.jpg (37KB, 623x626px) Image search: [Google]
1381854504574.jpg
37KB, 623x626px
>>58002686
>>
#include <stdio.h>
#include <stdlib.h>

struct concatstr {
enum {
STRING,
NODE
} kind;
union content {
char *str;
struct node {
struct concatstr *left;
struct concatstr *right;
} node;
} content;
};

struct concatstr *fromstr (char *str) {
struct concatstr *ret;
ret = malloc (sizeof (struct concatstr));
if (ret == NULL) {
return NULL;
}
ret->kind = STRING;
ret->content.str = str;
return ret;
}

struct concatstr *concat
(struct concatstr *left, struct concatstr *right) {
struct concatstr *ret;
ret = malloc (sizeof (struct concatstr));
if (ret == NULL) {
return NULL;
}
ret->kind = NODE;
ret->content.node.left = left;
ret->content.node.right = right;
return ret;
}

void freeconcat (struct concatstr *c) {
if (c != NULL) {
if (c->kind == NODE) {
freeconcat (c->content.node.left);
freeconcat (c->content.node.right);
}
free (c);
}
}

void fprintconcatf (FILE *stream, struct concatstr *c) {
if (c != NULL) {
switch (c->kind) {
case STRING:
fprintf (stream, "%s", c->content.str);
break;
case NODE:
fprintconcatf (stream, c->content.node.left);
fprintconcatf (stream, c->content.node.right);
break;
default:
(void) *((int *) NULL);
break;
}
}
}

char *str0 = "foo";
char *str1 = "bar";
char *str2 = " fizz";
char *str3 = "buzz\n";

int main (void) {
struct concatstr *c;
c =
concat (
concat (
fromstr (str0), fromstr (str1)),
concat (
fromstr (str2), fromstr (str3)));
fprintconcatf (stdout, c);
freeconcat (c);
return 0;
}
>>
>>58002469
that is for strcat() to write on string terminator because anon is too stupid to use strcpy()
>>
>>58002623
Here, I'll use GMP as an example.

Here's some code I copied off of Stack overflow
    mpz_t a,b,c;
mpz_inits(a,b,c,NULL); //initializer function

mpz_set_str(a, "1234", 10); //equal operator
mpz_set_str(b,"-5678", 10); //equal operator

mpz_add(c,a,b); //add operator

If I were to create the similar thing with C++, it would be
class mpz
{
public:
mpz operator=(const char*,const short);
mpz operator+(const mpz);

private:
mpz_t value;
};

And during compiliation, the compiler, the way I understand it, is that for every function mpz has, it creates a function with a "self" variable in front. For every variable mpz has, it puts it into a struct, and it compiles exactly like the C code.

A better example would be python, as you're supposed to include the self in the functions, so it's more obvious.
>>
>>58002656
if you waste too much time on function call, inline it
>>
>>58002783
Daily reminder that [functions closely related to the objects they manipulate] is not the same thing as [object orientation]
>>
>>58002783
So what you're saying here is that functions that operate on data are object-oriented?
>>
>>58002783
this is not an object and you are confusing a concept with its implementations.
>>
>>58002814
>>58002821
>>58002824
Which is why I said "concepts."
C is not OOP in any way, yet you can simulate the same behavior.

If OOP is so bad, then why does any C code look like C++?
>>
New thread:

>>58002845
>>58002845
>>58002845
>>
>>58002840
>any C code look like C++?
In your dreams anon.
>>
>>58002840
this is not the same behavior at all, fucking mongoloid.
>>
>>58002656
if you don't need that much accuracy (or if you can afford to spend some memory) a lookup table might help you
also consider that x^y = b^(y*logb(x))
>>
>>57999081
If you key it properly, and have it index properly, an increase in size will note effect perf much.
>>
>>58002840
>then why does any C code look like C++?
>"the most C++ i've ever seen is example code from C++ tutorials"

C++ code can range anywhere from "just C with one extra feature" to "full blown Java-mode enterprise OOP" to "purely functional programming language"
>>
>>58002840
>struct == OOP
?? ¬.¬
>>
>>58002686
what;re you using them on anything that matters?
>>
>>57998553
Compress then sort as you would for a normal array.
>>
How do you check for auxillary carry (also called half carry) when writing an emulator
Thread posts: 319
Thread images: 41


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