[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: 350
Thread images: 44

File: hey sexy.jpg (71KB, 500x375px) Image search: [Google]
hey sexy.jpg
71KB, 500x375px
old thread: >>56681175

What are you working on, /g/?
>>
File: gifgif.gif (219KB, 621x457px) Image search: [Google]
gifgif.gif
219KB, 621x457px
>>
Just finished some basic binary search functions. Vector of items of type T n stuff.
>>
>>56687778
Adding a Registration and a "Forgot password" views to my login window.
>>
nothing right now cause I don't feel like it

should be working on my json-based document database though
>>
File: 1455627844909.png (581KB, 438x897px) Image search: [Google]
1455627844909.png
581KB, 438x897px
Still working on akari-bbs!

Do you think it's a bad idea to run strstr in reverse by reversing the haystack and needle in order to find the last instance of a string?
>>
>> Be a Haskell autist.
>> Write a minesweep in clojure.
>> Write a big-ish 15-line function.
>> Calling it fails and gives a NullPointerException with no additional information whatsoever.

I miss muh types and GHC error messages.
>>
need project ideas, please help
>>
>>56687968
autism simulator
>>
Reminder to look back on old code and learn from your documentation mistakes
>>
File: awoo~.png (762KB, 1000x1000px) Image search: [Google]
awoo~.png
762KB, 1000x1000px
How does this post make you feel?

>>56686223
>>
>>56687722
I can't emulate this, I can need it to work with the makefile, what do?
>>
File: 1435200181177.png (176KB, 437x556px) Image search: [Google]
1435200181177.png
176KB, 437x556px
>>56687961
I feel you bro.
>The Hindley-Milner type system is one of the greatest (yet least-known) achievements in modern computing.
>>
>>56687930
every time I read it as akari-boobs.
change the name to akari-boobs already!
>>
Haskell
>>
File: turboc.png (10KB, 650x102px) Image search: [Google]
turboc.png
10KB, 650x102px
>turbo C explodes when trying to use kdq

Fugg.
>>
>>56688114
what year is it?
>>
Making a new "Ayy Lmao" virus. What features do you guys think should be in it?
https://www.youtube.com/watch?v=iszCXbFwcdg [Embed]
for those who don't know what it is.
>>
File: Windows 98-2016-09-18-11-26-11.png (406KB, 1586x855px) Image search: [Google]
Windows 98-2016-09-18-11-26-11.png
406KB, 1586x855px
>>56688139

The current one.
>>
>>56688151
cringe
>>
File: hereyougo.gif (88KB, 10000x10000px) Image search: [Google]
hereyougo.gif
88KB, 10000x10000px
>>56688177
How to add cringe?
>>
>>56687961

>Calling it fails and gives a NullPointerException with no additional information whatsoever.

You honestly don't need anymore information than "hey retard, you dereferenced a null pointer." Try to git gud at debugging.
>>
>>56688190
You post this image every thread

It's hilarious, well done xd
>>
File: was_a_mistake1.jpg (35KB, 1500x751px) Image search: [Google]
was_a_mistake1.jpg
35KB, 1500x751px
>>56688213
Null was a mistake.
>>
ive never programed before
But is it possible for me to make a sneaker bot to buy sneakers
>>
>>56688278
Nothing is impossible

>captcha is SUCCESS
>>
>>56687930

Are you worried about the algorithmic complexity of strstr? strstr is pretty damn efficient for what it does.

Why do you have to reverse the haystack/entries of what you are storing? It's not like you built a queue to hold all the entries, as you should be holding all of the entries in a stack and searching from top bottom will yield the last instance of the string.
>>
File: mcafee.png (19KB, 839x411px) Image search: [Google]
mcafee.png
19KB, 839x411px
Wow, I didn't even realize that Microsoft Plus 98! was keeping me safe.
>>
>>56688334
any idea on where to start
>>
File: 1410874830625.png (305KB, 1920x1080px) Image search: [Google]
1410874830625.png
305KB, 1920x1080px
>>56687968
roll nerds

(USER WAS WARNED FOR THIS POST)
>>
>>56688277

No, it was not. Inevitably, there has to be some way of dictating that a pointer is invalid, and ideally, one does not want to add extra bits to contain this information. The value of 0 is the easiest value for most CPUs to test for, so if every platform maps the address 0 as invalid, we have the benefits of an efficient and universal standard for tracking invalid elements.
>>
>>56688411
No you don't
>>
>>56688419

Name a system that uses either less memory or less CPU time than a null pointer.
>>
>>56688445
You do not need a null pointer whenever you need a pointer. In many cases, there's no potential nullness.
>>
>>56688467

Functional programming makes null obsolete.
>>
>>56688467
What about functions where NULL is a possible return value, either as error checking or something else.
What should an allocator function (like malloc) return when it can't get the memory for you?
What should a searching function (like bsearch) return if it can't find anything?

>>56688503
I think Ruby is talking about how the hardware actually works, not how some type system works.
>>
>>56688551
>What about functions where NULL is a possible return value, either as error checking or something else.
>What should an allocator function (like malloc) return when it can't get the memory for you?
>What should a searching function (like bsearch) return if it can't find anything?
Maybe Ptr
>>
>>56688573
How is that represented in hardware?
>>
>>56688551
>What about functions where NULL is a possible return value, either as error checking or something else.
>What should an allocator function (like malloc) return when it can't get the memory for you?
>What should a searching function (like bsearch) return if it can't find anything?
Optional Ptr

>>56688551
>I think Ruby is talking about how the hardware actually works, not how some type system works.
Ruby is retarded and doesn't know what he's talking about.

>>56688604
With bits.
>>
>>56688604
the same way
>>
>>56688619
>With bits.
What bit pattern specifically?
Maybe/Optional is just a type system wrapper over NULL.

From a hardware perspective, you still have NULL. You just decided to call it something else.
>>
>>56688659
You say "there is a type called pointer, and there is a type called nullablePointer"
>>
>>56688619
>Ruby is retarded and doesn't know what he's talking about.

OH MY GOD! RUBY ETERNALLY BLOWN THE FUCK OUT! WILL HE __EVER__ RECOVER FROM THIS?!
>>
>>56688675
Computer hardware doesn't have the concept of types, mate.
>>
>>56688696
Computer hardware doesn't have the concept of pointers, mate.
>>
>>56688706
Sure, but you can dereference shit.
It's useful to have a "it's invalid to deference this" value.
>>
>>56688659
The null pointer doesn't exist in hardware anymore than optional types do. They're both abstractions representing emptiness. The difference is that optional types are a better abstraction because they don't ruin the rest of the type system.
>>
tfw will never be able to program a gf to lost my virginity too
>>
>>56688756
>The null pointer doesn't exist in hardware anymore than optional types do.
It actually does.
Dereferencing 0x0 will cause a CPU interrupt.
>>
>>56688739
I thought you were defending null pointers
>>
>>56688841
Did I say something that implied otherwise?
>>
>>56688870
it's useful to have "it's valid to dereference this"
>>
>>56688892
>valid
Re-read what I wrote.
>>
>>56688393
get a good job to get money to buy sneakers
>>
>>56688793
Null doesn't exist in hardware.

>>56688870
>It's useful to have a "it's invalid to deference this" value.
>>
>>56688902
I wasn't quoting you
>>
>>56688902
>>56688918
I literally meant it's useful to have "it's valid to dereference this"
You can go from this to "it may or may not be valid" easily, but the reverse isn't trivial
>>
>>56684027
if memset is so fast, why don't people use

char *p;
memset ( p, 0, 1 );


instead of

char p = 0;


?
>>
>>56688943

More like memeset();
>>
>>56688943
Because that won't actually work.
>>
>>56688911
Hardware has a value which is never valid to dereference. That is what NULL is, so the concept of NULL does exist in hardware.

>>56688929
It would be completely infeasible for individual CPU instructions to manage something like that.
It would also require extra space for a 'valid' flag. So you would need pointers greater than the CPU's word size, or sacrifice 1 bit in your address space.
>>
>>56688996
it does after you malloc *p.
>>
Is there a better way to write this?

if Level1_Complete == False and Level2_Complete == False and Level3_Complete == False and Level4_Complete == False and Level5_Complete == False and Level6_Complete == False and Level7_Complete == False and Level8_Complete == True:

http://pasteall.org/80418/python

Here is what's funny about this. As admittedly ugly and obtuse that looks, that code actually works perfectly within the official Python shell. However, within Blender's Python shell it doesn't work at all. I've actually known this to be a quirk of Blender for a long time, that you can't use more than one or two AND statements on a single line. It won't give you a Syntax Error, it'll just not work.
>>
Are there any good object-oriented languages.
>>
>>56689034
OOP is inherently flawed, so "good object-oriented languages" is an oxymoron.
>>
>>56689014
No it wouldn't, what are you on about?
It's purely type level, the CPU does fuck all
>>
>>56689023
malloc is really slow.
>>
>>56689054
>It's purely type level
I've been arguing about the CPU level the entire time.
I even pointed that out right at the start.
>>
>>56688943

Stack vs heap allocation.
>>
>>56689058
but you will use it only once, at the beginning of the program.
>>
>>56689067
Pointers don't exist at the type level
>>
>>56689083
*CPU level

Fuck this fucking delay
>>
>>56689045

Programming is inherently flawed.
>>
>>56689032

have you tried adding all of the levels to a list and then running:

if [x == FALSE for x in list_Levels]:
>>
>>56689107
>>56689083
The concept of the "invalid address" does though, which I've already said.
>>
>>56689128
Yes, and that doesn't mean all your pointer types need it
>>
>>56689078
But then what advantage do you gain?
>>
>>56688190
FUCK YOU! FUCK YOU! FUCK YOU! FUCK YOU! FUCK YOU! FUCK YOU! FUCK YOU! FUCK YOU! FUCK YOU! FUCK YOU! FUCK YOU! FUCK YOU! FUCK YOU! FUCK YOU!
>>
>>56689032

You can consider consolidating all the Level 1-7 boolean variables into one by evaluating two at a time.

So compare 1 and 2, 3 and 4, 5 and 6, 7, then compare 12 to 34 and 45 to 67, and then finally comparing 1234 to 4567. Of course, >>56689122 probably is easier.
>>
>>56689175
He does this every thread you idiot
>>
>>56689045
I've been starting to think that. I really do want to give object-oriented a chance though.
>>
How do I find someone to program games, or do projects with?
It's very lonely by myself.
>>
>>56689158
maybe it will be faster inside loops with lots of assignments
>>
>>56689175

>not filtering the image dimensions or MD5
>>
File: 1474319165792.png (210KB, 1280x679px) Image search: [Google]
1474319165792.png
210KB, 1280x679px
>>56689188
He's stupid, leave him be
>>
>>56689219
If you're the guy that does it, then I'm not on your side
It's fucking dumb, and it will never be funny. You are literally fake twitch support tier (no wonder you find it funny)
>>
File: the cloud.jpg (212KB, 1195x672px) Image search: [Google]
the cloud.jpg
212KB, 1195x672px
So is there a reason timing attacks still exist?
Why can't you just broadcast random data all the time to hide actual connections? Or maybe send out random spurts that look like encrypted data every once in a while?
It's a pretty simple idea so someone else must have thought of it, so why isn't it used?
Is it just bandwidth/CPU load, or is there some sort of fundamental crypto problem?
>>
File: cccc.png (191KB, 660x423px) Image search: [Google]
cccc.png
191KB, 660x423px
>tfw learning JavaScript

You have to remove an element like this.

elem.parentNode.removeChild(elem)
>>
>>56689239
I know that wasn't directed towards me since I am not him but that still hurt.
>>
>>56689128
Now I'm confused. Pointers are just an integer value that gives the index of a slot in your allocated pages of virtual memory in most OSes. How did the CPU level stuff come in?
>>
>>56689251
Wew. Wrong image.
>>
>>56689251
You are learning how to interact with the DOM. You are not learning javascript.
>>
File: Jellyfish.jpg (758KB, 1024x768px) Image search: [Google]
Jellyfish.jpg
758KB, 1024x768px
How do I find someone to program games, or do projects with?
It's very lonely by myself.
>>
>>56689032
if not any([Level1_Complete, Level2_Complete, Level3_Complete, Level4_Complete, Level5_Complete, Level6_Complete, Level7_Complete]) and Level8_Complete
>>
>>56689304
Are you autistic?
>>
>>56689294
Is JavaScript not being used to interact with the DOM?
>>
>>56689322
I am higher up on the scale than most.
>>
>>56689323
It is, but you're not learning it by learning the DOM

Similar to how watching a video to teach you chess on a computer is learning how to play chess, not learning to use a computer.
>>
>>56689316
or
level_complete = [Level1_Complete, Level2_Complete, Level3_Complete, Level4_Complete, Level5_Complete, Level6_Complete, Level7_Complete, Level8_Complete]
if not any(level_complete[:-1] and level_complete[-1]:
>>
>>56689304
Learn to enjoy loneliness and reject human companionship
>>
>>56688943
well I ran it here and memset took twice as much time as the =.
>>
>>56689402
>Learn to enjoy loneliness
i wish i could

>reject human companionship
i am the one who has been systematically rejected
>>
>>56689430
>i wish i could
You can with practice

>i am the one who has been systematically rejected
Convince yourself that it was in fact you who has rejected everyone else of your own volition
>>
>>56689071
Doesn't work vs bss allocation.
>>
>>56689430
Why would you want more friends than dpt's /g/entlemans?
Also, in which languages you program.
>>
>>56689122
Thanks for giving me the idea to use lists here. I don't understand your method, but using lists is the way to go:

AllLevelsCompleted = [Level1_Complete, Level2_Complete, Level3_Complete, Level4_Complete, Level5_Complete, Level6_Complete, Level7_Complete, Level8_Complete]
if AllLevelsCompleted == [False, False, False, False, False, False, False, True]:


Oh, also, the "and and and and"-way actually does work. I just forgot during my testing to include the script that defines the "Level_Complete" booleans and loads them into the global dictionary. But I'm glad I did it this way as it's much cleaner
>>
I'm sitting here dumbfounded. I going to learn how to program but holy shit am I fucking clueless, and I haven't even gotten to opening a book yet. I'm still just following this guide (down below) and am trying to get a compiler for C but since I don't even have the slightest inkling as to what a compiler is or what it does I'm fucking stumped.

I tried visual studio community and it game me a bunch of errors just by booting it up and then I had no idea what I'm looking at so I just kind of looked for the word compiler in the above toolbars and got nothing. holy shit man.

http://pastebin.com/UjUtepzP
>>
>>56689495
>a compiler is or what it does
It's the program that takes human-readable source code and coverts to something that a computer can run.
>>
>>56689464
>Doesn't work
but it does
>>
>>56689478
Java's the one I'm currently enjoying.
It would just be nice to talk to someone who wasn't myself.
>>
>>56689576
No, it doesn't. You didn't set p to a valid memory location. Your shit would segfault.
>>
>>56689597
char p;
memset(&p, 0, 1);


happy now?
>>
>>56689548
alright, so how do I use a compiler program? If I were to type some code in gedit:
#include <stdio.h>

main()
}
printf("hello, world\n");
{

How do I move this to a supposed compiler program like visual studio?
>>
>>56689386
Well, I disagree.

I think you can learn the fundamentals of JavaScript by playing with the DOM.
>>
>>56689495
To be honest dude, you should install Linux in a VM or on a separate partition.

Download GCC, which is a compiler and linker, and read through the beginning of C Primer Plus.

Basically, a compiler takes what you've written and turns it into executable machine code for the computer to use. A linker takes some operating system specifics and libraries and changes the code to work. GCC is as simple as writing code in any text editor and typing "gcc myprogram.c" in a terminal, and it'll compile or give you errors. It's much more simple than figuring out Visual Studio, projects, and all the excess stuff that you won't need until you're building big, long time or multi person projects.
>>
>>56689683
Browser APIs != JavaScript.

Sorry, this isn't a matter of opinion.

At least, for fucks' sake, know which languages and tools you are interacting with as you mash your fat stubby fists into the keyboard.
>>
>>56689495
1) Download the Haskell platform from this site here: https://www.haskell.org/platform/
2) Follow install instructions like for any other program you'd install.
3) Look in your start menu for the "haskell platform" folder and start GHCi
4) A window will pop up where you will be able to type things like 2+2 and get an answer interactively.
5) To get further, follow this book: http://learnyouahaskell.com/chapters
>>
>>56689590
You can talk here tho, anyways put your github here and I'll contact you to chat if you wanna, but I only use C# nowadays.
>>
>>56689689
Yeah even the guide says I should install linux. I found a link to getting GCC ftp://mirrors-usa.go-parts.com/gcc/ but man... I feel like a real idiot right now, but I'm not even sure as to what I'm looking at.

>>56689728
Thing is, this guide I'm following specifically states that haskell is a functional language which isn't applicable to video games (which is why I want to learn) and it also tells me to start with C as its not a managed language so fuckups, although catastrophic, aren't problems based on bloated features of the language itself.

The dude who wrote the guide seemed pretty adamant on starting with C.
>>
>>56689709
You're moving the goal posts.

Where did I say Browser APIs equals JavaScript? I didn't. I said I think you can learn the fundamentals of JavaScript by playing with the DOM.

You store elements in variables, you loop through HTML collections, you create shortcuts using functions to manipulate the DOM easier, you use conditional statements, etc.
>>
>>56689784
Generally GCC actually comes with Linux distributions. Just install it, open up a terminal and type "gcc" and you should have it. If not, you use the package manager to install GCC. So like apt-get install gcc. The entire Linux kernel is written in C, which is why a lot of distros never uninstall it.
>>
>>56689794
JavaScript is learning frameworks & meta languages, dumbass, not any of that crap you said. Get you a templating view and rendering engine. Now you are JavaScript. Dick
>>
>>56688467

Then don't check for null if you know for certain the pointer will never be null. It's not as if you needed that one extra memory address in your virtual address space (or realistically, that one extra page of memory).

>>56688573
>>56688619

In reasonable optimizing compilers, maybe and option types are just an abstraction over a null pointer. If the null pointer were not invented, we might represent them differently in memory in a way that could be less space efficient or less cpu efficient.

>>56689638

It's still faster to just do p = 0, because then, p can simply be in a register, and the entire assignment operation would just take one instruction.
>>
>>56689640

Ugh, I hate to add more complex things to your learning so let's start from the beginning with this.

Visual Studio is an integrated development environment (IDE). This means that it has a compiler but also a ton of other things inside it like an editor for code and other stuff which is too complex to list now.

For a compiler to compile your program, you need to send it the appropriate commands for it to compile a file for you.

So if my code was "code.c", I would have to pass it to gcc, a compiler:

gcc code.c -o code


Which turns my code in code.c to an executable program in code.

For an IDE, you have to generally do several steps to get it to compile something.

The problem is that Windows is a horribly non-standards compliant platform for compiling code. There's a lot of stuff involving compilers on Windows but with C and C++, you would have to find a GCC toolchain called MinGW-w64.

I would not try the link you found for GCC. I would download a POSIX environment MSYS2 and then set it up so then you can compile like you would on Linux.

http://codrspace.com/fauxtronic/installing-mingw-2015/
>>
>>56689866
It's about type safety and convenience
>>
scheme is the most powerful language of all time
>>
>>56689813
Alright then, I'm gonna go with ubuntu and do a dual boot. At this point it seems like linux is pretty much essential.

Fuck I feel like I'm swamped and I don't know a damn thing. Its too late to start tonight so I'm gonna start tomorrow but basically what I need to do to be able to even begin to start programming and doing the problems in this book I have to.

-Learn and install ubuntu to dual boot alongside windows
-find out if I have GCC by opening up a terminal and just typing it in.
-get that program gedit to write my code in

anything missing?
>>
>>56689784
And imho C is a terrible language to recommend to newbies, unless you want to scare them away. You will learn C eventually, but it is not really a language that lets you experiment quickly or one that drills good programming habits into you.

I tend to suggest Haskell to anyone who wants to just get his feet wet for a few days because it gives you good habits right off the bat and because installing a working setup is very easy.
>>
>>56689942
There's nothing wrong with starting with C.
Learning all the "gotchas" and idiomatic C patterns mans you up.
>>
>>56689942
>Haskell as a first
I unironically recommend this
>>
>>56689899

Right, and you can have your type safety and convenience... as long as it's a null pointer under the hood.
>>
>>56689942
>C is a terrible language to recommend to newbies, unless you want to scare them away
I started with C, and I thought it was great.
>it is not really a language that lets you experiment
Beginners don't need to "experiment quickly". They're there to learn the fundamentals of programming.
>or one that drills good programming habits into you
I would argue that it does. It forces the programmer to be aware of what they're doing, otherwise their program is probably going to fuck up.
>>
>>56689935
No, that sounds fine to me. If you want, you can stick with Windows and go with the other anon's suggestion of using MinGW. But I feel like that would be a bit complicated since you're going to need to use libraries and other stuff at some point or another and it's going to hurt your head.

Your other option is to learn a different language. C# could work since it's really good for video games and easy to get yourself setup with on any platform, especially Windows. I'd recommend you stick with C though, good to learn at least a bit about safeness, type systems and all that jazz before you move to new paradigms. Sorry if I'm going over your head, the important thing really is that you just don't give up.
>>
File: poo-in-loo.jpg (327KB, 2000x1000px) Image search: [Google]
poo-in-loo.jpg
327KB, 2000x1000px
>>56689932
Nope, it's python
>>
>>56689992
No, that's the point, it's not a null pointer
You have a type of pointers and a maybe or either type constructor, and that's what malloc or similar returns
>>
>>56689992
Which is what e.g. Rust does. It has a NonZero<T> type which expresses that its underlying value can never be 0, and this works with Option. Option<NonZero<T>> is basically just a T but obviously can be used like an Option.
>>
>>56689992
>>56690012
And anything that might return a null pointer returns the alternate part of Either or the Nothing part of Maybe, so you still have 90% of operations saying they only take non-nullpointers and only return non-nullpointers
>>
>>56689992
>>56690031
Oh, and it's worth noting that a reference &T (&mut T) is basically a NonZero<*const T> (NonZero<*mut T>) under the hood.
>>
>>56689995
>> I started with C, and I thought it was great.
Survivor bias.
>>
>>56689996
I don't plan on giving up, especially since I just bought gamemaker (I know its GML but the fact that I paid money for it and its sitting on my desktop, I'm inclined to use it which I can't do if I quit).
>>
>>56689995
Haskell lets you experiment with very neat ideas and also prevents you from doing stupid shit. The newbie also doesn't need to get a segfault or memory corruption to see that he's done something terribly wrong.
>>
>>56690012

>it's not a null pointer
If it's a zero in memory, it's a null pointer. Doesn't matter what the high level language concept is.
>>
>>56690065
Surviving = learning

>>56690087
>especially since I just bought gamemaker
lol you're going to move on from that quicker than you realise
>>
>>56690103
The point is the language itself stops you from assigning a null pointer to a valid pointer type
>>
>>56690103
>inb4 some fuckass 80s environment not using 0 as NULL
>>
>>56689992
Everything is null pointers?
>>
>>56690129

NULL is more or less universally agreed on to be 0 forever on all platforms from the past 20 years, present and future platforms. No one unless they have a really REALLY good reason will implement NULL not as 0 and they would probably warn everyone using their platform. I would not mind if C mandates in its next standard that NULL must be 0.

At least that part of C is not screwed up as something like the fact CHAR_BIT only has to be at least 8 bits so you have some esoteric architecture and DSP using 16 bit and 32 bit chars. I don't even think the justification for that kind of decision is any good.
>>
curiosity: what books do you like for algorithms?
>>
>>56690200
C does enforce that 0 is the NULL pointer constant.
It's just that the underlying bit-pattern doesn't have to be zero, which is slightly annoying because zero-initialising a pointer (static, calloc, etc.) doesn't grantee that it's the NULL pointer.

I agree with you though. I really wish the C standards committee would remove a lot of the legacy assumptions so that we can write programs with far less implementation defined behaviour.
That seems unlikely to happen though.
>>
>>56690233
>which is slightly annoying because zero-initialising a pointer (static, calloc, etc.) doesn't grantee that it's the NULL pointer.
First, why would you malloc(0)? If you want null, just type NULL. even saves you a few characters. Second, it's not defined by the standard. It has nothing to do with anything you're saying. They were just lazy.

>I really wish the C standards committee would remove a lot of the legacy assumptions so that we can write programs with far less implementation defined behaviour.
Fork a major implementation of C, remove a bunch of crap in it, add some standardization, and name it C without Crap (or CC)
>>
>>56690390
>Second, it's not defined by the standard
http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1570.pdf
>6.3.2.3 Pointers
>An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.
>>
File: Untitled.png (226KB, 1606x979px) Image search: [Google]
Untitled.png
226KB, 1606x979px
Rendering .OBJ files.
>>
>>56690484
As BMPs?
>>
Does anybody know why this java code would instantly throw an indexoutofbounds exception the second it attempted to iterate the first time?
I shit you not, this was working yesterday when I closed my development environment. There's no threading or anything else, either.
StringBuilder pathBuilder = new StringBuilder(".\\crawlResults\\");       
for (String c: linkChain) {
if (c != null) {
pathBuilder.append(format(c)).append("\\");
}
}
>>
>>56690526
Going through this: https://github.com/ssloy/tinyrenderer/wiki
>>
>>56690233

C allows for a wiggle room for edge case platforms with weird hardware, like 36-bit CPUs. That said, I've seen plenty of platforms break away from the C standard regardless. For instance, there's a couple of C compilers for the Gameboy Color that let int be 8 bits and long be 16 bits. There's no reason it couldn't let int be 16 bits as per the standard, and just encourage the use of char everywhere, but since a number of C programmers just use int for everything, they break away from the standard for convenience.
>>
java help; I'm sure it's simple enough but I can't think this one through;

Generate a 2d boolean array with random true/false cells; done
Traverse the array and store the coordinates of the true elements in a stack; done
Print an array showing clusters/blobs of true elements, with each different blob showing a different letter; this is what I need help with

Here's an example of the current output;


[X] [ ] [ ] [X] [X] [ ]
[X] [ ] [X] [X] [X] [ ]
[X] [X] [X] [X] [X] [X]
[ ] [ ] [ ] [X] [ ] [ ]
[X] [ ] [X] [ ] [ ] [X]
[X] [ ] [ ] [ ] [ ] [ ]
(0, 0)

(0, 3)

(0, 4)

(1, 0)

(1, 2)

(1, 3)

(1, 4)

(2, 0)

(2, 1)

(2, 2)

(2, 3)

(2, 4)

(2, 5)

(3, 3)

(4, 0)

(4, 2)

(4, 5)

(5, 0)


Process finished with exit code 0


The coordinates are the stack (i've got it printing backwards right now, so (5, 0) is at the top). What would be the best way to traverse that stack and determine clusters of coordinates? I cannot use recursion.
>>
I know a bit of C.
should I go deeper in it or learning c++ would be better?
>>
do you think bjarne is ashamed
>>
>>56691155
yes. he is almost bald.
>>
>>56691192
i meant of the cancer he's spread on the programming world
>>
>>56691198
>i meant of the cancer
was it the chemo that made him go bald?
>>
File: file.png (354KB, 1152x648px) Image search: [Google]
file.png
354KB, 1152x648px
>>56691155

No, seeing as how far he actively evangelizes his language with his appearances during CppCon.

https://www.youtube.com/watch?v=1OEu9C51K2A

I don't mind that but shitting on C when it was the thing that got C++ to the place where it was is pretty unacceptable. He is unwilling to admit that he has created a monstrosity of a language and the fact that in 2015 people had to subset into "guidelines" for it to be usable and he is unwilling to say that it was what C++ should have been all along instead of his multiheaded chimera, which is why it's just "good".
>>
>>56688190
what the fuck
>>
>>56691254
>C++ actually already has not_null
The fuck bjarne?
>>
>>56691254
If he created c++ to run away from c, or because c isn't as good as he wanted it to be, why is it bad to say that c isn't good?
>>
>>56691307

Because it's telling when he or anyone else is unwilling to strip C compatibility from the language and the proposal is to have C11 standard library compliance with C++17 Yet, trigraphs are disappearing in C++17 also. C compatibility is a nightmare in C++ and honestly, no one knows what to do with it.

There isn't a point with keeping standard library compliance with C when you don't have or/and are unwilling to put in syntax compatibility with C. Designated initializers, restrict qualifier, anonymous unions, _Generic, etc. are all different in C than in C++.

C++ has different ways to do all of those so it doesn't include these syntactical changes even though some would be great to have in C++ and would improve C compatibility. This kind of inaction is not only harming C++ itself on that front but it's also actively harming C because people won't use the features of C C++ hasn't picked up and people write in mostly some pseudo C99 style that is compatible with both languages unconsciously.

It also harms the standardization of C. C++17 is going to get rid of the register keyword, and look at one of the C2X proposals here.

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2067.pdf

It's a great proposal that will finally allow C to have true constants and use them in a way that reflects the intent of the register keyword's usage in a way that programmers would expect. Yet it might get shot down with compatibility with C++ being one of those reasons.

I would seriously love for C++2X just to announce a clean break from C and implement its own standard library and semantics instead of choosing some abomination of past standard C and piggybacking off of it. Bjarne would at least win some respect from me for doing this.
>>
>>56691461
C++ is already an abomination
>>
File: C++.png (72KB, 1016x98px) Image search: [Google]
C++.png
72KB, 1016x98px
>>56691461
C++ should just change their name and pretend they never had anything to do with C.
Their syntax isn't even similar anymore.
>>
>>56691482

Which is partially due to compatibility with C. I honestly have no problems with any of the proposals he has with future C++ standards but if he is going to put down C-style programming in C++ and yet at the same time keep C compatibility in C++, he might as well be a hypocrite with what he is preaching for modern C++. It's self-ignorance at best and self-deception at worst.
>>
I want anonymous functions in C2X!
>>
>>56691577

See http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2030.pdf

I am certainly for this proposal too.
>>
started working on my own SSG for my blog if I ever decide to actually make it.
also finally actually taking the time to learn Coq. it's pretty interesting mang
>>
Please help me bois.

 import java.util.Scanner;

public class IfElseStatements {

public static void main(String[] args){
Scanner input = new Scanner(System.in);

// Declare variables.
int age = 0;
int weight = 0;

/* Unused idk if worth it
int[][] ageWeight = {{10,20},{80,100}};
*/

String[] rollerC = {"Black", "Green", "Yellow", "Silver", "Red", "Purple", "Pink"};

// Obtain user input.
System.out.println("Please enter an age.");
age = input.nextInt();
System.out.println("Please enter your weight.");
weight = input.nextInt();


// Selection structure
if (age <= 10 && weight < 80){
System.out.println("You must ride the " + rollerC[0] + " rollercoaster.");
} else if(age < 10 && weight >= 80 && weight <= 100){
System.out.println("You must ride the " + rollerC[1] + "rollercoaster.");
}

}
}


>If a person is younger than or equal to 10 years old and weights between 80 and 200 pounds (including weighing exactly 80 or 200 pounds), print the following:
This person needs to ride the green roller coaster.

Can't get this shit to work my man,
>>
>>56690103
What standard says that a null pointer has to be represented as a zero in memory?
>>
Apologies if this is babies first programming question, but do Linux users (preferably those who program for a living) use an IDE or just various tools separately (Make, GDB, valgrind, etc)?
>>
>>56691715
I personally use Vim + gcc + make, etc.
I have never found an IDE to be particularly useful.
>>
>>56691551
most of that (in the image) is more semantics than syntax. the syntax part is template syntax, which has always been that way. not that you're wrong in general, that image just isn't particularly exemplary

also
>third line is unnecessary
>typedef instead of alias
>ReturnTypeReturnType
>>
>>56691727
You use that stack at work or personal use?
>>
>>56691691

Some, like C, standardized it upon its inception. Most other languages piggybacked upon this semantic and it is kind of enforced in hardware too.

You certainly can have some language defining 0x9 as NULL or some other constant but I doubt it would gain much traction.

>>56691684

>If a person is younger than or equal to 10 years old and weights between 80 and 200 pounds (including weighing exactly 80 or 200 pounds)
>else if(age < 10 && weight >= 80 && weight <= 100)
>weights between 80 and 200 pounds
>weight >= 80 && weight <= 100

Do I need to say more?

>>56691715

I use kate/gedit and then command line for everything else. I feel like a pleb for not being able to learn vim or emacs but I like my current workflow.
>>
>>56691739
I'm a CS student. I use it for both university work and personal use.
>>
File: gooby.png (191KB, 812x716px) Image search: [Google]
gooby.png
191KB, 812x716px
>>56691742
>Do I need to say more?
I PUT THIS GUN TO MY HEAAAAAAAAAD AND I SMILE

SMIIIIIIIIIILE


also, any suggestions for better using arrays in this case?
>>
>>56691715
In the developer team that I work on, everyone either uses emacs, vim, or sublime text, along with normal command line tools for the language being used.
>>
visual studio's IntelliSense is quite great
>>
>>56691715
I don't program for a living, but I use VS code and a Makefile.
>>
>>56691801
Indeed senpai, it's a feature that I will love for every editor. I can imagine that shit for every language I use, shit would be so cash.
>>
File: Capture.png (38KB, 791x857px) Image search: [Google]
Capture.png
38KB, 791x857px
Noob question.
Using Android/Java. I have a custom listview with an adapter, and it is supposed to load an image from internet. The problem is, the adapter loads before the image has a chance to download, but when I call a function to load more images (using the same image again), the listview gets refreshed and the images appear as needed.
So how do I make it wait until the image is actually loaded before it executes setImageBitmap? It's driving me insane. Stackoverflow has a lot of solutions, but all of them revolve around same thing - basically make it async, but it just doesn't work. Running a new thread inside the adapter hangs my app altogether.
My code is in pic related.
>>
>>56691715
Use emacs
>>
Where do I start learning about intermediate/advanced concepts and lower level programming? I've been doing the basics for years and am quite well versed on general OOP, but I'd like to go much deeper with C and much higher with OOP, especially C++ but it doesn't really matter what language for the latter.
>>
>>56691788

What do you mean by that? Are you talking about if the way you are using arrays is appropriate?

I would suggest an enum in this case for roller coaster colors. You can read more about them here at https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html. Having your weights as unchanged ints in your if statements is okay but if someone else reads your code, they won't know what the numbers 80 or 200 mean. Most programming guides will stipulate you put them in separate variables and name them explicitly in your code but since this is personal code, you don't have to but it is good practice.

There are many ways you can hold data in programming and these data structures in programming all have their individual tradeoffs with if you want maximum space efficiency or time efficiency or access efficiency. Knowing when to use them and how to build and implement them properly is what people who major in computer science/computer engineering in university do mostly.

Since you are only learning for fun, don't sweat about any of that for now and move on with learning other stuff that are more important like syntax in Java. You will know and learn about other data structures when you have more knowledge and have a need to use them.
>>
>>56691848

Are you checking the status of the AsyncTask during its execution? I would suggest implementing onProgressUpdate() to see what is happening and to check up on why your application is hanging.
>>
>>56691931
What have I done, my man

 package ifElsePkg;

import java.util.Scanner;

public class IfElseStatements {

public static void main(String[] args){
Scanner input = new Scanner(System.in);

// Declare variables.
int age = 0;
int weight = 0;

/* Unused idk if worth it
int[][] ageWeight = {{10,20},{80,100}};
*/

String[] rc = {"black rollercoaster.", "green rollercoaster", "yellow rollercoaster.",
"silver rollercoaster.", "red rollercoaster.", "purple rollercoaster.", "pink rollercoaster."};

// Obtain user input.
System.out.println("Please enter an age.");
age = input.nextInt();
System.out.println("Please enter your weight.");
weight = input.nextInt();


// Selection structure
if (age <= 10)
{
if(weight < 80)
{
System.out.println("You must ride the " + rc[0]);

}
else if(weight >= 80 && weight <=200 )
{
System.out.println("You must ride the " + rc[1]);
}
else if(weight > 200)
{
System.out.println("You must ride the " + rc[3]);
}
}
else if (age > 10 && age <= 20)
{
if(weight < 80 )
{
System.out.println("You must ride the " + rc[4]);
}
else if(weight >= 80 && weight <=200 )
{
System.out.println("You must ride the " + rc[5]);
}
else if(weight > 200)
{
System.out.println("You must ride the " + rc[6]);
}

}
else
{
System.out.println("You must ride the " + rc[7]);
}

}
}


I can't really use enum right now it has to be IfElse statements. Was jw if there was a better use of arrays rather than have them be place holder for the RC colors.
>>
>>56691922
>lower level programming
learn assembly
>>
>>56692042
I want to learn about complicated memory management and extreme pointers and stuff, I feel like assembly is probably so low level that its not even abstracted away to that level, is that a misconception?
>>
Got my new Haskell book coming in tomorrow, but I'm more excited to have a new book
>>
>>56692027
btw I did catch that error where I skipped an array value.

If you are reading this, how would I go about implementing sophisticated error checking, like checking for negative numbers, or input that's not a number
??
>>
>>56692051
If you wanna be an expert at X language, why not instead program extensive projects in those languages?
>I want to learn about complicated memory management and extreme pointers and stuff
Deep C Secrets might be interesting for you.
>>
>>56692061
I bought KR C for $50 and didnt read it.
>>
>tfw you fell for the programming meme
>>
>>56692027
>if (age <= 10)
>else if (age > 10 && ..
If you've already taken out one of the options you dont need to keep checking it after that. Same goes for the weight checks:
>if (weight < 80)
>else if (weight <= 200)
>else
>>
>>56692019
Thanks, I'll read up on that.
Would it make sense to just create a new dialog with result and let it download all the images, and then return a list of bitmaps?
>>
>>56692222

In general, do whatever works for you as long as you can figure out what's going on. You aren't going to ship this to the user, I would think.
>>
/dpt/ should hang out on irc somewhere
>>
>>56688190
>hereyougo.gif (88 KB, 10000x10000)
gee thanks now my chrome cache directory probably grew by a few GB
>>
>>56692925
rell again. Like hell i'm gonna do a picross solver
>>
>>56692934
what the shit kind of application is Benford's law?? That's an entire field of applications. It's like saying make an application for statistics. Wtf

rell agin
>>
>>56692972
do the picross solver faggot
>>
>>56690003
Python is basically a crippled Lisp with better syntax and libraries.
>>
>>56688410
rollan
>>
>>56688410
Why do you even post childish stuff here like this?
>>
File: 1306326725906.png (62KB, 220x239px) Image search: [Google]
1306326725906.png
62KB, 220x239px
>>56693272
>>
>>56693283
And you just did it again
>>
File: smug hair.png (49KB, 187x207px) Image search: [Google]
smug hair.png
49KB, 187x207px
>>56693288
>>
File: 1300720778048.gif (233KB, 180x135px) Image search: [Google]
1300720778048.gif
233KB, 180x135px
>>56693288
Wow, do you hate fun, anon?
>>
Does c++ have something similar to Haskell's case statements?
>>
>>56693295
I don't you just post stuff that 10-year olds watch, on mature board
what are you trying to achieve?
>>
>>56693323
>mature board
lolwut
>>
>>56687778
is C still useful today?
>>
>>56693337
That's what I'm talking about
You can't even understand what I wrote, and I bet when it comes to technology you're just full of misinforming stuff
>>
>>56693350
*tips*
>>
>>56693358
What?
>>
Porting 32bit software to 64bit.
>>
>>56693364
That's what I'm talking about
You can't even understand what I wrote, and I bet when it comes to technology you're just full of misinforming stuff
>>
>>56693358
confirmed 13 years old
>>
>>56693375
And you're just copying my text now
Could that be, because you can't answer question I gave you? Because you're just making no sense
>>
>>56693388
children should be ignored
the more attention you give it, the more excited it becomes
>>
>>56693388
what are YOU trying to achieve with your uninteresting spergposts
>>
>>56693402
I guess you're right
>>56693404
Question is not an answer
I will answer it thought.
What I'm trying to achieve is to know why people like you go on technology board, post childish roll images, and later when you ask them why, they just write nonsense
Anyway, it's not worth arguing with you anymore, don't want to make this thread our personal conversation, just don't do stuff like this again. Thanks
>>
what do you think of my hot architecture
##map.h##
void init_map(char *file);
void destroy_map(void);
void render_map(struct wnw *window, struct pnt *from, struct pnt *to);
char cell_to_char(struct cell *cel);
struct cell *get_cell(struct pnt *point);

#window.h
void clear_window(struct wnw *window, char clear_char);
void draw_to_main(struct wnw *window, struct pnt *top_left);
void print_main(void);


my rouge-liek will be the bestest
>>
>>56693449
Though I think actually I will remove destroy_map and add destroy_window.
>>
>>56693440
literally fuck off to reddit you cancerous smug sperglord
>>
File: poo in it.jpg (46KB, 630x405px) Image search: [Google]
poo in it.jpg
46KB, 630x405px
>>56693449
>void in arguments
>commenting with #
>>
>>56693591
>He doesn't know that in C there's a difference between void arguments and non specified
>I was making something in python earlier
No YOU poo in loo pajeet.
>>
>>56693610
>>I was making something in python earlier
shart in mart todd
>>
>>56693539
Wow, calm down, there is no need to use those rude words
You don't even know me
>>
>>56693731
>reddit being a passive aggressive little shit

wew
>>
>>56693755
I don't understand what's wrong with reading stuff in reddit
If you like some topic, you can find reddit page for that topic and see a lot of stuff about it. It's cool, you should check it out
>>
>>56693774
you truly are the butt of the joke
>>
>>56693779
What are you trying to say?
>>
>>56693787
im trying to say you should go back to plebbit and stay there.
>>
>>56693795
Finally you fell for it faggot
Go back there yourself
>>
>>56693810
Was getting caught part of your plan?
>>
Guys, have you already reached your cognitive limit?

When I was 12, I tried to learn C++ and failed. But even back than I understood that I'll be able to learn it later.
Today I'm much older and I know that I won't get any smarter by simply growing up. I'm currently trying to learn stuff that is definitely possible to understand by an intelligent person, but now I'm starting to doubt whether I'm intelligent enough. I don't even know if I can comprehend it or it is completely out of my league.

Does anyone here know how to distinguish cognitive limit from being stuck for a while?
>>
>>56693849
yes
>>
>>56693849
I'm a big guy
>>
>>56693911
I'm so sorry, you were supposed to have your midi-chlorian levels measured at or before the age of 4, to potentially be taken away for programming training. If you missed the opportunity, there isn't much that can be done.
Sorry anon.
>>
>>56693911
Are you mentally disabled/ill (including being a female)? If not, it's likely it's just being stuck.
>>
>>56689122
jesus christ
not any(list_levels)
>>
>>56690103
>>it's not a null pointer
>If it's a zero in memory, it's a null pointer. Doesn't matter what the high level language concept is.
You are truly retarded m9
>>
>>56693946
The furthest future even the most powerful jedi can't see. His own limit every person has.
>>56693947
I hope so.
>>
>>56694025
Spoken like someone who's never programmed in a real language. I bet you agree with the statement
>“Programs must be written for people to read, and only incidentally for machines to execute.”

too.
>>
>>56693911
Take a break from c++ every now and then to try learning some other languages. Maybe try a purely functional programming language since most of them should be very different from c++.
>>
File: ayy.webm (170KB, 547x268px) Image search: [Google]
ayy.webm
170KB, 547x268px
A windowing system to rival X!
>>
>>56694089
Lol, I didn't mean I don't know C++. It was hard to learn back then, it is a trivial language to use now.
I was asking about the more abstract issue of "I don't know whether this problem is out of my league or I just need more time".
>>
>>56694077
You're missing the point. The pointer is non-nullable.

>If it's a zero in memory, it's a null pointer. Doesn't matter what the high level language concept is.
It isn't a zero in memory.
>>
>>56693344

Someone?
it may be a retarded question, but I know nothing about codes
>>
>>56694130
yes
>>
>>56687930
Sounds like you need someone to implement rstrstr.
>>
>>56694130
no
>>
>>56694130
maybe
>>
>>56694130
If you can't tell why you need to use C, you don't need C. But it is a good thing to know C and other low-level stuff.
>>
>>56694130
i don't know
>>
>tfw my room is starting to smell of cum
>>
>>56694183

I am confused, as I know that C is a pretty basic and wide used language. (by basic I mean low-level). so it owuld be useful.
BUT
If it's aimed to low-level performance, would it be useful at these days, where other languages may do the same/more?

that's why I was asking if it stills being useful or not.
>>
>>56694212
yes
>>
>>56694212
C++ is far more relevant, it has modern features and is only marginally slower than C
>>
can you repeat the question
>>
>>56694145
>>56694165
>>56694174
>>56694192
>>56694218

Ebin trolling kid :D:D
I rate you 11/10
Go tell your classmates, hurry!
>>
>>56694237
YOU'RE NOT THE BOSS OF ME NOW
>>
>>56694247
>saying c is relevant currently is "ebin trolling"

do you tell mommy about how you pwn noobs online after she gets home from work
>>
>>56694212
Sometimes you just don't have other options. For example, if you are writing code for microcontrollers you have to know C. But I'm pretty sure this isn't a case for you.
C/C++ sometimes used for high-performance code, but for most tasks performance is either not an issue or it can be achieved by other means than using C.
Simply saying: C is useful when you have no better options. It's a waste of time otherwise.

Even simpler: if you are asking this questing, forget about C.
>>
>>56694225
>C++ is far more relevant, it has modern features and is only marginally slower than C

C++ is for pajeet and SJW faggots that can't into coding and should be kill.

Also check those compile times faggot.
>>
>>56694271
Don't listen to this retard.
C is the only language you need to know, all else is pajeet tier or needless bloat.
>>
>>56694212
When people argue that C isn't useful anymore, just remember -- Intel's hit their performance ceiling on CPUs unless they can develop some revolutionary new tech.
>>
>>56694273
k
>>
>>56694300
MAKE MORE CORES
>>
>>56688190
lmao crashed the tab in Chromium
>>
learning c++, unless you don't explicitly care about the precision of the value, why would you ever do
 type variable = value 


instead of
 type variable {value} 


?
>>
>>56694403
What the fuck is that second syntax? I write C++ professionally and I've never seen it.
>>
File: WRZ0E3Z.png (11KB, 438x180px) Image search: [Google]
WRZ0E3Z.png
11KB, 438x180px
>>56694412
from a tour of c++, written by the balding old fuck himself
>>
>>56694412
>>56694412
>>56694412
>>56694412
>>56694412
REMINDER THIS IS C++
REMINDER C++ IS LITERAL USELESS BLOAT
>>
p sure it's 310 now
>>
What's the best book to read to learn java?
>>
>>56696394
do yourself a favour and learn c# instead
>>
>>56696504
no
>>
>>56696389

tl;dr
It's so you can do translations by matrix multiplication.
>>
>>56687961
>>56688213
Found the error. Was using (<= a b) to compare two integers, but one of them was nil.

In common lisp this would start up the debugger, which would find the type error (can't compare ints to nil) and it would point me to the correct line of code. In clojure, I get a NullPointerException. ^^
>>
File: javascript trash.jpg (103KB, 1024x576px) Image search: [Google]
javascript trash.jpg
103KB, 1024x576px
>"0" is equal to false but acts like true

>javascript
not even once
>>
>>56696628

The concepts of "truthy" and "falsey" were a mistake.
>>
File: sweat.jpg (23KB, 300x300px) Image search: [Google]
sweat.jpg
23KB, 300x300px
>tfw this summer i'm going to be interning as a researcher assistant for my professor's work on a deep learning machine to recognize lung cancer
>tfw senior year i'm going to be continuing work on it as my senior honors project
>tfw soon i'll be free from the basilisk
>>
Why am I getting an ArrayIndexOutOfBoundsException here?



if ((y - 1) >= 0){//if the left exists
if (bArray[x][y - 1] || bArray[x][y+1]){// if left or right are true
blobArray[x][y] = alphabet;
} else if (bArray[x][y+1]){ // if left doesn't exist, only check right
blobArray[x][y] = alphabet;
}

}

>>
File: obey.png (850KB, 1920x1080px) Image search: [Google]
obey.png
850KB, 1920x1080px
>do what I did in python in c
>runs literally 50 times faster

#define WIDTH 1920
#define HEIGHT 1080
#define DEPTH 3

#include<math.h>
#include<stdio.h>

enum color_band {R, G, B};

const size_t FRAME_SZ = WIDTH * HEIGHT;
const size_t TOTAL_SZ = DEPTH * WIDTH * HEIGHT;
const char *FILE_NAME = "image.ppm";
const unsigned char MAX_COLOR = 255;

float distance(float p1[], float p2[]);

int
main(int argc, char *argv[])
{
FILE *file_pointer = fopen(FILE_NAME, "wb");
unsigned char *pxs = malloc(TOTAL_SZ);
float center[2] = {WIDTH / 2, HEIGHT / 2};

for (int h = 0 ; h < HEIGHT; ++h) {
for (int w = 0; w < WIDTH; ++w) {
for (int d = 0; d < DEPTH; ++d) {
unsigned char px;
float point[2] = {w, h};
float dist = 1.0 - (distance(point, center) / HEIGHT);

switch (d) {
case R:
px = 0.5 * dist * MAX_COLOR;
break;
case G:
px = 0.1 * dist * MAX_COLOR;
break;
case B:
px = sin(dist * 10) * MAX_COLOR;
break;
default:
px = 0;
}

pxs[(h * WIDTH * DEPTH) + (w * DEPTH) + d] = px;
}
}
}

fprintf(file_pointer, "P6 %d %d %d\n", WIDTH, HEIGHT, MAX_COLOR);
fwrite(pxs, TOTAL_SZ, 1, file_pointer);
fclose(file_pointer);
}
>>
File: cuda.png (9KB, 1280x757px) Image search: [Google]
cuda.png
9KB, 1280x757px
Where do I go from there?
>>
>>56696504
fuck off
>>
>>56696655
compile it with -O2 (-O3 if you're alpha)
>>
Ok so apparently W exists so we can still do matrix multiplication on 3D points.
In that case, why store it? why not just have it a temporary inside the function that does the operation?
>>
>>56696731
it has different uses in different contexts

in gl_Position, w=0 indicates a non-homo coordinate, w!=0 is the perspective divide

in gl_FragColor, w is the alpha channel of the framebuffer
>>
(defmacro john (oliver)
(when (eq oliver 'oliver)
`(format t "~%I mean come on, people, it's ~D for G-d's sake!"
(nth-value 5 (decode-universal-time (get-universal-time))))))

(john oliver)
>>
>>56687992
I'm voting for this one
>>
File: tiredjpg.jpg (11KB, 251x242px) Image search: [Google]
tiredjpg.jpg
11KB, 251x242px
>>56696697
>cussing
>>
>>56687992
looks like he finished it already
>>56696824
>>
>>56696654

You need to check the array bound of y + 1.
>>
>>56696799
Yeah I know what W does in a fragment shader, I'm confused over what it's for in a vertex shader, or more specifically, why it's always stored with the vertex data, is it always 1? when is it not 1?
I don't understand what W is used for other than matrix-vector multiplication.
>>
>>56696824
Look where you fucking are.
>>
>>56696863
perspective-correct interpolation
>>
File: 1327079595963.jpg (52KB, 467x413px) Image search: [Google]
1327079595963.jpg
52KB, 467x413px
>>56696716
>>
>>56696885
So if I'm not (manually) doing perspective correct interpolation (because opengl does it for me), then there's no reason at all to store W persistently with vertex data?
>>
File: angry shig.jpg (36KB, 212x218px) Image search: [Google]
angry shig.jpg
36KB, 212x218px
>>56696814
>(nth-value 5 (decode-universal-time (get-universal-time))))))
>this is how you access $CURRENT_YEAR in Lisp
>>
File: Capture.png (67KB, 1129x680px) Image search: [Google]
Capture.png
67KB, 1129x680px
>>56687778
Just spent the last hour of my day bashing out a 5D vector type. Nighty night <3
>>
any good source to learn R?
>>
>>56696933
>protuct
Fix your shit.
>>
dpt is dead.
>>
File: justone.png (1MB, 1920x1080px) Image search: [Google]
justone.png
1MB, 1920x1080px
whoa dude pass the bong

Fuck me, I wasn't expecting this at all. Had to decrease the bitrate to post it - full color version only compresses to 5MB.
>>
File: scheme-eval-1.png (74KB, 1497x522px) Image search: [Google]
scheme-eval-1.png
74KB, 1497x522px
what am i doing wrong with this? this is for an assignment, so please don't say trying to make a scheme evaluator in scheme
>>
>>56697048
I'm sorry. It's probably my fault.
>>
File: 0005.gif (18KB, 128x128px) Image search: [Google]
0005.gif
18KB, 128x128px
>>56687778
Working on a program to determine the amount of panning imbalance in a stero audio file. It has to account for ten bands. Current part I am wrestling with involves neural nets.

Fuck neural nets. I swear, the explanations I've found are deliberately obscuring and conplicating things to prevent my understanding.
>>
https://ideone.com/ZB3SPM

N-dimensional compact vector implementation with x, y, z, w accessors.
Two problems with this implementation though.
First, vector_fields classes are exposed to the user. A clean implementation only exposes what you need, nothing more.
Second, anonymous structs aren't standard C++, even though most compilers support them.

Any ideas?
>>
Should I hate the webdevshits or the mobiledevshits that built this shit?
>>
Hi /g/, how do I become a mobile developer. less looking at it as a way to make money, and more of a hobby, if anything takes off that would be great, but I just mostly want to make apps that I would use
>>
Anyone know a lot about parser/yacc?
I have a grammar like
expr = ...
| "case" expr cases

cases = case | cases case
case = "|" pattern "->" expr

For code that looks like
case (mod x 3, mod x 5)
| (0,0) -> "fizzbuzz"
| (0,_) -> "fizz"
| (_,0) -> "buzz"
| (_,_) -> show x


However this reports a shift/reduce conflict, probably because of nested case expressions.
case x
| y -> case z
| w -> 0
| v -> 1 ; <- which "case" does this belong to?

How can I resolve this conflict to get yacc to shut up? (I'm actually using racket's built in yacc equivalent, parser-tools/yacc)
>>
File: 1.jpg (46KB, 800x480px) Image search: [Google]
1.jpg
46KB, 800x480px
>>56697216
Im not smart either
>>
>>56697196
>https://ideone.com/ZB3SPM
what in the ungodly fuck
why is
template <typename T>
struct vector {
T x, y, z, w;
};

not enough for you C++ folks??
>>
>>56697170
The call to (eval e) recursively calls (eval 1) and (eval 2), which call (car 1) and (car 2) in the cond clauses. Make a habit of checking types first in a cond clause before accessing list elements. In that case, the else clause should only return E, not (car E).

Alternatively, the recursive calls to eval can take sublists as opposed to elements, so cadr becomes cdr and caddr becomes cddr.
>>
double my_exp(double x){
int bound = (int) (x+.5);
double e = 2.71828182845904523536, cons = x - (double)bound, sum = 0;
for(int i = 0;i<12;i++)
sum += my_pow(cons,i)/my_fact(i);
return my_pow(e,bound)*sum;
}
>>
>>56697170
If you did
(eval 2)
It'd go to the 'else' and try to do
(car 2)
>>
>>56697324
Working on an ln function now so I can generalize a pow function.
>>
>>56697280
I want sizeof(vector<int, 3>) to be 12 on a 32-bit platform.
I also want vector.y and vector[1] to return a reference to the same int.
>>
what does ignore() do and when would i use it?tried looking it up, still can't understand
>>
>>56697324
if my_fact(n) runs in O(n), then that's gonna be pretty slow my dude.
>>
>>56689304
We can team up n shit.
Give some github
>>
>>56697196
vomited
Just provide specific instances of vector<T.N> for N between 1 and 4, and a default one.
>>
>>56697362
Good point, knowing that I only need up to factorial 12 I can just implement an array.
>>
>>56697426
Well you can also do
int fact = 1;
for (int i = 1; i < 12; i++) {
sum += ... / fact;
fact *= i;
}

or something like that
>>
>>56697405
Can't do that since not all platforms satisfy the offset requirements for members x, y, z, w.
>>
I want to implement sophisticated error checking, like checking for negative numbers, or input that's not a number in this Java program I made.

How do I go about doing that?
>>
>>56697445
What platforms?
>>
>>56697456
poo in loo
>>
>>56697456
if (bad_thing)
throw BadThingException("bad thing happened");
>>
>>56697535
C++ doesn't guarantee variables in a struct will not have some padded bytes between them.
>>

#include <stdio.h>

int main(int argc, char *argv[]) {
if (!argc >= 2) return 1;
char *p = argv[1];
while(*p!='\0') printf("%d ", (int) *(p++));
printf("\n");
return 0;
}


rate my first C app :-)
>>
>>56697445
You can still satiate your autism by using enable_if on each specialization as opposed to nested conditionals.
>>
>>56697542
yeah but how do I do it specifically for if the input is letters or negative numbers
>>
>>56697625
I don't see how you can use enable_if to add member fields to a class.
>>
>>56697656
You use it to constrain the template specializations for N = 1..4 with unions based on whether the offsets are equal. The default specialization just contains an array.
>>
NEW THREAD!

>>56697751
>>
>>56697754
Can you show an example?
>>
>>56697777
>>
>>56697636
http://lmgtfy.com/?q=java+check+if+input+is+a+number
>>
>>56687778
>What are you working on, /g/?
Fucking around with Verilog, trying to build babby's first 16-bit CPU. Right now I'm trying to figure out how to model a somewhat realistic memory interface to attach to the CPU.
Thread posts: 350
Thread images: 44


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