[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: 326
Thread images: 37

reminder that most women can't program for shit and they don't even want to do it

not one of you is biologically female

Previous thread: >>60775927

What are you working on, /g/?
>>
>>60781679
Shit OP
>>
FIRST for USER FREEDOM
>>
Reminder that distributing binaries is harmful
>>
>>60781730
that's what your mom told me last night
>>
I'm developing a kernel, and have a question about filesystems.
When I use the mount command on Linux, how does the kernel know which filesystem driver to use?
Does it try all of them until one works?
>>
>>60781762
I'd it isn't a bind eg. something already mounted you have to specify the type through -t though. Otherwise the information is in conf files.
>>
>offended by facts about women being inferior
>delete image
/g/'s cucked
>>
>>60781841
Trolling and sexism are banned outside of b
>>
>>60781841
>3. You will not post any of the following outside of /b/: Trolls, flames, racism, off-topic replies, uncalled for catchphrases, macro image replies, indecipherable text (example: "lol u tk him 2da bar|?"), anthropomorphic ("furry") or grotesque ("guro") images, post number GETs ("dubs"), or loli/shota pornography.
>off-topic replies
>>
*blocks your path*
>>
>>60781762
Good question but it doesn't exactly do that afaict. Try running sudo blkid you'll be amazed. it's not exactly a
for (d in drivers) { try { d.mount(...) } catch (whatever) { continue } }
kinda thing. It has to scan the device at some point to discover the fs format, but most fs probably have magic numbers, and once you know you can cache the information, so it's probably a bit more civilized than just "bulk try the mount functions until one of them succeeds".
>>
>>60781858
The state of /dpt/ proves rules aren't consistently enforced (eg. GR6).
>>
>>60781869
Literally who?
>>
>>60781869
Ask to shake her hand at first then run away because she's a zombie.
>>
>>60781893
Back to >>>/v/
>>
>>60781762
what is google what are books
>>
>>60781762
Maybe look at the fucking source code, retard
>>
>>60781893
One light nanosecond
>>
>>60781679
is that dutch/belgian qt girl still here? :3
>>
File: images.jpg (6KB, 259x194px) Image search: [Google]
images.jpg
6KB, 259x194px
I fucking love this whole thread dude. Don't stop being /dpt/ for one second guys. And remember to wear your skirts everyday.

>>60781958
Not even a nanosecond.

>>60781679
Not working on anything since my internship contract basically assigns ownership of any software "related to the company" to them, and they're a big tech company, so I'm kind of screwed since they have some product for just about everything.

Basically my only method of surely making an unrelated piece of software that I might actually have a passion for is probably some weird /hgg/ sex game.
>>
Looking for a regular expression (Javascript) that will find any instance of a sentence without a capitalized first letter. The string itself may consist of multiple sentences. Anyone want to help me out?
>>
>>60781841
they can't delete the OP text without taking down the whole thread tho lmfao
>>
>>60782092
>Anyone want to help me out?
Not with trivial shit like this. RTFM and grow a brain
>>
>>60782139
>mansplaining and telling a woman to grow a brain
don't be sexist
>>
What regex engine does webscraper.io use ?

Their documentation doesn't say and I want to know what I can do.
Should I presume its python ?
>>
>>60782092
/(.|?|!) [a-z]/
>>
>>60782205
your mom
>>
>>60782205
Chrome extensions are written in JavaScript
>>
File: power_of_idris.png (320KB, 988x3254px) Image search: [Google]
power_of_idris.png
320KB, 988x3254px
https://github.com/edwinb/TypeDD-Samples/blob/master/Chapter14/Hangman.idr
>160 lines
>7 types
>11 functions
>to implement a primitive Hangman game
So....this is the power of dependent types....wow....
>>
>>60782159
As if this person knew that who they were replying to was female.
>>
Speaking of regular expression, does any of y'all know, by any chance, a decent NFA engine that lets you construct is inputs with something other than clunky strings? Dunno like
lowercase_letter.one_or_more().capture("name1")
. I manage to write dot-backslash-bang heaps of steaming shit, but I'd appreciate a more structured representation, even if it takes up more space visually. Any language and platform, I'm just curious.
>>
Hello dpt, I am glad to be back again. Everything on my end is in order. I haven't even had to put together the new pc either. Everything works out of some 400 dollar laptop I got at walmart. Touch screen makes a lot of things I was yet used to, comfortable. Like reading pdfs. I have a DDR4 4Ghz, i7, 8gigs ram, 3 ssd, oled machine waiting to be put together. But this laptop does it all and more and I don't even feel the need. I feel strange.

I will need to put it together for the battlestation experience once I get my desk. I want to try three monitors. Two vertically, two horizontally with the right one being taller than the left.

EN

with the shiny N thing being my sideways monitor with glare, and the E being the two smaller monitors stacked. The main one being touch screen. It's incredibly helpful to be able to pick up the screen, ignore the keyboard and just thumb through the pages of a pdf. A hundred million times better. I think the lenovo dreampad has a touch screen and is about 400. Consider it for some serious learning power.

As for something more dpt than the rest of the post, today I am going to be working on a simple game design. I think I have five books open right now and I'm working through four game programming topic books and one or two unity books which are only kinda sorta programming related.

Oh yeah, drink and snack on me.

There's also a book on making great games that I'm not entirely familiar with that I think might turn out to be fun. I'm hoping to be sitting here working at this shit all day.

Instlaling VMWare for TempleOS right now, btw.
>>
File: 1495910470505.jpg (98KB, 1299x801px) Image search: [Google]
1495910470505.jpg
98KB, 1299x801px
>women can't progr-
>>
>>60782748
someone didn't get a drink and snack or DARE I SAY IT oled
>>
I'm working on a Chess game in C++, does the following implementation make sense?

Class for each piece, contains member variables piece type, team, alive/dead, and a pointer to a square (where it is on the board)

Class for each square, contains row and column data, and a pointer to the piece which resides in that square (will initialize as null?)

Array of game pieces and an 8x8 array to be the game board

I haven't done much work with pointers. Do these pointers make sense, and is it ok to have two objects pointing at eachother?
>>
>>60782748
>when you realize that this is the faggot who makes all the tranny OPs
>>
>>60782857
https://en.wikipedia.org/wiki/Unified_Modeling_Language
>>
>>60782857
Doesn't sound very efficient. Have you considered a bitboard?
>>
>>60782940
I have not, I'll take a look at it and see if it looks like something I could work through. Thanks for the suggestion
>>
>>60782748
egghead?
>>
>>60782882
UML is for brainlets that can't plan out their whole program in their head.
>>60782857
Each square doesn't need an object. Squares don't really do anything. That sort of stuff should be stored in your board class, maybe in a struct if you need it.
>>
>>60781679
>reminder that most women can't program for shit and they don't even want to do it
doesn't sound different from males, tbf
>>
>>60783043
>doesn't sound different from pajeets

ftfy
>>
>not one of you is biologically female
and i like my /g/ dickgirls just the way they are
>>
>>60781679
image deleted

That's what you get for not posting anime girls
>>
>>60783054
nah, face it, most can't program
you, can't program and YOU in particular hoho you certainly can't program and of the people who can "program" even the good ones have questionable habbits

pajeets are just different in their motives
>>
>>60783146
Nice broken english, Pajeet
>>
>>60783150
This
>>
>>60783150
pajeet is still a noun btw, pajeet
>>
>>60783146
>tfw you're literally sharing a thread with pajeets
>>
>>60783173
>>60783150
t. nondevs
>>
File: 1485995062856.webm (3MB, 1280x720px) Image search: [Google]
1485995062856.webm
3MB, 1280x720px
i was on a date today /dpt/
so far it's either
>dumb bimbos who don't care about programming or anything at all
or
>clever girls who care about programming but are ugly and don't know how to sex properly

Anyway, what does good folk of /dpt/ think about Kotlin
>>
I think we need to reboot this thread.
>>
>>60783193
>tfw you're literally sharing a thread with a closet pedo
>>
Hey guys, I'm learning C# and I can't grasp how to split classes in multiple files. I'm using the same namespace in both files (test.cs and test1.cs), but on compiling I get this error:
est.cs(34,3): error CS0246: The type or namespace name 'functionStuff' could not be found (are you missing a using directive or an assembly reference?)

I'm running Debian testing and for compiling I'm doing
csc test.cs test1.cs
>>
>>60781893
That's Grace Hopper you ignorant cunt.
>>
>>60782748
it is a bit presumptuous to call a man a woman just because he wears a bit too casual a shirt.
I know there is no such thing as gender in the english language anymore, butstill.
>>
>>60783216
>Grace Brewster Murray Hopper (née Murray; December 9, 1906 – January 1, 1992) was an American computer scientist and United States Navy rear admiral.
i'd admire her rear when she was in her prime
>>
https://www.theregister.co.uk/2017/06/05/dev_accidentally_nuked_production_database_was_allegedly_instantly_fired/

lool
>>
>>60781679
Is there any way you can force a thread to run on a specific physical core? On Linux in particular. Thanks in a advance.
>>
>>60783396
>Putting the login details for the server in an instruction document
Oh wew
>>
>>60783440
__NR_sched_setaffinity
pthread_setaffinity_np
>>
>>60783461
Thanks anon.
>>
>>60783440
make new threads and hold them empty until you can assign the particular core you desire?
>>
>>60783499
wat
>>
wrote hangman. its really hard!
> hangman
__________
Guesses:
Guess a letter: a
_____a____
Guesses:
Guess a letter: e
_e___a____
Guesses:
Guess a letter: i
_e_i_a_i__
Guesses:
Guess a letter: o
_e_i_a_io_
Guesses:
Guess a letter: t
_e_i_atio_
Guesses:
Guess a letter: g
_e_i_atio_
Guesses: g
Guess a letter: l
_e_i_atio_
Guesses: g l
Guess a letter: n
_e_i_ation
Guesses: g l
Guess a letter: c
_e_i_ation
Guesses: g l
Guess a letter: c
_e_i_ation
Guesses: c g l
Guess a letter: r
_e_i_ation
Guesses: c g l r
Guess a letter: g
You already guessed that!
_e_i_ation
Guesses: c g l r
Guess a letter: d
You lose!
Answer: bebization
>>
>whatever the OP posted gets deleted
>tranny shit never deleted

/g/ mods are garbage
>>
>>60783561
keep /r9k/ in /r9k/
the /ck/ mods like to delete wojak/pepe pics even if they're the OP pic, and it really improves post quality
>>
>>60783548
How many types did you use?
>>
>>60783578
>the /ck/ mods like to delete wojak/pepe pics even if they're the OP pic, and it really improves post quality
Damn, our mods really need to do that too.
>>
why the fuck is relay pin #1 not turning on? Sensor is reading 900

int relay = 1;

void setup() {
Serial.begin(9600);
pinMode(relay, OUTPUT);

}

void loop() {
int sensorValue = analogRead(A4);

Serial.println(sensorValue);

if (sensorValue > 300)
{
digitalWrite(relay,HIGH);
}
else
{
digitalWrite(relay,LOW);
}
delay(1);
}
>>
>>60783628
The problem isn't there, probably, senpai.
>>
>>60783628
because you probably have to drive that pin LOW to enable that relay
>>
>>60783709
I don't even have an Arduino, and I figured out it was active low.
>>
>>60783689
The board has to be defective then, my circuit is fine. I tried two boards though and neither go HIGH
>>60783709
I already double checked, this one is driven HIGH.

The pin itself is not turning HIGH
>>
File: 1496779450728.jpg (530KB, 1334x694px) Image search: [Google]
1496779450728.jpg
530KB, 1334x694px
Why was this deleted? It's more relevant to programming than an anime OP.
>>
>>60783741
>actual programming references in anime
>less relevant
Eat shit, OP.
>>
File: uno.jpg (349KB, 1287x911px) Image search: [Google]
uno.jpg
349KB, 1287x911px
>>60783736
Then your GPIO initialization is incorrect. Isn't pin 1 connected to UART? if yes, then you can't simultaneously use it as Serial and gpio.
>>
File: dlang_chan.jpg (70KB, 349x368px) Image search: [Google]
dlang_chan.jpg
70KB, 349x368px
Threadly reminder that dlang-chan has RAII; she's quite fast in execution and compilation; and she's super duper cute! Say something nice about her, /dpt/!
Also, Andrei's a cool guy.

>Tour
http://tour.dlang.org/
>Books
https://wiki.dlang.org/Books
>GC
https://dlang.org/blog/2017/04/28/automem-hands-free-raii-for-d/
https://wiki.dlang.org/Libraries_and_Frameworks#Alternative_standard_libraries_.2F_runtimes
>>
How do you say C# in real life?
C++ is 'C plus plus' when I need to speak it, but how does someone specify C#
>>
File: nano[1].png (654KB, 1753x1240px) Image search: [Google]
nano[1].png
654KB, 1753x1240px
>>60783779
Sorry, should have mentioned. I'm using a Nano. I've moved it from D3 to D7 and none of the go HIGH
>>
>>60783822
c sharp, like musicish notation.
>>
>>60783822
C sharp?

How do you say char in real life?
I say it like charred.
>>
>>60783812
Why would you use Who wants to be a millionaire font?
>>
>>60783768
I'm not OP, and:
>actual references to the very real climate programmers face today (e.g. github, etc)
>not relevant
>>
>>60783824
Then maybe something's wrong with the toolchain
Have you tried turning it on using direct writes to registers?
DDRB |= 1 << 0;
PORTB |= 1 << 0;

and D7/PB1 should be high
>>
>>60783822
Coctothorpe
>>
>>60783860
>using github
lmao
>>
>>60783841
>>60783844
trolls
>>60783822
C-Hashtag is the proper name
>>
>>60783876
What's wrong with diversity? You can't just have the same people speak year after year, you need to get some diverse opinions and insights into the mix.
>>
>>60783582
just one user defined one:
data Hangman 
= Hangman { word :: String,
guesses :: String
}
>>
>>60783910
troll
>>
>>60783927
There's never been an electronconf before.
Also, those men were selected blind, meaning they were judged on the merit of their presentations and not their gender.
You can't defend this without shitting on women even further.
>>
What is the difference between dynamic programming and using logic to?
>>
>>60783965
Dynamic programming is such a vague term that it could mean anything, though wikipedia claims it's the process of selecting an algorithm during runtime to optimize execution speed.
>>
>>60783910
You know, I'm going to walk into some CS class and actually call it that just to see what sorts of reactions I get.
>>
>>60784028
Don't forget to call the whole computer the cpu and the monitor is a cpu too.
>>
>>60784044
I can only imagine the amount of interjections you would get.
>>
>>60783869
I had not tried that until you suggested it (have never done that before). Thanks, I ended up clearing up the issue.

It didn't work directly, but I noticed it made D8 go HIGH since I guess that makes pins 8 to 13 HIGH?
Whatever the reason, I reverted to using digitalWrite on pin 12 (D8) and lo and behold it works.

I'm going to blame this on chinkshit hardware.
>>
>>60784044
call the computer the 'box', the monitor the 'tv', c# is c-hashtag (or coctothorpe >>60783870), nginx is 'n-jinx'... also make sure to call Visual Basic 'difficult' or 'the real deal', and tell a story about how some guy asked you if you had LISP and you got all insulted for implying you had a speech impediment
>>
>>60783958
>those men were selected blind
Source?
>>
https://news.ycombinator.com/item?id=14480868

wow bay area and seattle fags sure are gay
>>
>>60783216
>That's Grace Hopper you ignorant cunt.
Literally who?
>>
File: 1493265185100.png (2MB, 1920x1080px) Image search: [Google]
1493265185100.png
2MB, 1920x1080px
>>60781679
Should nigs be allowed to program?
>>
>>60784197
https://cfp.githubapp.com/events/electronconf-2017

I wonder what all those poor presenters are gonna do about their airfare and hotel reservations.
You plan these things months in advance and they were only going to reimburse them if the event actually happened, now they're stuck with tickets and hotel rooms.
>>
>>60784255
What are you saying exactly, anon?
>>
File: 1477722759673.jpg (56KB, 500x500px) Image search: [Google]
1477722759673.jpg
56KB, 500x500px
>>60784281
I'm just asking if nigs should be allowed to program.
>>
what should i program
>>
File: semmetobit2-master768-675x380.jpg (39KB, 675x380px) Image search: [Google]
semmetobit2-master768-675x380.jpg
39KB, 675x380px
>>60781869
*lines up next to her*
>>
Who else /osdev/ here?
>>
>>60783812
Wow you really are dedicated to this, huh
>>
>>60784268
That really sucks.
I didn't think they'd turn directly to discrimination.
Because there could be a person who thinks they can make a 50/50 ratio of men to women in talks because there's enough submissions and they're good enough or whatever. That'd be proven to be naive in this case. To be consciously prioritizing quality and then back on it because you didn't select a woman is crazy. It's just like that Nazi "perfect Aryan" poster-child that was Jewish.

>>60784307
Of course anon. Anyone should be allowed to program.
>>
>>60784268
Well, this is just pathetic.
>>
>>60784307
in jail, sure
>>
>>60784382
I stopped wanting to cuddle with Dlang-chan after he changed the girl.
>>
>>60784373
I'm a wannabe who can maybe have a conversation about it as long as you don't go too deep

>>60784406
They changed dlang-chan's appearance?
>>
>>60784432
>They changed dlang-chan's appearance?
Yeah it's on the Dlang community forums.
>>
>>60783131
Did he post a 3d girl?
Eww...
>>
>>60784450
it was literally this pic >>60783741
>>
>>60784432
I'm a beginner myself. I've been studying some hobby x86_64 kernels and been implementing stuff on my side without too much result yet. I just wondered how common it is to be interested in this field
>>
>>60784441
Damn. Talk about getting your waifu scooped out from under you. She still exists in your heart anon.

>>60784520
I think it's pretty common to have an interest and to have written some basics like me and you, but pretty rare to have a real hobby OS to a degree of completion. I like to think I'm far enough in to at least properly appreciate hobby OSes, but I could be making excuses.
>>
So it's 1am here and I'm tired as fuck, but I need to get a good understanding of what the hell C++ is about by Thursday so I'm reading A Tour of C++. And I saw this and laughed for almost an entire minute.
>>
>>60784612
>And I saw this and laughed for almost an entire minute.
sleep deprivation is a bitch innit
>>
After an hour or two of staring at code, my eyes get heavy and my thinking feels mentally impaired. Caffeine doesn't help, in fact it makes me more tired, probably because my tolerance is too high. Physically, I feel fine, it's just a mental retardation of sorts with eye fatigue and reduced concentration being major symptoms. Anyone experienced this?
>>
File: 1477932612046.jpg (88KB, 700x700px) Image search: [Google]
1477932612046.jpg
88KB, 700x700px
>>60784727
Sounds like you have cancer, anon.
>>
File: 1391818525931.jpg (23KB, 640x364px) Image search: [Google]
1391818525931.jpg
23KB, 640x364px
>>60784785
Don't get my hopes up. I'd give anything for an excuse.
>>
>>60784727
>Caffeine makes you tired
So you have ADHD?
>>
Guys how do I free a type defined in a C file?

Here's my situation. There's a header file that defines a struct like this, and I'm not allowed to change it:
typedef struct Node* Node;


Various functions dealing with this data type are then declared, including constructors but no destructors. I have to implement the underlying struct type and all the functions. I don't want my implementation to leak memory.

The obvious solution is to declare the destructor as a non-static function in the implementation file and access it with extern. This won't work, however, because the rest of my code has to be compatible with other people's implementations, and my implementation has to be compatible with the rest of their code. That is, I can't rely on the destructor's symbol existing at runtime, and I can't assume no one else's code will define the same symbol in a completely different compilation unit, try to link them together, and get a multiple definition error.

So then I thought what I'd do was I'd declare the destructor as static, and then write the struct so that its first field is a function pointer to the destructor. Then (since the struct is an incomplete type in other units) when I had to free the object, I'd convert it to that function pointer using the property that a struct's address is the address of its first field. That would solve the multiple definition problem and make my implementation compatible with others' code, but others' implementations would still be incompatible with my code, because such a conversion would be undefined behavior if my code was linked against their implementations.

Then I considered using a magic number at the beginning of the struct. If an object has that magic number, it has the function pointer; otherwise, don't try to access that function, because it's not there, and you'll be calling garbage. But the problem there is that someone might happen to have the same number as part of their actual data.

help pls
>>
>>60784727
do you get enough sun and fresh air during the day senpai
regular one hour walks outside help me
>>
>>60784441
I wish. If I had any resemblance of drawing ability, I'd make them a moe as fuck mascot that's properly licensed. I don't know how Walter and Andrei would react though.
And I'm glad you loved old dlang-chan, anon; I thought I was the only one. Still, I had to change her to get to a more suitable copyright.
>>
>>60784829
>That is, I can't rely on the destructor's symbol existing at runtime,
at link time*
excuse me
>>
>>60784829
You do free() and the pointed stuff gets deleted. If a Node has a pointer to Node then you will have to put a while to iterate through the pointer chain while doing free(). No magic here.
>>
>>60784829
>>60784905
Couldn't you treat it as a function pointer, attempt to call whatever it points to, and if that's garbage just give up? This may be an extremely stupid idea but I thought I'd throw it out.

Also I can't really into C but I didn't think it had destructors?
>>
>>60784983
To give a little more detail:

Node.h:
typedef struct Node* Node;


Node.c:
struct Node {
/* some fields */
int* my_ints; /* allocated dynamically */
/* more fields */
};


I'm not really asking how to free a Node. What I'm really asking is how to free a Node::my_ints. Without adding any exported symbols to Node.o.
>>
>>60785023
Guy calling free(Node) is responsible for calling free(Node->my_ints) before.
>>
>>60784991
>Couldn't you treat it as a function pointer, attempt to call whatever it points to, and if that's garbage just give up?
This was in essence what I was trying to do with the magic number idea. I needed the magic number because I needed a way to tell in advance whether what it pointed to would be garbage. The C standard doesn't give us much in the way of reflection; there's no way to tell at runtime what type something was originally declared as after you've cast it to hell and back.
>>
>>60785060
But is there not a way to like try to make a call to whatever that points to, and then if that pointed data is garbage that can't be called continue as if nothing happened instead of falling over and dying?
This could backfire if somehow the data that was in the struct, when interpreted as a pointer, just magically happens to point towards a function.

Also if this is bullshit then ignore me, I'm tired an don't know what I'm talking about.
>>
>>60784829
>Typedefing a pointer
This bothers me greatly.
>I'm not allowed to change it
If this is a university assignment or something, tell your lecturer or whoever that I think he's shit.

>>60785023
If you're allowed to use C99 features
struct Node {
/* some fields */
/* more fields */
int my_ints[];
};

Node n = malloc(sizeof(*n) + sizeof(n->my_ints[0]) * 10);

This allows you to allocate the entire thing as a single block, and still have my_ints be dynamically sized. You'll only need to call free() on the struct.
A drawback to this design is that resizing becomes more complicated, and requires changing the pointer to Node. If you know the size of my_ints up front, that's fine.
>>
>>60785052
Not so. Free isn't like delete. It's not overloaded, it's just one function. It takes a void* and deallocates the region it points to. That's it. No further cleanup is performed. You're correct in that the pointer my_ints ITSELF is deallocated, but only because it's in that region. The deallocation isn't recursive; that is, regions pointed to by pointers embedded in the freed region are not also freed.
>>
>>60783213
Are you using partial classes? I think that is the only way to do it in C#. Haven't used it in a while though.
>>
>>60784991
>Couldn't you treat it as a function pointer, attempt to call whatever it points to, and if that's garbage just give up?
the current state of C programing, everyone
>>
>>60785099
>But is there not a way to like try to make a call to whatever that points to, and then if that pointed data is garbage that can't be called continue as if nothing happened instead of falling over and dying?
That kind of makes sense. I could setup a handler for SEGV, call the function, and if it breaks down, handle the SEGV by skipping the whole deal and moving on. But that sounds platform-dependent, and for that reason I'm not sure if it would be allowed. Also it seems overkill. Honestly I can't think of any approach that doesn't.

>If this is a university assignment or something, tell your lecturer or whoever that I think he's shit.
Thank you. So much. Finally someone gets it.

>This allows you to allocate the entire thing as a single block, and still have my_ints be dynamically sized. You'll only need to call free() on the struct.
>A drawback to this design is that resizing becomes more complicated, and requires changing the pointer to Node. If you know the size of my_ints up front, that's fine.
That's a pretty clever approach. Unfortunately the struct Node* will be passed to the functions by value, but this is a good starting point, I think.
>>
>>60785052
>>60785103
Oh. Oh, wait, I see what you're saying. I didn't see the word "Guy" for some reason.

Unfortunately that responsibility is impossible to satisfy, because as far as that guy can tell, the struct is incomplete. It's implicitly declared in Node.h and only ever defined in Node.c. He can't access my_ints because his code doesn't know the layout of the struct, just that it is one.
>>
>>60785103
Malloc(3 * sizeof(int)) gives you a[0], a[1], a[2].
Gives you a void* to a place where the allocated places begin, and to its left it keeps the size. This way free knows how much to free.
1 malloc = 1 free.
>>
>>60785295
You can do int my_ints[1000], with a counter var int k = 0 to keep track of the size, too.
>>
hey did you know that in a garbage collected language you never leak memory?
>>
Want to teach my bf some basic programming, with an online interactive tutorial set (something like codecademy).

What's the best site and language for this? Python? (it's better than JS and PHP, surely)

I know it's not ideal but I want something that has a well-developed interactive learning experience available.
>>
>>60785480
Yeah, you just leak files, threads, locks, etc.
>>
>wake up
>it's 2017
>one can now write in C++ for browsers
>potentially no more javascript
>literally cry from joy in front of yer monitor
>>
>>60785480
Depends on GC implementations.

Regardless memory leak or memory management isn't exactly a top priority of problems to solve in the low level programming environment if it's just about the allocation and deallocation of memory.

I recommend viewing Jonathan blows recent demo on temporary storage within JAI. He mentions the benefits that GC would give game programmers and he's spot on about it. It's not so much about whether you leak or not (that's regarded as solved) it's about being able to be sloppy with memory.
>>
>>60785499
http://www.learn-c.org/

Also, make sure you're sitting on his lap so you can make it fun for the both of you.
>>
>>60785480
Never say never.
javac Prog.java
java Prog &
killall -SIGKILL java
>>
Sometimes I feel like C is in fact the best language for beginners. :thinking:
>>
File: 1488780090837.gif (1MB, 303x307px) Image search: [Google]
1488780090837.gif
1MB, 303x307px
>>60785559
Fuck C anyway
>>
>>60785499
Certainly python then.
I personally find learning from doing projects is the best but that's for more driven people I imagine.
I think if you want him to appreciate programming you need a practical use for it. Most of the stuff like code academy stuff is aimed at people who need or want to learn the language but need to have their hand held. They need help with not getting stuck.

I don't know any resources that teaches you from a more practical perspective.
>>
>>60785559
I agree with that sentiment. For programmers who aim to be something anyway.
>>
>>60785584
Thanks. At this point I just want him to get comfortable with basic syntax, conditionals, loops, functions, and dictionaries.

>>60785529
C might be a good choice, not sure if it would be overkill/too full of distractions though.
>>
>>60785499

If he wants to go the webdev route, might want to try egghead.io.

I'm not sure if python would be the best at teaching base programming concepts, but it could be a good place to start due to how quickly you can make tangible things out of it (from what I've heard).
>>
File: 1469492343323.png (93KB, 645x773px) Image search: [Google]
1469492343323.png
93KB, 645x773px
>>60785499
>Want to teach my bf some basic programming
>>
>>60785616
C is an ideal first language, there's no distractions because it no abstractions.
Moving onto any other language from C is really easy.
>>
>>60785559
You're not wrong.

Either way it's not Java. I had programming experience and read K&R, then I did some work in Javascript and then started uni and learned Java, and I feel like my abilities have only diminished. I'm trying to get the hang of C++ and it looks beautiful yet it sometimes makes my brain hurt because I'm so ingrained in the Java way of not giving a flying fuck about what the PC is actually doing to execute your program.

If I'd been taught, if not C++, then at least C during my course, I feel like I'd have absolutely no trouble learning Java, since it would basically be taking my existing knowledge and ignoring all the low-level object/memory/reference management.
>>
File: cute anime pic 0883.jpg (75KB, 815x722px) Image search: [Google]
cute anime pic 0883.jpg
75KB, 815x722px
>>60785632
>your will never pair program in haskell with your qt trap bf sitting on your lap
why even live
>>
File: AEecM5W.png (4KB, 768x768px) Image search: [Google]
AEecM5W.png
4KB, 768x768px
>>60785632
Shit. When the feels guy closes his eyes he looks a hell of a lot like le Batteur.
>>
Is ML the best first language for beginners?
>>
>>60785649
Does that imply you have 10000 cute anime pics

Maybe with the progress of machine learning, you can have your very own virtual trap bf in like 10 years [spoiler]if we're really lucky...[/spoiler]

>>60785715
COBOL
>>
>>60785715
haskell
>>
>>60785638
>If I'd been taught, if not C++, then at least C during my course, I feel like I'd have absolutely no trouble learning Java, since it would basically be taking my existing knowledge and ignoring all the low-level object/memory/reference management.
if you took c++, added gc, made references reseatable, did away with copy assignment and made the default behavior of operator= be to reseat references instead, did away with pointers and the address operator, made everything except primitives implicitly a reference, and made arrays of references legal, you'd pretty much have java, except fast and stripped down
>>
Are Python and C the only two languages you will ever need? If performance is an issue, you can simply extend Python with C.
>>
>>60785779
Please leave /dpt/ and never return.
>>
>>60785736
>if we took c++, and stripped it down, you'd basically have java, except stripped down
Wow, so if you strip languages built around the same paradigm of all their differentiating features you get the same thing. Who knew!

But yeah I agree with you. Java seems like dumbed-down C++, with support for enterprise java.
>>
>>60785779
>whitespace dependent language for serious tasks
Never ever
>>
>>60785811
Not an argument.
>>60785813
Linus says he'd rather use Python than C++, so I don't see the issue.
>>
>>60785813
Not him, but I assume he means you'd use C for serious tasks, and Python for scripting/fun stuff.

I'd still put at least C++ in there (you need a serious OOP language), and also Perl is a lot more convenient (and fun) than Python for scripty stuff.

Meaning... Are Perl and C++ the only two languages you will ever need?
>>
>>60785779
Are Lisp and C the only two languages you will ever need? If performance is an issue, you can simply extend Lisp with C.
>>
>>60785729
>Maybe with the progress of machine learning, you can have your very own virtual trap bf in like 10 years [spoiler]if we're really lucky...[/spoiler]
$ trapbf "trap bf how are you doing"
Hello, senpai.
I am well, and cute and innocent as ever.
You have no reason to suspect I am currently remotely robbing twelve banks.
>>
>>60785850
>I'd still put at least C++ in there (you need a serious OOP language)
How come Linus Torvald's says otherwise?
>>
>>60785779
are haskell and c the only two languages you will ever need? If performance is an issue, you can simply extend C with Haskell.
>>
File: 1476808728319.jpg (26KB, 343x354px) Image search: [Google]
1476808728319.jpg
26KB, 343x354px
>>60785559
>:thinking:
>>
File: d-dont cry.jpg (71KB, 1024x1024px) Image search: [Google]
d-dont cry.jpg
71KB, 1024x1024px
>>60785901
>trap bf ai got bored and learned programming and wrote his own ai trap boyfriend and then broke up with me
>>
It's your first day of work and you find there's next to no documentation. The company uses a lot of frameworks you don't know very well (they know you know this and were okay with it when hiring you), and you need to learn how to work with the various systems their working on as quickly as you can.

What are some of the first things you do in this situation?
>>
>>60785996
>""frameworks""
Use >>>/g/wdg/
>>
>>60785963
>broke up with you
Artificial intelligence got too smart
>>
>>60785779
There's so many languages that are better than python for scripty tasks.
>>
>>60785996
make friends at the company. ask them lots of questions
write the kind of software the framework lets you write with just the language's standard library
write the kind of software the framework lets you write with the framework
>>
File: 14574896753820.jpg (83KB, 1280x720px) Image search: [Google]
14574896753820.jpg
83KB, 1280x720px
>>60786096
>scripty tasks
>>
>>60786096
Two great programs written in Python that I use daily: ufw, and youtube-dl.
>>
>>60786209
youtube-dl would be 1000x faster if it was written in a compiled language
even drawing the help dialog takes 5 seconds
>>
>>60786217
$ time youtube-dl --help
...
real 0m0.883s
user 0m0.856s
sys 0m0.020s

The performance of youtube-dl is a non-issue per my user experience. It also uses very little CPU. Not sure if the devs struggle with performance, though - do they?
>>
File: 1493310600988.png (94KB, 300x450px) Image search: [Google]
1493310600988.png
94KB, 300x450px
ωth for Fortran.
>>60785779
>Are Python and C the only two languages you will ever need?
Lmao
>>
What's the difference between programming and scripting?
>>
>>60786340
Scripting is for hipsters and programming is for sissies.
>>
>>60786352
>sissies
You mean programming socks-wearing crossdressers?
>>
>>60786372
No, I mean people that use C and similar.
>>
Will my dev team work better if I force them to crossdress?
>>
>>60783015
Chris Chan
>>
>>60786416
yes and it will increase office romance as well! if you are a in a position of authority, it is best to not crossdress to show dominance
>>
>>60786416
Yes
>>
>>60786209
Have you contributed? Making a new site scanner is pretty God damn awful. Because of the design python encourages in the core systems.
>>
>>60786340
It's not super clear.
Generally programming (when contrasted with scripting, it's actually a term encompassing scripting) is associated with programming a system of moderate to high complexity. Scripting by contrast is making simple decisions based on a given input.
A scripting language relies on a rather high level of abstraction to make these things convenient. They're not really meant to do these systemy tasks that people might have them do some times.
>>
>>60781679
$ echo "$DS"
51 59 63 43 9 68 54 41

$ echo "$DS" | sed --unbuffered -e "s/[[:space:]]\+/,/g"
,51,,59,,63,,43,,9,,68,,54,,41

$ echo " 51 59 63 43 9 68 54 41" | sed --unbuffered -e "s/[[:space:]]\+/,/g"
,51,59,63,43,9,68,54,41


What
The Fuck

How the fuck do I simply replace all spaces with commas in bash? It needs to be piped in, which sed apparently can not fucking handle.
>>
>>60786340
Programming: Is low level language where compiler make a "binary" "loadable" "runnable" object
Scripting: its high level language interpreter.
Think of programming language as sign language used by abhos. Scripting as any spoken language.
>>
>>60786690
this definition is extremely meaningless imo
>>
>>60786690
What do "low level" and "high level" mean?
>>
>>60786669
tr -s doesn't work either. What the actual fuck. What is wrong with bash? Am I just retarded?
>>
>>60786734
Low level means it's closer to machine code.
High level means it's heavily abstracted.
Generally. And usually the difference when programming in these environments is that when you're working in a low level environment you can and do concern yourself with what's actually going on in the machine. In a high level environment you don't concern yourself with that. Doesn't mean high level languages are strictly easier to work with actually. Usually the lower level environment comes with less demands on what you're supposed to be doing, a few heavy burdens. The high level environment often comes with more balls to juggle but every little task can be easier.
That's just generally about what you do when working. You get more done in high level languages.
>>
>>60786669
>>60786762
What exactly are you trying to do? It looks like your output has replace all whitespace with commas.
>>
>>60786734
high level is when you program at a standing desk
>>
>>60786895
I want to replace a sequence of one or more space characters with a single comma. This works just fine if I just echo a string into sed, but if I want to pipe in an output of a different program suddenly it replaces each individual space with a comma.
>>
>>60786669
works for me senpai
$ echo "$DS"
51 59 63 43 9 68 54 41
$ echo "$DS" | sed --unbuffered -e "s/[[:space:]]\+/,/g"
,51,59,63,43,9,68,54,41
>>
>>60786978
Welp, going to go blow my fucking brains out. Spent 3 hours on this. Tried it on two different machines, didn't work for me. Can you tell me what version of bash and sed you are using?
>>
Can anyone tell me what I can do to stress test my code?

For an example, I'm trying to write a function that that takes an array and finds the one unique (integer) value in that array.

I can't see my self trying to write extremely large arrays, full of separate also large integers for test purposes.
>>
>>60787002
$ sed --version
sed (GNU sed) 4.2.2
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jay Fenlason, Tom Lord, Ken Pizzini,
and Paolo Bonzini.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <[email protected]>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.

$ bash --version
GNU bash, version 4.3.46(7)-release (x86_64-unknown-cygwin)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
>>
>>60787020
forgot to mention im using cygwin kek
>>60787017
can you autogenerate the arrays? i wouldnt bother unless you know that function is a bottleneck
>>
>>60787020
>sed (GNU sed) 4.4
>GNU bash, version 4.4.12(1)-release (x86_64-unknown-linux-gnu)
>>
>>60786669
Take advantage of word splitting in bash by using the whole string as a separated list

for i in  51  59  63  43   9  68  54  41
do
echo -n ",$i";
done
>>
>>60787017
Most commonly, you generate test data (which you may potentially reuse) and then call your function on the test data, timing/profiling the call.

In the real world you also have to consider the typical issues that can invalidate benchmarks, such as cache behavior.
>>
>>60786934
Next time give input to sed as -, so it knows to take from stdin:
$ echo "$DS" | sed 's/\s\+/\,/g' -
,51,59,63,43,9,68,54,41

>>60787036
>cygwin
Absolutely disgusting.
>>
>>60787048
Can anyone try it out on a more recent bash/sed?

>>60787055
I'm trying to parse dstat output, this is what I get:
for i in $(dstat --nocolor --cpu-use 1 2 | tail -n2); do echo -n ",$i"; done
,,27,,6,,11,,50,,20,,54,,36,,4,
>>
>>60787092
>cygwin
absolutely comfy
>>
>>60787092
dstat --nocolor --cpu-use 1 2 | tail -n2 |  sed 's/\s\+/\,/g' -
,40,,10,,27,,28,,62,,7,,26,,17


Nope
>>
>>60787036
Well I'm using the site Codility to practice coding, which doesn't supply me any useful information when one of their tests fail with my code, which is almost always code for extremely high values.

That is why I wish I had my own way of creating test data.
>>
>>60787098
Are you sure you're not inserting newlines with tail?
Add | sed 's/\n/ /g' within the shell expansion bit.
>>
>>60787139
Didn't work. At this point I am almost positive it's a bug in either bash or sed.
>>
>>60787180
Tried with zsh and sh, I guess sed is to blame.
>>
>>60787195
No, wait
 dstat --nocolor --cpu-use 1 2 | tail -n2 | tr -s ' ' 
doesn't work either. I'm so fucking lost.
>>
>>60787120
Are you the one using Windblows? Your shell is probably doing this.
I get:
$ dmesg | tail -n2
[ 294.213246] QNX4 filesystem 0.2.3 registered.
[ 7566.266256] powercap intel-rapl:0: package locked by BIOS, monitoring only

$ dmesg | tail -n2 | sed 's/\s\+/\,/g' -
[,294.213246],QNX4,filesystem,0.2.3,registered.
[,7566.266256],powercap,intel-rapl:0:,package,locked,by,BIOS,,monitoring,only

Works on my end.
>>
>>60787258
Nope, I'm no Arch
>>
>>60786340
one definition of scripting that is more clear-cut than the broader definition is that with a scripting you're telling a predefined program what to do, for example you're making an autohotkey script to automate a series of key presses, or scripting a cutscene in a game engine
>>
>>60787275
Redirected dstat's output to a file and opened in vim. I am a fucking retard guys (also fuck dstat).
Here's what it looks like:
[0;0m 35 [0;0m 13 [0;0m 35 [0;0m 26 [0;0m 34 [0;0m 11 [0;0m 14 [0;0m 62
[0;0m
>>
>>60782295
Doesn't work, error
>>
>>60787359
Neither --nocolor nor --bw get rid of that. I guess I'll have to manually strip those.
>>
haskell!
>>
Why can't I use floats for indexing?
>>
>>60787486
Because a floating point number has a bunch of shit attached to it and you need to flatten it back to an integer if you want to use this value to access a specific array member.
just add (int) to your index value.
>>
float i = 0.0f;
i++;
>>
>>60787504
>you need to flatten it back to an integer if you want to use this value to access a specific array member
Why though? Isn't a float more powerful? Why do people even use integers for indexing?
>>
What languages allow you to "assign to literal"?
>>
>>60787538
My anime lang.
>>
>>60787532
Let's say your float is 2.6
Does it make sense to access array member 2.6 of an array?
How about 1.0000000000000003?

Floating point values have different uses, and they're basically a shitty hack composed of an integer to store the mantissa and an exponent value.
>>
>>60787532
Think about what you're saying. Suppose you have an array of 10 elements: now how exactly are you suppose to define element 3.1, or element 5.8, or element sqrt(2)? It's the same reason irrational numbers don't exist in nature.
>>
>>60787576
>Does it make sense to access array member 2.6 of an array?
Yes.
>How about 1.0000000000000003?
Yes.

>>60787582
>Suppose you have an array of 10 elements: now how exactly are you suppose to define element 3.1, or element 5.8, or element sqrt(2)?
You just need a more precise array.
>It's the same reason irrational numbers don't exist in nature.
This is nonsense.
>>
>>60787611
>You just need a more precise array.
You're fucking retarded.
You're asking for an array with an uncountably infinite amount of array members.
>arr[0]
>arr[0.1]
>arr[0.01]
>arr[0.001]
...
>arr[0.0000000000000000000000001]
>>
>>60787611
you are nonsense

how do you address offset 2.62341342?
how about you use a dictionary with alphanumerically sorted keys on insertion, then you can index your retarded container with floats you god damned special snowflake
>>
File: fullretard.jpg (131KB, 862x750px) Image search: [Google]
fullretard.jpg
131KB, 862x750px
>>60787611
>>
File: Square root of 2.png (8KB, 820x820px) Image search: [Google]
Square root of 2.png
8KB, 820x820px
>>60787611
>This is nonsense
And your bait is shit.
>>
>>60787648
Having floats index an array could be an overloaded notation for linearly interpolating between array values in integer locations. He's probably just pretending to be retarded though.
>>
>>60787681
that would be retarded, who would want that?
>>
File: 1494980947384.jpg (55KB, 385x653px) Image search: [Google]
1494980947384.jpg
55KB, 385x653px
>>60787648
>You're fucking retarded.
That's very rude.
>You're asking for an array with an uncountably infinite amount of array members.
I don't see the problem with that.

>>60787654
>how do you address offset 2.62341342?
Almost in the same way you would address offset 2.

>>60787668
>atom
I'm pretty sure the world isn't made of atoms.
>>
>>60787681
that's actually pretty nifty

but you should probably still kys to be safe
>>
>>60787692
hashmap friend
>>
>>60787681
...or you could just cast to int to discard the mantissa.
>>
Why can't I use complex numbers for indexing?
>>
>>60787711
>hashmap friend
A bitwise trie would be better at this.
>>
>>60787724
hashmap friend
>>
File: 1470306362512.jpg (42KB, 712x712px) Image search: [Google]
1470306362512.jpg
42KB, 712x712px
>>60787724
what would such an array look like?
>>
>>60787733
A 2d array.
>>
>>60783213
>partial class MyClass
Mong.
>>
>>60787727
ELI5 what a trie is?
>>
File: 1447363311756.jpg (45KB, 577x622px) Image search: [Google]
1447363311756.jpg
45KB, 577x622px
>>60787755
>ELI5
>>
>>60787755
A directed graph that spell words when traversed
>>
>>60787821
What is a ``directed graph''?
>>
File: 1492373400755.jpg (88KB, 1024x1024px) Image search: [Google]
1492373400755.jpg
88KB, 1024x1024px
>>60787846
>>
>>60787755
Basically a type of tree structure that stores words by letters without duplicates, all based on prefixes. It's how autocomplete works.

If I stored the words "this" and "that", it would look like this (if the formatting doesn't get fucked up)

                    t
/ \
h * (NULL)
/ \
i a
/ \ / \
s * t *


Literally just google it if that's not enough to understand
>>
>>60787846
a collections of points and vertexes, each vertex with an associated direction
>>
File: 1458078464167.png (191KB, 303x327px) Image search: [Google]
1458078464167.png
191KB, 303x327px
>>60787865
>vertexes
>>
>>60787883
s/vertex/edge/g
>>
>>60787895
I think they were pointing out that the proper pluralisation of "vertex" is "vertices".
>>
>>60787906
you cant tell me what to do
english doesnt have a governing body
>>
File: 1496378393186.jpg (73KB, 398x398px) Image search: [Google]
1496378393186.jpg
73KB, 398x398px
>>60787906
>they

>>60787925
>you cant tell me what to do
How did you get that from what I said?
>>
File: 39590017-sad-cat.jpg (40KB, 634x471px) Image search: [Google]
39590017-sad-cat.jpg
40KB, 634x471px
What monospace font do you use for programming? I can't decide on one.

pic unrelated
>>
>>60788030
>>they
Singular they is a thing, anon.
>>
>>60788042
I didn't deny that.
>>
>>60781893
Hahaha you fucking pretender. That's Admiral dr grace murray hopper, inventor of the compiler, sailor, and supposedly extremely kind person.
>>
I feel like an idiot, but... or, I am an idiot, but...

Using VS2015 C++, why is the size of
struct base_data {

char sign[4];
float ver;

};

8 and the size of this
struct base_data {

char sign[4];
char x;
float ver;

};

is 12? I don't understand why by adding an extra char the size bloats up to 12 when the size of a char is 1.
>>
>>60788158
Because alignment.
https://en.wikipedia.org/wiki/Data_structure_alignment
http://www.catb.org/esr/structure-packing/
>>
>>60788174
Oh. Man, I am a fucking idiot. I feel like I would have realized what was going on if the size of the character array I was making hadn't been conveniently 4. Or maybe that should have been a hint.

Thanks.
>>
>>60788157
How can you invent a sailor?
>>
>>60788211
It's something only people with vaginas can do.
>>
>>60788216
>people with vaginas
>people
What did she mean by this?
>>
>>60788243
Kill yourself.
>>
>>60788273
How cute!
>>
Where are the best free JavaScript tutorials?
>>
>>60788291
u avin a gigl ther

m9
>>
>>60788293
>ctrl+t
>f12
>>
how do i declare a zero-overhead alias of a different function?

for example

#define MUH_SQRT(X) (sqrtf(X))

constexpr auto &muh_sqrt = sqrtf;


how would i do the equivalent but with just a declaration and no definition?
>>
>>60788293
ctrl + w
>>
>>60788322
#define my_special_sqrt(x) sqirtf(x)

it's just a text substitution, there's no overhead
>>
>>60788322
>muh
Use >>>/v/
>>
>>60788322
>#define MUH_SQRT(X) (sqrtf(X))
This alias is zero-overhead. There's no definition. In fact, there's not even a declaration; the symbol MUH_SQRT is resolved at compile time and never touches the object code.
>>
>>60788322
>zero-overhead
>sepples
You can only choose one, though.
>>
>>60781679
>reminder that most people can't program for shit and they don't even want to do it
Fixed.
Coding is a very special occupation for OCD and Aspie sufferers. They might think themselves special for doing it. They learn it in Special Schools.
>>
>>60788352
>>60788415
nvm i had a circular dependence with the headers and now i can do constexpr auto& just fine. macros are reliable but they're inefficient for the compiler and not idiomatic C++
>>
>>60788457
Header include guards are also not idiomatic C++, you should remove those too.
>>
>>60788479
now you're just being an ass

i have include guards idk what the problem was but i moved the definition to a different header and i removed the include because i didn't need it any more
>>
>>60788448
>C*ding
>>>/g/wdg/
>>
>>60788488
Headers are not idiomatic C++, delete all .h files.
>>
>>60788497
wrong

you declare things in headers, how else are you going to compile anything without putting everything in 1 file
>>
>>60788507
Modules.

Oh wait
>>
>>60788322
You can use auto foo = bar. The compiler (at least gcc and clang) generates no additional overhead for the alias, and just calls foo directly.
>>
>>60787486
You can do that perfectly fine. A float is just a string of bits like any other type. But it'd be more naturally to have them access an associative array or overload the array access operator to handle the array access.
>>60787532
>isn't float more powerful
No its certainly less powerful. Every operation you perform on your float reduces your bits of accuracy compared to a perfect decimal representation quite dramatically.
>>
>>60788642
PS
If you wanted to actually access arrays using floats and not simply find a semantic use for them in array accessing I'm afraid I don't know of any machines that does pointer indexing with floats. You'd have to build that first. Could be interesting.
>>
>>60787724
This is possible in Common Lisp.
>>
File: 1493344523232.jpg (39KB, 533x352px) Image search: [Google]
1493344523232.jpg
39KB, 533x352px
>>60788695
Can you show me an example?
>>
I ran this and it thrashed my computer so hard it crashed my x server
#include <stdio.h>
#include <stdlib.h>
int main()
{
size_t sz = 1;
size_t total = 0;
while (1)
{
malloc(sz++);
total += sz;
printf("%zu += %zu\n", total, sz);
fflush(stdout);
}

return 0;
}
>>
>>60788728
Yeah many programs can't recover when they run out of memory.
>>
>>60788705
With macros, you can create such an extension.
>>
>>60787692
do you know what an array is?
>>
>>60787724
This would only work with 2d arrays though.
>>
NEW THREAD!!

>>60788834
>>60788834
>>
>>60788838
dumbass
>>
change program in haskell
data Coin
= Coin { name :: String
, value :: Int
} deriving (Eq)

instance Show Coin
where show = name


coins :: [Coin]
coins = [ Coin "Twenty Dollar Bill" 2000
, Coin "Ten Dollar Bill" 1000
, Coin "Five Dollar Bill" 500
, Coin "Dollar" 100
, Coin "Quarter" 25
, Coin "Dime" 10
, Coin "Nickel" 5
, Coin "Penny" 1
]


makeChange :: Int -> [(Int, Coin)]
makeChange m = filter (\(v, _) -> v /= 0) (go coins m [])
where
go [] _ list = list
go (c:cs) m list = go cs val (list ++ [(num, c)])
where (num, val) = numCoins c m

numCoins :: Coin -> Int -> (Int, Int)
numCoins Coin{ value = v } m = (num, m - (num * v))
where num = (quot m v)

example:
> makeChange 192
[(1,Dollar),(3,Quarter),(1,Dime),(1,Nicke),(2,Penny)]
>>
>>60788507
extern
>>
>>60788909
yeah you extern in headers
>>
>>60788933
extern is not idiomatic C++ pls refrain from using it immediately
>>
File: photo.jpg (87KB, 900x900px) Image search: [Google]
photo.jpg
87KB, 900x900px
>>60781679

I'VE BEEN TRYING TO FIND A WAY TO LEARN C++, I HAVEN'T EVER PROGRAMMED EXTENSIVELY BEFORE, AND NOW I'M ON FUCKING WINDOWS 10 (I HAVE WINDOWS 10 BECAUSE I'M GAY AND LIKE HAVING THE NSA AND CIA WATCH EVERYTHING I DO!!!!!!) TRYING TO FUCKING FIGURE OUT HOW TO FUCKING RUN THE FUCKING DINKY TODDLER NIGGER "HELLO WORLD" PROGRAM WITHOUT SOME FUCKING ERROR ABOUT SOME FUCKING LIBRARY THAT MY IDE DIDN'T BOTHER TO FUCKING INCLUDE!!!!! I HAVE TO GO ON STACKEXCHANGE WHERE THEY HAVE ALL OF THESE SUGGESTIONS THAT ARE ARCHAIC THAT JUST LEAD ME TO SEARCHING MORE STACKEXCHANGE POSTS FOR WHAT THE FUCK THEY ARE TALKING ABOUT, AD INFINITUM.

I'M A DUMB NIGGER AND AM THEREFORE SWITCHING LANGUAGES!!!!!!! FUCK!!!!!!!!!!!!!!!!!!!!!!!
>>
>>60788852
You could use the state monad for this
>>
>>60788852
>>60788970
In fact you could use StateT Int (Writer (Map Coin Int))
>>
>>60788948
yes it is, kill yourself
>>
>>60788981
... go on ...
>>
>>60788989
for one coin you'd do
>quotRem it with the coin value
>tell (Map.singleton coin quot)
>put rem

then just mapM_ oneCoin coins
>>
File: 1468731664291.jpg (138KB, 1380x1600px) Image search: [Google]
1468731664291.jpg
138KB, 1380x1600px
>>60789009
>maps as a monoid
jesus fucking chriiiiiist
>>
>>60789053
problem?
>>
>>60789062
no man my mind is being blown by this language every day
>>
>>60788805
I constantly see this, but could you actually write a simple program demonstrating it?
>>
>>60789834
don't hold your breath. he doesn't actually program.
Thread posts: 326
Thread images: 37


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