[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: 372
Thread images: 30

File: 2000px-Haskell-Logo.svg.png (36KB, 2000x1412px) Image search: [Google]
2000px-Haskell-Logo.svg.png
36KB, 2000x1412px
I need more programming pictures edition

What are you working on, my dudes?
>>
>>56462189
First for D
>>
Second for D is shit.
>>
third for you should try d
>>
Third for D is dicks
>>
>>56462200
Can't argue with those double dubs, guess I'm a #rustacean now
>>
A game where you are Pajeet and you run from evil western men who want to control your defecation preferences in ARM assembly
>>
File: Screenshot_2016-09-06_22-03-11.png (329KB, 1310x229px) Image search: [Google]
Screenshot_2016-09-06_22-03-11.png
329KB, 1310x229px
>>56462189
Stumbled upon this program I wrote a while back, interested to see if anyone can do it better
http://pastebin.com/p7viNijY
>>
>>56462231
You could do the same by piping /dev/rand straight into memory
>>
I'm getting the following error:

Cannot implicitly convert type 'void' to 'System.Collections.Generic.List<BasicMovie.Movie>'

from this code (too long to post here): http://pastebin.com/FHFtt4du

on line 26. What am I doing wrong?
>>
>>56462290
>http://pastebin.com/FHFtt4du

`AddMovie(ref Movies);`
>>
>>56462290
Is it not obvious that you are attempting to assign data from a function that returns void to a variable?
>>
>>56462290
poo in loo rajeesh
>>
New to C#. I'm writing a poker app. Just got the randomized deck working. Gonna start on the players and card strengths next. Would love some advice and critique. How would you guys handle the players?

    public class card
{
public string value { get; set; }
public string suite { get; set; }
}

class Program
{
static void Main(string[] args)
{
var deck = getDeck();

int count = 0;
int total = deck.Count;

foreach (var card in deck)
{
Console.WriteLine("{0}/{1} {2} of {3}",++count, total, card.value ,card.suite);
}

Console.ReadKey();
}

static List<card> getDeck(bool shuffled = true)
{
List<card> cards = new List<card>();

string[] suits = new string[4] { "Hearts", "Clubs", "Spades", "Diamonds" };
string[] faceCards = new string[4] { "J", "Q", "K", "A" };

foreach (var i in suits)
{
for (var j = 1; j < 10; j++)
{
card c = new card();

c.suite = i;
c.value = (j + 1).ToString();

cards.Add(c);
}

foreach (var f in faceCards)
{
card c = new card();
c.suite = i;
c.value = f;

cards.Add(c);
}
}

if (shuffled)
{
Random rng = new Random();
var count = cards.Count;

while (count > 1)
{
count--;
int k = rng.Next(count + 1);
var value = cards[k];
cards[k] = cards[count];
cards[count] = value;
}
}
return cards;
}
}
}
>>
File: 1460256710712.jpg (36KB, 512x512px) Image search: [Google]
1460256710712.jpg
36KB, 512x512px
I'm still working on my C message board!
http://akaribbs.mooo.com

There's another guy working on a message board as well, right?
>>
>>56462309

I didn't think that changing a value by reference in the method counted as a return value. It didn't mention that in The C# Player's Guide.

When I change 'void' to 'List<Movie>' it tells me that not all code paths return a value but that's what the Movies parameter is and it only ends with Movies.Add(movie).
>>
>>56462377
Hope you're working on QR right this second.
>>
>>56462351
Unions are literally perfect for cards, what the heck are you doing.
Why don't you represent cards from 1-12, Ace to King?
>>
>>56462411
C# is fucking trash
>>
>>56462302
>>56462309
>>56462342

>>56462411

Oh wait, Jesus Christ I'm an idiot. I see what the problem is now. I need to go to bed.
>>
>>56462411
Is this your first programming language?

Do you understand the purpose of passing a ref to Movies?

>>56462424
You're fucking trash.
>>
>>56462419

You mean 1-13?
>>
>>56462434
Yeah, sure senpai.
>>
>>56462432

It's my first 'real' language. Coming from Python. I've realized my stupid mistake and what you were talking about though now. This was pure stupidity on my part.
>>
>>56462419

Not familiar with Unions. I'll look it up. Thanks!
>>
>>56462262
your mom gets piped by randoms every night
>>
>>56462419
>Unions are literally perfect for cards
how so? are you talking about enums or..?
>>
>>56462377
post'd
>>
>>56462448
why do you seem to keep falling for /dpt/ memes? you shouldn't give a fuck about what people ITT think. most of these fags are elitists college kids with no real world experience
>>
I'm trying to create a function that:
>creates unique outputs based on input
>creates the same output regardless of input order, i.e. abc = bca

Can anyone point me in the right direction?
>>
>>56462466
No, enums are essentially programmer-friendly aliases for encoded data.

A Union (as in C/++) is the concept of a datatype that is multiple types at once. You declare that a certain type is an "int, double, float, string" all at the same time.

But that was actually wrong.

See, there are actually multiple ways to do this.
A dictionary is the simplest way. You can translate a key to a value, or a value to a key.
So you can go from int to string.

A lower-tech way is to simply make an immutable array of tuples which hold the string and value pair for each card.

For situations where any face card is considered "10", you just floor any value above 10 to 10.
>>
>>56462542
just multiply all the inputs together senpai
>>
>>56462542
the fuck
>>
>>56462552
the card can be an integer and you could look up the corresponding string in an array. why are you even involving unions or dictionaries
>>
>>56462534

I haven't *actually* fallen for a DPT meme. I love Python (and Flask and Django) and would gladly take a job in one of them if they were available in my area. Sadly over the past few months that I've watched job boards there haven't been any Python positions. So I'm learning C# and ASP.NET because that's what I've seen the most. I called it a 'real' language because it's strongly typed and I like to play into DPT memes a bit.

I recommend Python to people in these threads all the time. I can see where you'd get the idea that I fell for the meme though.
>>
>>56462586
>I recommend Python to people in these threads all the time
fucking cancer

>Python (and Flask and Django)
literally >>>/g/wdg
>>
>>>/b/702869574
>>
File: Selection_028.png (38KB, 799x684px) Image search: [Google]
Selection_028.png
38KB, 799x684px
>Pointers
allocbuf + ALLOCSIZE - allocp >= n


I can't make sense of that. ALLOCSIZE is just an integer number, aalocbuf is a pointer to the beginning of the array of the same name, then allocp is a pointer at the end of allocbuf.

Looking at the above code I already stated isn't it basically:
memory address + int - memory address >=n


This doesn't make sense to me.
>>
>>56462578
I said that.

The problem with using arrays for card powers is that you have to remember, "oh shit I need to add 1 to get the actual value of the card", or "any face card is worth 10."

It's perfectly fine to use arrays of cards to initialize a deck. But using arrays of cards to translate between ints and strings is fucking ass.

In C# you could simply modify the value property to either get the actual value of the card or 10, if face cards are considered 10.
>>
>>56462553
input 1: 1,1,1,1 = 1
input 2: 1,1 = 1

That will not work anon. I need unique values.
>>
>>56462613
poo in loo
>>
>>56462616
Just rearrange the inputs in ascending order and put that bitch through a hash function.
>>
>>56462623
poo poo in da loo, said the shrew who said more than he actually knew
>>
>>56462637
you're clearly a beginner try being a bit more humble for your own sake
>>
>>56462542
"hash function"
"sort"

Of course, it's impossible to create a hash function that is totally unique for every input, but the only functions that fit those criteria are simple transforms like "a + 1"
>>
>>56462610
It's called pointer arithmetic. When you add 1 to a pointer, it increased by the size of the pointed to type.

Say you have 4 byte ints and a pointer to an array of ints.
The memory location of the pointer ('ptr') is 0x100.
So ptr + 1 points to 0x104.
ptr + 2 points to 0x108
etc.
>>
>>56462601

¯\_(ツ)_/¯
>>
>>56462649
Eat shit.
Your stupid array method is pointlessly complicated and unreadable for any sufficiently complex definition of card value.
>>
>>56462674
lol good luck with your programming101 card game
>>
>>56462701
Good luck with your hundredth implementation of fizzbuzz in increasingly obscure languages.
>>
>>56462626
>>56462659
>hash function
I had never heard of that until now, that was exactly what I was looking for, thanks anons. I'm going to use md5.

>the only functions that fit those criteria are simple transforms like "a + 1"
what do you mean by this?
>>
>>56462710
roasted
>>
>>56462351
https://gitlab.com/bollocks/libbokerface

I'm doing something similar. I'm making an irc bot that will deal poker. It's in C++. So far cards, hands, and hand strength is done. I've built a test that creates every possible hand and sort of proved it correct. It's set up for 5 card hands and I'm going to use it for texas holdem and just brute force the 20 combinations from substituting one or two hole cards.

Look at the TexasHoldem object for how I'm implementing the game. It's 90% done. It's designed to allow the irc client to interface between the protocol and the object. So it's protocol agnostic.

I was able to work the evaluator down to 7ns from about 160ns. I think it's suitable for bruteforcing odds calculations for AI if you want to go that route.

I'm using naked deletes right now because I learned c++ way back when. I'll probably fix that later.

Consider it WTFPL at this point. So take what you liked. I'd appreciate attribution but I'm too lazy to figure out what license I want.

Warning TexasHoldem is poorly commented at this point but that should improve.
>>
>>56462764
samefag
>>
File: 2016-09-07-100021_1280x800_scrot.png (155KB, 1280x800px) Image search: [Google]
2016-09-07-100021_1280x800_scrot.png
155KB, 1280x800px
>>56462865
uh huh
>>
>>56462874
>1280x800
kek
>>
>>56462887
that wont save u from looking stupid
>>
>>56462258
When you're wording out numbers, "and" denotes when decimals start.

e.g. "two-hundred and three" isn't 203, but 200.3
>>
>>56462919
Neither will Chromium, tbqh farn
>>
>>56462874
jesus that aspect ratio
>>
>>56462919
his C# app-in-progress is very poor quality you're the ones who look stupid
>>
>>56462956
>>56462887
samefag
>>
>>56462971
who is >>56462957 then retard
>>
>>56462887
>>56462956
>>56462957
>>56462978

samefag
>>
>>56462664
I think I understand.

I have one more question that might not make sense:
int *ptr1 = beginning of array;
int *ptr2 = end of the same array;

Would:
ptr2 - ptr 1 = size of array?
>>
>>56463000
samefag
>>
>>56463002
Yes. But convert them both to ints first.
>>
>>56463002
ptr2 - ptr1 + 1 = length of array = (size of array) / (size of element)

like if you have an array of length 8 and pointers to [0] and [7], 7-0+1=8
>>
>>56463002
Yes, assuming ptr2 points just past the end of the array.

>>56463036
>But convert them both to ints first
That's not true. It's a ptrdiff_t.
>>
>>56463056
>ptrdiff_t
I thought that was only in C++.

If you want to add pointers for some reason, there's also uintptr_t in C++ for both addition and subtraction.

>inb4 why would you add pointers
>>
>>56462926
No, he's right.
You would only omit the "and" in 203 if you were talking slang.
If you want to denote decimals, you denote your decimals in base 10 form.
200.3 would be "two hundred and three tenths"
>>
>>56463161
The more you know
>>
>>56463036
>>56463043
>>56463056

Thanks, Anons.
>>
>>56463161
or two hundred point three
>>
File: Untitled.png (5KB, 435x154px) Image search: [Google]
Untitled.png
5KB, 435x154px
Just moved to VS 2015. Why the fuck does intellisense work when I'm typing literal strings, and how do I disable it?
>>
>>56463161
>You would only omit the "and" in 203 if you were talking slang.

This is actually one of those US vs. UK thing, sort of like math vs maths.
>>
>>56462424
>C# is fucking trash

2016's /g/. God help us.
>>
File: C# devs.jpg (786KB, 1200x800px) Image search: [Google]
C# devs.jpg
786KB, 1200x800px
>>56463271
calm down rajeesh
>>
>>56462814
neat. starred it to save and watch the progress.
>>
File: lennart_poettering.jpg (123KB, 1024x678px) Image search: [Google]
lennart_poettering.jpg
123KB, 1024x678px
>>56463294
Poo-in-loos use Java and pretty much only Java. You're giving them too much credit if anything.
>>
>>56463322
nice meme retard

http://www.c-sharpcorner.com/members/rajeesh-menoth
>>
File: Screenshot_2016-09-06_23-43-10.png (52KB, 1673x422px) Image search: [Google]
Screenshot_2016-09-06_23-43-10.png
52KB, 1673x422px
>>56462926
That's how I usually say it though, except it usually comes out as two-hundred n' three.
Apparently I'm not supposed to do that in American English though, but I don't think I was ever taught that
https://en.wikipedia.org/wiki/English_numerals
>>
>>56463322
I'd say it's a fair split between c#/++ and Java.
>>
>>56463359
Vindicated
>>
I'm shitty at programming. I just wrote a subtraction function and it worked with very little editing. So now I'm trying to figure out what's wrong with it that I'm not seeing.
>>
>>56463420
thnx
>>
>>56463359
> 110 -> one-one-zero
holy shit brit vernacular is so disgusting. Is this really normal? Are there limey kids in trig classes talking about "tyoo-sevun-zehro" angles?
>>
File: 1469148722292.gif (2MB, 709x625px) Image search: [Google]
1469148722292.gif
2MB, 709x625px
I suck.

How do I compare a number stored within a variable to the number of a specific slot of an array?

eg:

A variable n is being used to store a given number,
the array in use is as follows:

variable[size] = {x, x2, x3, x4 ...}

if(n == variable[x]
...
>>
>>56463565
the question is for which bus, 117 is the bus number like a code, the angle would be two hundred and seventy degrees
>>
>>56463200
to add onto what the other guy said, performing a conversion to ptrdiff_t before subtracting the start pointer from the end pointer will yield the address difference, which you then increment before dividing by the size of the elements.

do use ptrdiff, its best practice and using int has caused bugs for me
>>
>>56463633
ok. But not two-seventy? Its so natural.
>>
>>56463663
for you
>>
>>56463594
You're not phrasing the question very well, but I think you're talking about
if (n == variable[0])

You access the elements of an array using an index. In your case, 0 corresponds to 'x', 1 to 'x2', 2 to 'x3' and so on.
>>
>>56463594
maybe its because im tired but im not sure i follow.

by "number of a specific slot of an array", do you mean index (ie. the position it is in relative to the start of the array)? or do you mean the element AT that position?

>if(n == variable[x]
in this case, n and x are both variables, x is being used as the index, and variable[x]

what exactly are you talking about?

>>56463710
it crashed my program with no survivors
>>
>>56463711
>>56463720

What I'm trying to do is a complete clock + calendar using
<stdio.h> and only using <time.h> to set up a delay on the loop that I'm going to use to count the amount of seconds, minutes, hours (...)

http://ideone.com/OFB3uT

The problem is that I'm using the 29/02/2016 date as a test but the program is saying this is a invalid date instead of a valid one.
>>
>>56463840
void main()

int main(). void is not correct.

if (mth >= 1 && mth <= 12)
{
if (day == dperm[mth])

This is an off-by-one error. January is at index 0, not index 1.
so it should be
dperm[mth - 1]

Also, in this code, you're checking if day is the last day of the month, otherwise every other day is invalid.
So just like the year/month comparisons, it should be
if (day >= 1 && day <= dperm[mth - 1])
>>
>>56463664
Two seventy is retarded.
>>
nvm fixed it
>>
>>56463840
On this line:
if (day == dperm[mth])

You're trying to check if the date falls within the range [1, daysPerMonth], right? You're actually just checking if it falls on the last day of the month.

Some other advice
main always returns an int. your compiler might accept you declaring it as void, but it shouldnt
use abstraction. for each distinct bit of logic (e.g. number of days per month, validating the date, etc), put it into a separate function. this helps a lot because its self documenting-- when you call a function daysPerMonth(), isValidDate(), you know exactly the intent of the code is.

If you want, I'll post functionally equivalent code that demonstrates abstraction reasonably well, and leave the implementation of the functions to you.
>>
File: 1472344904063.png (1MB, 1000x1142px) Image search: [Google]
1472344904063.png
1MB, 1000x1142px
>>56463923
>>56463956


Thanks anons
here, have 1 qt
>>
Can you guys post a pic of what machine you're programming on? :3
>>
>>56463968
I don't want it
>>
>>56464005
Why?
>>
File: 1452463042847.png (128KB, 336x377px) Image search: [Google]
1452463042847.png
128KB, 336x377px
>>56463956
>use abstraction. for each distinct bit of logic (e.g. number of days per month, validating the date, etc), put it into a separate function. this helps a lot because its self documenting-- when you call a function daysPerMonth(), isValidDate(), you know exactly the intent of the code is.
Unnecessarily splitting shit into functions makes shit more annoying to read, as the flow of control keeps jumping over the place.
You shouldn't split shit into functions unless you want to reuse that logic again somewhere else, or the logic is just getting far too complicated in a single place.

>>56464005
Why are you on 4chan if you don't like cute anime girls?
>>
>>56463999
x220
>>
>>56464032
>anime
>2hu
>>
>>56464012
>>56464032
Because
>>
>>56464045
touhou had an anime.
>>
>>56464032
>as the flow of control keeps jumping over the place.
One of the main benefits of abstraction is that it makes it unnecessary to read the implementation. If you see a function called validateDate(), and you need to read the implementation to understand its purpose, you've got bigger problems than your coding ability. You don't need to know the implementation of it unless its buggy, or it has poor performance, and you can solve either cases far more easily because the design is far more modular.
>>
>>56464115
"Too much abstraction" and "bad abstractions" are a thing, you know.
In this case, it's pretty trivial, but in general, you shouldn't be abstracting shit just for the sake of abstracting shit.
>>
>>56464135
The only purpose for abstraction is to avoid repeating yourself.
if you find yourself doing something often, just put it in it's own function and make it generic enough to call it from anywhere.
>>
File: IMG_20160906_232040.jpg (3MB, 3120x4160px) Image search: [Google]
IMG_20160906_232040.jpg
3MB, 3120x4160px
>>56463999

My screen's a little dusty.

(Posting with secure tripcode because can't post with Sempai tripcode on phone)
>>
>>56464165
Did you put that Ubuntu button there?
>>
>>56464153
>The only purpose for abstraction is to avoid repeating yourself.
Weren't you just touting the fact that it means you don't have to think about shit?
Even then, including calling a function call an "abstraction" seems to be stretching the definition a little far.
>make it generic enough to call it from anywhere
Making general solutions that works well is hard to do right.
There is no point having generality unless you actually need it.
All you're doing is making your implementation more complicated for no gain.
>>
>>56464165
What an excellent photograph.
What aperture did you use?
>>
File: thinkpaddu.jpg (1MB, 2576x1932px) Image search: [Google]
thinkpaddu.jpg
1MB, 2576x1932px
>>56463999
Here you go!
>>
>>56464213
>nano
>>
>>56464135
this guy is not me >>56464153

hes a beginner, and while youre right that too much abstraction can be cumbersome, i generally think beginners should try to abstract more than less if only so that they design their programs with more modularity and, as beginners often do, dont make their programs a giant clusterfuck of spaghetti
>>
>>56464181
No. It came with the laptop, actually.

>>56464188
I have no idea what an aperture is with regards to cameras. I just used my phone. I am terrible at taking pictures.
>>
>>56464182
>All you're doing is making your implementation more complicated for no gain.

Spending a little time creating abstractions pays off big when your application grows into the kloc range.
Otherwise you end up with an unmaintainable mess.
>>
>>56464215
what's wrong with nano?
>>
>>56464237
>Otherwise you end up with an unmaintainable mess.
There is more than one way to structure a program, you know. You don't need some giant tower of abstractions (that will be extremely difficult to change later) to have a well-organised program.
Sometimes a function is just a laundry list of things that needs to be done.
Do A, then do B, then do C, and so on. If this is the only place when A, B and C are being done, what use is there separating them into functions? All you're doing is breaking the control flow for the reader.

>>56464251
Why don't you use an editor which actually has some features?
It doesn't take that long to get started with vim or emacs.
>>
>>56463999
Disabled my phone camera ripping out it's cam binary the day I bought it.

I have an Ikea generic desk, an Aeron chair (company gave it to me), a Kinesis Advantage keyboard to prevent RSI, one Samsung 23" LED (20 something inch, can't remember/care) and a serial cable to box running Xen for the sole purposes of compiling software/testing on multiple archs. AMD 8core w/cheap Asus board to support 32G ECC ram.

My regular dev box is a generic bunch of gigabyte parts with AMD 8core, again cheap Asus board + 32G ECC ram, and a stack of SSDs to enable faster builds writing and reading on different drives. It runs BSD.

I mainly break small web apps, audit, reverse engineer phone apps, and have a totally different job writing new handlers for in memory dbms at a BigCorp DbaaS because I got into a machine learning hobby which led me to database modifications, which led me to a job in db mods.
>>
Post/pre increment question:

This just prints abc, and does not concatenate the string:
// Concatenate t to the end of s; s must be big enough.
void strCat(char s[], char t[])
{
int i, j;
i = j = 0;
while (s[i++] != '\0') // Find end of s.
;
while ((s[i++] = t[j++]) != '\0') // Copy t.
;
}

int main()
{
char a[10] = {'a', 'b', 'c', '\0'};
char b[] = "xyz";

strCat(a, b);
printf("%s\n", a);
}


However, this does concatenate the string, giving the result "abcxyz"
// Concatenate t to the end of s; s must be big enough.
void strCat(char s[], char t[])
{
int i, j;
i = j = 0;
while (s[++i] != '\0') // Find end of s.
;
while ((s[i++] = t[j++]) != '\0') // Copy t.
;
}

int main()
{
char a[10] = {'a', 'b', 'c', '\0'};
char b[] = "xyz";

strCat(a, b);
printf("%s\n", a);
}


This surprises me. I would think I would want to check that value at s[i] and compare it to '\0' BEFORE I increment. So I would think that s[i++] would be the way to go, but as I stated earlier, this doesn't work.
Where am I going wrong with my logic/reasoning with pre/postfix increments?
>>
>>56464340
>Why don't you use an editor which actually has some features?

I already use all the features afforded by nano and I would appreciate if you could come up with some actual criticism for nano that doesn't consist of memes.

Also, your arguments against abstraction are so vague that they contribute nothing.

>>56464388
prefix increments, then accesses the variable
postfix accesses, then increments the variable
>>
The more I learn C, The more C++ makes me cream my panties.
>>
>>56464426
Faggot
>>
>>56464388

If you compare to '\0' before the increment, you have the index pointing to the character after the '\0', where you are copying the new string to. So in the end, you have a buffer that looks like "abc\0xyz". Guess where printf is going to stop printing?
>>
>>56464153
>The only purpose for abstraction is to avoid repeating yourself.

That's not what abstraction is. You are talking about helper functions, scripting, but not abstraction.

Abstraction is when you want to build a massively concurrent distributed system but you don't want the clients who connect to it to know anything about the underlying complexity so you hide it with abstraction, the clients just see local storage, local messages, ect but they are propagated all over the system hiding this complexity.
>>
>>56464407
>prefix increments, then accesses the variable
>postfix accesses, then increments the variable

Right, does it not make sense to access the variable at s[i] compare it to '\0' then increment it?
>>
>>56464488
Your coding style is an awful version of K&R and I don't even want to read it.
If you wanna be cute with your incrementers, just do
while (*++s)
or similar.
>>
By the way, if you're trying to copy the C strcat function, you can actually do it without iterators.

char* strcat(char *source, const char *destination)
{
char *ret = source;

while(*source) source++;
while(*destination) *source++ = *destination++;
*source = '\0';

return ret;
}
>>
>>56464519
>Your coding style is an awful version of K&R and I don't even want to read it.

Why are you trying to help me then? You're missing the point of my question.
>>
>>56464478
I see. Thank you.
>>
>>56464575

And I just realized that I called the source the destination and vice versa. Despite this, I managed to consistently fuck up the names, so the entire function works as intended.
>>
>>56464388
Unary operators are right-associative

Read 'C Traps and Pitfalls'
http://www.cs.tufts.edu/comp/40/reference/CTrapsAndPitfalls.pdf (29 pages, old pdf)

Also go on libgen.io and get 21st Century C
Also go on libgen.io and get this: http://csapp.cs.cmu.edu/

I that CS:APP book, right in the preface/introduction they give that Unary example you just ran into (it get's even more jinxy when trying to do pointer arithmetic and fucking up your unary operator).

There's just too much to know, like all the string functions that don't return /0
>>
>>56464641
oops
>return \0
>+n In that book
>>
>>56463322
sure dude? seen plenty of poo in loo js programmers
>>
does anyone understand sld resolution? because i don't

could someone explain what's going on here?
>>
>>56464729
Not really surprising considering JS is Java without the safety check of at least needing to be compiled first.
>>
>>56463594
You use an index.
>>
>>56464581
hes not trying to help you. hes trying to make you conform to his practices.
>>
>>56464738

JS is not an interpreted Java. You are perhaps thinking of BeanShell. Unlike Java, JS:

1. Is weakly, not strongly typed
2. Is dynamically, not statically typed
3. Does not force OOP
4. Uses prototype-based, rather than class-based OOP
5. Supports first class and top-level functions

Honestly, aside from the fact that both use a C-style syntax, I find little in common between JS and Java.
>>
>>56464738
>JS is Java
k
>>
>>56464737
It's basically depth-first search. It iterates through each possible expansion of the given expression recursively, prints bindings if it finds a fact that matches the expression, backtracks if it can't expand further, and halts if there are no branches left to backtrack to.

That slide actually shows the tree traversed by the search. Each column in a row represents a different branch of the tree. It can't find a rule that satisfies edge(1,3), edge(2,3), edge(4,3) or edge(4,C), so it can't find any solution.
>>
>>56464846
>5. Supports first class and top-level functions

Uh, um, Java has lambdas too, you know.
>>
abc = np.array([1, 2, 3, 4])
for a in abc:
if a > 2:
a = 0
print abc


Why is this printing
[1, 2, 3, 4]
rather than
[1, 2, 0, 0]
?
>>
what is the time complexity of treemap.values()?

http://www.tutorialspoint.com/java/util/treemap_values.htm
>>
>>56465871
The for loop isn't passing a by reference. The body of the conditional doesn't mutate the object a points to, but assigns it to a different object. Try iterating through indices and assigning abc[i].
>>
>>56465899
That's just a tree traversal, so O(n).
>>
>>56465905
Alright. It would have been nice to write it like that, looks nice and readable...
>>
File: wew.jpg (49KB, 331x331px) Image search: [Google]
wew.jpg
49KB, 331x331px
https://bugs.chromium.org/p/chromium/issues/detail?id=137231
I've run into this issue. I'm trying to do zipping operations (zip.js) using promises and callbacks asynchronously with the HTML5 DnD API but by the time I get to the second file the ondrop event has ended and the datatransfer.items has been reset.
What am I to do? It makes no sense that an API would be built to force you to do things synchronously in a language that's all about async and events. It also means I can't do the zipping operations on a webworker.
>>
>>56465919
And if you use a better enterpriseâ„¢ language like C++â„¢, as opposed to Python trash, you can do that quite easily! Just watch the magic unfold:
int abc[] = {1, 2, 3, 4};
for (auto &a : abc) {
if (a > 2) {
a = 0;
}
}
std::cout << abc << std::endl;
>>
>>56464842

Might as well put (void) instead of () at the end of the function while you are at it when you aren't going to ever pass one since that is the pedantic way to define a function with no parameters.

>>56466056

>magic
>for (auto &a : abc)

>>56466037

Use Firefox? It's not the end of the world if one browser doesn't do it properly and there are others available for you to use.
>>
>>56466092
>Use Firefox? It's not the end of the world if one browser doesn't do it properly and there are others available for you to use.
Firefox hasn't even implemented dataTransfer.items yet. For firefox I force users to upload a zip instead of doing it for them. And it's not a browser bug, it's the spec itself. The spec describes that you can only access the dataTransfer.items from within the ondrop event. Once you've left it (not sure if it means context or time) you're locked out.
https://html.spec.whatwg.org/multipage/interaction.html#drag-data-store
>A drag data store mode, which is one of the following:
>Read/write mode
>For the dragstart event. New data can be added to the drag data store.
>Read-only mode
>For the drop event. The list of items representing dragged data can be read, including the data. No new data can be added.
>Protected mode
>For all other events. The formats and kinds in the drag data store list of items representing dragged data can be enumerated, but the data itself is unavailable and no new data can be added.
Maybe if I meme it up with context binding it'll stay in the event?
>>
>>56462189
someone suggested I look into the "Julia" programming language. I was working on a project in Python and they suggested it as an alternative. anyone know anything about it? thoughts?
>>
>>56466190
It's very homosexual
>>
>>56462258
(loop (format t "~R~%" (parse-integer (read-line))))
>>
>>56466382
fag homosexual
>>
>>56466056
>
std::cout << abc << std::endl;

Disgusting.
>>
>>56466575
Well thankfully, if you're not a complete dumbass and don't overwrite cout and endl, you can just say
using namespace std;
cout << abc << endl;

Unfortunately, that anon was an autist that just regurgitated every general guideline he saw on SO before thinking why they should be followed.

>inb4 other autists get triggered
>>
god damn it banned again
>>
>>56466657
Still pretty disgusting compared to
print abc
2bh.
I prefer C over Python usually but that and for loops are the one thing I think look better in Python.
>>
>>56466056
>std::endl
>flushing the buffer manually
Don't do this. STL knows far better than you when to flush.
>>
>>56466673
You can just do
puts(abc)
in C/++.
>>
>>56462377
why don't you center that shit boi
>>
>>56466666
wasted
>>
File: url.jpg (3KB, 188x228px) Image search: [Google]
url.jpg
3KB, 188x228px
>>56466666
HOLY SHIT
>>
>>56466666
gnu/digits
>>
>>56466666
My man
Kill urself
>>
>>56466200

Nice, tell me more.
>>
>>56466673
Why are you bringing up C?
You're criticising a C++ feature.
>>
>>56466037
>force you to do things synchronously in a language that's all about async and events
as of recently*
and began with the server side*
>>
I am now making a simple Makefile generator tool called makemake, named after the dwarf planet Makemake, which lies in the Kuiper Belt. It takes as input as simple .json file (default makemake.json) and outputs a simple Makefile. The entire point is to have a simple and easy to understand Makefile generator that doesn't require reading a ton of documentation to figure out what everything does. It will support gcc and clang toolchains, and cross compiling to Windows, Linux, and/or Mac OS X; allow for auto-detection of internal header dependencies in C and C++, and make special case compilation for individual files easier.

I have no idea if anyone will ever find a use for this, but I don't like most Makefile generators, as they are often overly complicated.
>>
i've come to the conclusion that markdown using * and ** as i and b delimiters are likely the main reason why it's so badly standardized.
i've fucked around with some different markdown parsers and they act differently / weird as fuck when confronted with more complicated patterns that use stars.
>>
>>56467104
>stars
splats
>>
>>56467076
Well the end result is that there doesn't seem to be a language construct I can use to say "don't return until this promise has been fulfilled.
>>
File: 1444905507633.jpg (265KB, 700x987px) Image search: [Google]
1444905507633.jpg
265KB, 700x987px
I am making a lisp implementation in C, how can I in a portable way create a struct in runtime that I do not know about in the compile time when I use libffi? It looks like libffi does not provide any facilities for that.
>>
>>56467102
Can you give an example of input?
>>
How do you print Unicode characters using C++? I'm using Linux if that matters.

I'm receiving Unicode characters from user input using GLFW (more specifically glfwSetCharCallback). The callback function receives the Unicode character as an unsigned int, but what now? When I print it using cout, it only prints "0" no matter what key I press on my keyboard.

void CoreInput::charInputCallback(GLFWwindow* window, unsigned int key)
{
std::cout << key << std::endl;
}
>>
>>56467434
>Because an unsigned int is 32 bits long on all platforms supported by GLFW, you can treat the code point argument as native endian UTF-32.
Please, read docs.
>>
>>56467281

{
"toolchain" : "gcc",
"platforms" : ["i686-windows", "x86_64-windows"],
"libraries" : ["sfml-graphics", "sfml-window", "sfml-system"],
"headers" : ["include", "other_include"],
"sources" : "src",
"objects" : "obj",
"cxxflags" : "-std=c++14 -O3",
"special" : {
"main.cpp" : "-DSOME_DEFINE"
}
}
>>
I'm writing a program that pulls currency bid ask and rate at five minute intervals from yahoo finance and creates a csv, will run nonstop for three days...
>>
>>56467499
Well, yeah, but how do you treat a native endian UTF-32?
>>
I'm currently working on a makemake file generator. It takes as input a simple sexpr and outputs a simple makemake.json. The entire point is to have a simple and easy to understand makemake.json generator that doesn't require reading a ton of documentation to figure out what everything does. It will support the makemake toolchain, and cross compiling to Windows, Linux, and/or Mac OS X; allow for auto-detection of internal header dependencies in C and C++, and make special case compilation for individual files easier.

I have no idea if anyone will ever find a use for this, but I don't like most makemake.json generators, as they are often overly complicated.
>>
File: 1415638301449.jpg (84KB, 500x500px) Image search: [Google]
1415638301449.jpg
84KB, 500x500px
I remember studying C with a book that looked visually similar to "Jumping into C++", wich soft colors to highlight key points, tons of exercises and actual hands on examples of every single new concept introduced, but I can't find it anymore.

When I google for books, all I find is either the K&R (Which makes me feel like I'm learning how to computer off a thousand year old papyrus) or copycat books written by nobodies.

What's the other "Famous" C books? I remember choosing it because people told me it was as valid as the K&R, on top of being up to date with C11
>>
>>56467549
If you have a new compiler, you can use standard facilities (codecvt class) to convert it to whatever you like.
>>
>>56467506
Why not write a C++ package manager?
>>
>>56467763

I do not have need of a package manager -- I am not on Windows.
>>
>>56467434
>How do you print Unicode characters using C++?
I'd seriously consider using http://site.icu-project.org/. Working with unicode in C++ isn't pretty and depends on the systems locale. And using std:string is like asking for trouble.
>>
php chatbox, had to strip out all the html for it to fit here

<?php
$file = 'shouts.txt';
$maxShouts = 10;
$shouts = file($file);

$emoticons = [':D', ':(', '<3', '8)', ';)', ':)', ':|', ':P'];
$replace = [
'<span class="emote-happy"></span>', '<span class="emote-sad"></span>',
'<span class="emote-love"></span>', '<span class="emote-cool"></span>',
'<span class="emote-wink"></span>', '<span class="emote-smile"></span>',
'<span class="emote-plain"></span>', '<span class="emote-tongue"></span>'
];

if (array_key_exists('shout', $_POST)) {
$count = count($shouts);

if ($count == $maxShouts) {
unset($shouts[0]);
}

array_push($shouts, $_POST['shout']."\n");
file_put_contents($file, $shouts);
}

$shouts = array_reverse($shouts);
?>
<html>
<head>
<title>Chatbox</title>
</head>
<body>
<div id="chatbox">
<table width="100%">
<tr>
<td>Chatbox</td>
</tr>
<?php
for($i = 0; $i < $maxShouts; $i++) {
if (array_key_exists($i, $shouts)) {
$shouts[$i] = str_replace($emoticons, $replace, $shouts[$i]);
echo '
<tr>
<td>'.$shouts[$i].'</td>
</tr>
';
}
}
?>
</table>
<form name="shoutbox" method="post" action="">
<input style="width: 74%;" type="text" id="inputfield" name="shout" />
<input style="width: 24%; margine: 0; padding: 0;" type="Submit" value="Chat!" />
</form>
</div>
</body>
</html>
>>
>>56467274
What are you trying to do? Pretty much the only structures you'll need in a bare-bones Lisp implementation are symbols and cons pairs.
>>
File: pajeet message.png (7KB, 530x130px) Image search: [Google]
pajeet message.png
7KB, 530x130px
>>56467798
>I do not have need of a
>>
>>56467922
>margine
>e
>>
http://collinoswalt.com/biology/

Working on genetic algorithms. Birds flap their wings and try not to hit the upper and lower bounds of the map. I've yet to add breeding, but I think I've got the physics down. Currently just generates 25 random birds
>>
>>56468310
you could use a PID controller too
>>
>>56462189
int main(){
unsigned long long one = 1;
std::cout << (one>>64);
return 0;
}


Why the flying fuck is this outputting one?
>>
>>56468563
Outputting 0 for me, get FUCKED.
>>
>>56467506
I'd definitely use it when it's done, keep us posted
>>
>>56468563
warning: right shift count >= width of type [-Wshift-count-overflow]

try 63 instead of 64.
>>
How many shills does your company employ? I think we only have 4-5 out of 20 total employees.
>>
>>56468794
I don't work.
>>
>>56468794
What do you mean by shill
>>
>>56464165
did you take the pic with your microwave
>>
>>56468861
sit in front of a computer for 8 hours a day writing articles and posts on various social media
>>
i'm running a python script that writes to file in a loop, but when i open that file in file browser it's a blank file, even though the script has written to file multiple files. Is that expected/how can i view files as it gets written?
>>
File: 1473235152764.png (287KB, 638x660px) Image search: [Google]
1473235152764.png
287KB, 638x660px
>>
>>56468794
0 out of ~38 employees, but we do go through a marketing firm to manage our website and social media.
>>
>>56468903
just add a file.flush() after the write
f=open('test.txt', 'w')
f.write('memes\n')
#open file: blank file
f.flush()
#all the buffered write is written to disk
#open file: write is shown on file

just tested, works for me
>>
>>56468794
None. We do contract a PR company for public promotions, events and success stories. However there will only be like 90 views on youtube clips they make and most of them if not all are from employees.

The most important part is having a salesforce that invite customers out for lunch, dinner and events. Our salesforce are like 8 people out of a total of 110. I have no problem with them. They do an excellent job and all of them have higher technical educations. Many of them have studied engineering physics and similar and have work experience in their fields.
>>
I'm trying to replace invisible characters with their literal selves. Its not really working can anyone help me with this? Thanks in advance

 
while((c = getchar()) != EOF){
if(c == '\b')
c = "\\b";
else if(c == '\t')
c = "\\t";
else if(c == '\\')
c = "\\" ;
putchar(c);
}
>>
>>56469402
Looks like you are assigning strings to a char. I'd say you are probably writing to memory you aren't allowed to write to.
>>
>>56469428
Ahh how would i go about printing these then?
from what it sounds like I'm not going to be able to do this without having getchar magically turn into a string type.
>>
>>56469545
Putchar prints a char.
>>
>>56469545
just have a print statement in the if-else, don't save them in between, like:
while((c = getchar()) != EOF){
if(c == '\b')
printf("%s", "\\b");
else if(c == '\t')
printf("%s", "\\t");
else if(c == '\\')
printf("%s", "\\");
}


>>56469428
Usually the c compiler just assigns the pointer to the string to the int if you have
int i = "string literal";
>>
>>56469604
>int i = "string literal";
that's valid C?
>>
>>56469604
printf("%s", "\\b");
//can also be written as
printf("\\b");

Don't know what the fuck I was doing there, last one looks cleaner and might be faster.
>>
>>56469631
I don't know, compiler gives a warning but still compiles. No idea what the C standard says about it but i rather like to keep out of those arguments.
>>
>>56469604
Now i feel retarded. Thanks for the Help my good man

On the same note would there be a valid way to do it like i was? Saving the text then adjusting and printing the result? That what i was initially going for.
>>
>>56469604
>Usually the c compiler just assigns the pointer to the string to the int if you have
But i isn't even a pointer type? You get the address to "s" passed as value? Is that really standard compliant? And >>56469402 isn't initializing c in his if statements. It appears he's overwriting a char with something that's large than 1 byte.
>>
>>56469714
I was, as he said. >>56469428
>>
File: awetawrawewadwew.jpg (49KB, 551x955px) Image search: [Google]
awetawrawewadwew.jpg
49KB, 551x955px
can somebody help me out, i'm trying to learn javascript/mean

how do i call getcount from within manage? it currently says it's undefined.
>>
>>56469698
>On the same note would there be a valid way to do it like i was? Saving the text then adjusting and printing the result? That what i was initially going for.
You need a char array. "\\b" is two chars.
>>56469738
I wrote both replies.
>>
>>56469631
Not in a strictly conforming program. It is implementation-defined whether a pointer can be converted to an integer type, and if it can't, it results in undefined behavior.
>>56469801
"\\b" (as an expression) is a pointer to const char array of three elements.
>>
>>56469836
Fix: A pointer the first element of an array with three elements of type const char
>>
File: faweawdawe.jpg (52KB, 690x961px) Image search: [Google]
faweawdawe.jpg
52KB, 690x961px
>>56469786
i don't understand javascript classes, can somebody tell me why seed is null when i try to grab it from within the manage function?
>>
>>56469714
i should be an int since getc() returns an int and for testing the result of getc() against EOF it has to be stored as int.

And yes the compiler warning said it implicitly casts a pointer to int.
>>
Trying to configure xbindkeys and xdotools to rebind wasd to my arrow keys, to fix that horrendous civ5 key mapping.

Here's my config so far:
https://bpaste.net/show/5ef5accc9c8e (it's the top and last part that matter)


It seems like =(ungrab-all-keys)= =(grab-all-keys)= are heavy operations, and manually overriding doesn't seem to work.
I need them to prevent xbindkeys from catching the shadowed key press for when I'm not inside civ5.

Here's an example config
http://www.nongnu.org/xbindkeys/xbindkeysrc.scm.html
http://www.nongnu.org/xbindkeys/xbindkeysrc-combo.scm.html
>>
>>56469836
>"\\b" (as an expression) is a pointer to const char array of three elements.
Yeah forgot about null termination. Also I read up on getchar. It returns an int but I assume that c="\\b" is an illegal operation or should be? Or is it implicitly typecasted to an int somehow and manages to fit in 4 bytes but printf will only print the first byte in the int?
>>
File: warawe.jpg (31KB, 687x408px) Image search: [Google]
warawe.jpg
31KB, 687x408px
somehow

var seed = this.seed;

made seed appear out of thin air and now it's working as intended.

still don't know why i couldn't call a class function from within a class function but w/e

thanks for the help
>>
>>56469982
>printf will only print the first byte in the int?
You probably meant putchar() since printf prints how you want it printed.

But putchar() takes an int and converts it to unsigned char just before writing.
>>
>>56470061
You're welcome, faggot.
>>
>>56470061
you problem is "this" refers to something different depending on where you write it. Inside the lambda callback, this refers to something else.

This is a massive problem in JS. "this" is basically broken.

you can hack it to work by writing "var this_ = this;" right after "Manage(app, usermodel, todomodel){: and then use "this_" instead of "this". CoffeeScript makes this fix automatically.
>>
>>56469982
Since it's implementation-defined, it may be illegal (as the implementation documents). Implementations can define a special integer type to which pointers can be converted (intptr_t). Ability to successfully recover a pointer from an integer to which it was converted before is also implementation-defined.

This translation of non-printable characters to their C escape codes doesn't require any such feature. If you save the result into a buffer, then you first save the escape character, then its code. If you print it with putchar, you first putchar('\\'); and the putchar its code.
>>
>>56470061
>>>/g/wdg/
>>
>>56470061
Because JavaScript scoping is retarded so you need to do shit like this:
var self = this;


Above any closures et al then use the self rather than this variable. Also wrong general, go to wdg instead.
>>
>>56469958
What I meant to ask was:
Is there anything that I missed on these tools that make this process easier? Where should I improve my Guile (Scheme) programming? How should I have taken on this problem? At some point I drew a schematic, but it didn't make much sense.
>>
>>56470061
gEt the FUCK out of MY generAl yoU PIECE of DOG shiT
>>
>>56470084
Ah yeah I was reading the "fixed" code sample.
>>
>>56470190
>gEt the FUCK out of MY generAl yoU PIECE of DOG shiT
>E FUCK MY A U PIECE DOG T

What did you mean by this?
>>
>>56470160
>var self = this;
Why is this the case. I never understood why I saw this everywhere in javascript (other than guessing it had to do with weird scope rules)
>>
>>56470247
I don't know, I don't work with JavaScript, all I know is that it's because of some retarded scoping rules in JS and otherwise variables won't be accessible if you reference them directly through self withing closures/lambdas.
>>
>>56470268
I meant directly through this*
And within*
>>
>>56470268
>retarded scoping rules in JS
that's JS for you. and people still praise that piece of crap.
I don't get it
>>
>>56464340
>(that will be extremely difficult to change later)

good abstractions allow you to make changes easily, not the other way around
>>
tfw no project of mine is bigger than 400 lines of code.

wat do?
>>
>>56470436
keep it up
>>
>>56470402
There's some nice ideas hidden behind the septic tank of the language.
>>
>>56470268
>retarded scoping rules in JS

For me js is so unnatural and stupid, maybe because i come from c/c++/java/php
js makes me angry always
>>
File: port.png (624KB, 2000x510px) Image search: [Google]
port.png
624KB, 2000x510px
Which one of the 4 left do you guys think looks best? I just put them together quickly, when done the header will blend and look like the page on the right.
>>
What are some hands on C# tutorials that I can write and then add on too?

http://www.rohitab.com/discuss/topic/34338-indepth-c-trojan-tutorial/

Something like this but more useful (I have no use for a fucking trojan).
>>
>>56470549
>programming thread
>>
>>56470549
last one, with light blue
>>
How do I deselect an item in a listbox when selecting another entry from a dropdown menu (combobox)? I guess more specifically, where would I put
exampleList.ClearSelected()
or
exampleList.SelectedIndex = -1
? I'm getting a NullReferenceException currently and putting either of those in the combobox_SelectionChanged method hasn't rectified this.
>>
>>56470402
pretty sure the people praise the various modules related to webdev you can get for free and not the language itself
>>
>>56470713
probably. which is pretty sad, IMO.
why other langs don't simply copy and improve their shit? is there too much "NIH syndrome" among programmers?
>>
>>56470653
I started writing a Discord bot in C# last night. Pretty easy to work with. It greets you and sends random NSFW pics and jazz from my computer upon request.

There are hundreds of projects that you could clone and fuck with.

What are your interests? What software with interoperability do you use every day?
>>
Why does C++ still suck?

$ ls
funksjon.cpp funksjon.h main.cpp Makefile
$ cat funksjon.cpp
#include "funksjon.h"

#include <iostream>

template<bool B>
void funksjon()
{
std::cout << (B ? "ja" : "nei") << std::endl;
}
$ cat funksjon.h
#ifndef FUNKSJON_H
#define FUNKSJON_H

template<bool B>
void funksjon();

#endif /* FUNKSJON_H */
$ cat main.cpp
#include "funksjon.h"

int main(int argc, char **argv)
{
funksjon<true>();
funksjon<false>();

return 0;
}
$ cat Makefile
CXX=g++
CXXFLAGS=-Wall --pedantic -std=c++14
DEPS = funksjon.h
OBJ = main.o funksjon.o

%.o: %.cpp $(DEPS)
$(CXX) -c -o $@ $< $(CXXFLAGS)

all: $(OBJ)
g++ -o $@ $^ $(CXXFLAGS)

.PHONY: clean

clean:
rm -f *.o
$ make
g++ -c -o main.o main.cpp -Wall --pedantic -std=c++14
g++ -c -o funksjon.o funksjon.cpp -Wall --pedantic -std=c++14
g++ -o all main.o funksjon.o -Wall --pedantic -std=c++14
main.o: In function `main':
main.cpp:(.text+0x10): undefined reference to `void funksjon<true>()'
main.cpp:(.text+0x15): undefined reference to `void funksjon<false>()'
collect2: error: ld returned 1 exit status
Makefile:10: recipe for target 'all' failed
make: *** [all] Error 1
>>
>>56470847
You just fucking suck.
>>
I'm trying to make my fisrt Tic Tac Toe, but I can't figure out what's wrong with my takemove function.

void takeMove(){
int Move;
bool validmove;
string turn;
if(Xturn)
turn = "X";
else
turn = "O";
while(!validmove){
cin>>Move;
switch(Move){
case 7: board[0][0] = turn; validmove = true; break;
case 8: board[0][1] = turn; validmove = true; break;
case 9: board[0][2] = turn; validmove = true; break;
case 4: board[1][0] = turn; validmove = true; break;
case 5: board[1][1] = turn; validmove = true; break;
case 6: board[1][2] = turn; validmove = true; break;
case 1: board[2][0] = turn; validmove = true; break;
case 2: board[2][1] = turn; validmove = true; break;
case 3: board[2][2] = turn; validmove = true; break;
default: cout<<"Invalid move. Retry.\n"; validmove = false; break;
}
}
}


When I input a wrong move, instead of going back to the start of the loop and asking you to input the move again, it just prints the default case forever.
It never asks for input again, despite cin being literally the first thing in the loop, what am I doing wrong?
>>
>>56470881
'fraid not, friendo.
>>
>>56470847
You cant repair a house built on a destroyed foundation.
>>
>>56470687
It would be nearly impossible to help you with this without seeing all of the relevant code.

You're getting a NullRef on
exampleList
? Have you tried setting a breakpoint and inspecting the value of that object before you attempt to modify it?

ClearSelected()
is certainly what you're looking for.
>>
Only been struggling with this peice of shit assignment for about 24 hours

low = 0
mid = 50
high = 100
secretnum =("Is your secret number: ")
gameover =("Game over. Your secret number was: ")
print("Please think of a number between 0 and 100!")
print(secretnum + str(mid) + ("?"))
herp = input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. ")
while herp != 'c':
if herp == 'h':
high = mid
mid = int((mid + low)/2)
elif herp == 'l':
low = mid
mid = int((mid + high)/2)
else:
print("Sorry, I did not understand your input.")
print (secretnum + str(mid) + ("?"))
herp = input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. ")
if herp == 'c':
print (gameover + str(mid))


Its not my code i looked the assignment up online and found somone elses broken code and just debugged it.
>>
>>56470847

Template must be in the header or pre-instantiated

option 1
put the function into the header

option 2
add
>void funksjon<true>();
>void funksjon<false>();
to the header or cpp file.

option 3 (ishyddt)
put the template function into a .cpp/.tpp file and add
>#include "funksjon.tpp"
into the header's bottom
>>
Fact: MVC is a hack workaround for the limitations of the extreme OO, retained mode side of GUI implementation. Saying that a GUI must use MVC is digging your own grave.
>>
File: 1467019345752.jpg (10KB, 180x157px) Image search: [Google]
1467019345752.jpg
10KB, 180x157px
>>56470883
>case 7: board[0][0] = turn; validmove = true; break;
> case 8: board[0][1] = turn; validmove = true; break;
> case 9: board[0][2] = turn; validmove = true; break;
> case 4: board[1][0] = turn; validmove = true; break;
> case 5: board[1][1] = turn; validmove = true; break;
> case 6: board[1][2] = turn; validmove = true; break;
> case 1: board[2][0] = turn; validmove = true; break;
> case 2: board[2][1] = turn; validmove = true; break;
> case 3: board[2][2] = turn; validmove = true; break;
>>
>>56470883
>what's wrong with my takemove function.
Almost everything. What seems to be causing the malfunction is probably that the input you read is a string while the cases are all numbers, so none match. Replace the cases from case 7 to case "7" and so on.
>>
File: if trolled then killself.jpg (101KB, 539x899px) Image search: [Google]
if trolled then killself.jpg
101KB, 539x899px
>looking through lemonstand legacy code for shits and giggles
>realize that the language is infinitely better structured and easier to understand than most hipster meme languages nowadays

How did we regress in efficiency in less than 20 years?

The ability to call lines directly is something that is severely missing from modern languages. It seems like we're jumping through hoops using pointers and calling chars when we could just use the ancient methods. What the fuck happened?
>>
>>56470993

I'm not good enough to think of better alternatives to make a move based on the numpad :^)
I just want to know why the default case triggers forever in case of an invalid move.

>>56471026
But the input is Move, an integer.
>>
>>56470847
>Why does C++ still suck?

Because the "export" keyword was a massive failure.
http://en.cppreference.com/w/cpp/keyword/export
http://stackoverflow.com/questions/279404/what-is-the-best-explanation-for-the-export-keyword-in-the-c0x-standard
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1426.pdf
>>
>>56471026
I'll add that it works perfectly in case of a valid move.
My only issue is that if I type in, for example, "P" as my move, it prints "Invalid move. Retry" forever, without asking for input ever again.

If the issue was just one of comparison, then it would ask me for my input again anyway.
>>
>>56471057
even if you want to do it like that, why not convert the number into coordinates using maths rather than brute force?
>>
>>56471050
Structured programming happened. Goto is tough to reason about.
>>
>>56470989
>Fact: Opinion
>>
What books do you recommend for Python 3, lads?
>>
>>56471110
I tried that initially, but I couldn't find a mathematically sound way to convert the numbers into array coordinates.

The numpad increases horizontally and decreases vertically, and in series of three.

You tell me how to convert that into coordinates that organically get bigger top-down/left-right
>>
>>56471144
div 3 and mod 3 to get x and y (figure out which order)
subtract from 2 to reverse the direction (figure out which need it)
>>
>>56471144
num/3 = row
num%3 = col
>>
>>56470981
>option 2
>add
>>void funksjon<true>();
>>void funksjon<false>();
>to the header or cpp file.
This doesn't seem to be working for me (I have the problem in a larger project) - is there anything else I need to do to make it work?
>>
>>56471133
Well, essentially the problem that MVC "solves" is making all the various GUI widgets able to react and update to a changing model. This isn't an issue if you make the GUI stateless or at least mostly stateless, i.e. closer to an immediate-mode GUI. The deficiencies of OO lead to callback hell, whereas the deficiences of procedural just have to do with code duplication.
>>
>>56470981
option 3b: Depending on compiler you can use the export keyword.

I agree that solution 3 isn't pretty. But when you've lived with separated header and implementation body files for so long option 1 just feels wrong. Until the standard recommends to do away with header files one would expect template header files to be linked the same way as other "normal" header files.
>>
>>56471247
>>56471247

Using div/mod was my first thought, but accounting for the exceptions makes it look uglier and longer than just using a switch.

And, for the fourth time, it's not my issue.

I want to know why the default case makes my program not accept input ever again and just loop forever in case I try typing a letter in the Move value.
>>
>>56471289
>>56470981
It looks like it works if I do the explicit instantiation in the source file but not the header file.

Anyway, thanks, you've solved a headache for me.
>>
>>56468203
Sorry for replying this late, I hope that you are still on this thread.
This is so I will be able to call C functions that make use of such structures from my lisp.
>>
>>56471350
I thought export keyword had been removed from newer C++ standards?

option 2 is working for me now, fortunately my template parameter is a bool in this case and I know I will need exactly 2 instantiations.
>>
>>56469911
this is dynamic and depends on how a function is called.
Assign
var self = this;
at the top of Manage and change
this.seed
to
self.seed
.
>>
>>56467506
Cancerous
It would be better if it was sexpr
>>
>>56471305
>stateless GUI
Yeah, I know what immediate-mode GUI is, and working with it is fucking hell.

The point of MVC is simply to provide a potential design pattern to separate your logic from your GUI elements.

This allows you to easily detach the logic and attach it to an entirely different GUI framework, which means cross-platform is feasible.

Immediate-mode GUI designs inherently mix logic with GUI, because the GUI doesn't store any information about itself. While this can be very useful in some situations (vidya UI), it's typically a nightmare for your average non-trivial application.

tl;dr: It's likely that you haven't worked on large, complex GUI-based applications.
>>
>>56471050
>What the fuck happened?
OOP, perhaps?
>>
This may be a "how do I shot web" question, but where do I go to find good resources on pentests and security? Preferably self-security. I'm dipping my toes into networking and some of the books are pretty high-level, i.e. not too useful for a layman.
>>
File: 1470541239072.jpg (24KB, 340x340px) Image search: [Google]
1470541239072.jpg
24KB, 340x340px
Am I doing something wrong if I think I have about the same efficiency with vim as emacs?
>>
>>56464165
>ruby uses ubuntu

filtered
>>
Does your language have dependent types?

All new languages should have dependent types. There is no point in making a new language without them.
>>
>>56471588
>Immediate-mode GUI designs inherently mix logic with GUI, because the GUI doesn't store any information about itself.
Only the GUI logic, you don't have to be an idiot and mix the game/engine logic in as well. Why would you separate the GUI logic from the GUI presentation, since the former actually depends on the latter (the user has to click where he sees a button)?

Personally, I think most of the deficiencies of IMGUI are caused by deficiencies in the programming language, not in the "paradigm".
>>
>>56471665
You're probably doing something wrong if you think you're efficient with either of those editors.
>>
>>56470927
http://pastebin.com/e1XQL4wp
I get NullRef on selectedCounty in countyList_SelectionChanged. If I set a breakpoint at the end of that method if I select AL and the first county in the listbox, when I reach the breakpoint selectedCounty will be the first county in the listbox (for AL, Autauga).
>>
>>56471588
>>56471708
>Personally, I think most of the deficiencies of IMGUI are caused by deficiencies in the programming language, not in the "paradigm".
I suppose this might apply to RMGUI as well, since most languages aren't anything like Smalltalk.
>>
>>56471728
IDE user detected

Mate, you're a clueless dunce.
>>
>>56471789
t. person who has text editor+command line up at all times in the name of "efficiency"
>>
>>56471050

You can still use these ancient languages, you know. Nothing is stopping you.
>>
>>56471876
t. clueless dunce
>>
>>56471900
That's why you can still use C# isn't it mummy?
>>
>>56471900
b-but I don't want to be made fun of by #Dpt
>>
>>56471789
if you're efficient with vim/emacs it's because you've extended them to the point where they're essentially IDEs
>>
x = float(input('enter a decimal number between 0 and 1: '))

p = 0

while ((2**p) *x)%1 != 0:
print('Remainder = ' + str((2**p)*x - int((2**p)*x)))
p +=1

num = int(x*(2**p))

result = ''
if num == 0:
result = '0'
while num > 0:
result = str(num%2) + result
num = num//2

for i in range(p - len(result)):
result = '0' + result

result = result[0:-p] + '.' + result[-p:]
print('the Binary representation of the decimal ' + str(x) + ' is ' + str(result))

this fucking god damned class.
>>
>>56471789
>if you use an IDE, you're a clueless dunce
How's the NEET life treating you?

Did you get around to writing that FizzBuzz yet?
>>
>>56471789
Anyone who uses emacs seriously has added so much bullshit to it that its hardly editor+compiler any more.

You could almost say that it's a development "environment" that's "integrated" with various tools.
>>
>write a toy page in pure HTML/CSS + vanilla js that does some simple ajax requests using a lot of experimental features
>wonder how is it using a js framework
>rewrite the whole thing in angular
>spend twice the time reading the docs, editing the original HTML, using the recommended file hierarchy and modules structures
>result is magnitudes slower than original
>code is barely maintainable

This needs to stop.
>>
There's a difference between adding stuff to a bare bones editor to make an IDE than downloading a pre-assembled IDE which probably has way more things than you need and is way less customizable.

My opinion is that the vim/emacs snobs need to realize that, yes, they're probably using them as IDEs, but it's still better that way.
>>
>>56472043
>>56472096
>>56471985
t. more clueless dunces
>>
>>56471983

Nobody cares. Find a compliant minimal basic compiler and have at it.

Here's one: http://buraphakit.sourceforge.net/BASIC.shtml

>>56471975

Wew
>>
File: bait1.jpg (180KB, 756x1100px) Image search: [Google]
bait1.jpg
180KB, 756x1100px
>>56472200
>>
>>56471786
set a breakpoint at line 59 of your pastebin there

Does
countyList.SelectedItem
have a value before you try to use it?

Use the Locals window in Visual Studio while you're debugging.

Try handling the null value there:
if (countyList.SelectedItem != null) { ... }
>>
>>56472200
stay sour grapes
>>
>>56472354
stay guzzling cum
>>
>>56472159
Refactoring is still garbage in vim and emacs no matter how much you add to it.
>>
>>56471728

At least for java things like eclipse/intellij feel super sluggish. I would use gradle and emacs than intellij
>>
>>56471786
>>56472348
Addendum: I'm pretty sure the SelectionChanged fires as soon as the control is created in the Window, and unless it has a default value, you're going to get a nullref there.

This is happening before you have a chance to interact with it, yes?
>>
>>56472405
only if you have a shit computer idiot and gradle is the slowest part
>>
>>56472389
Refactoring is a workaround for writing rigid code.
>>
>>56472474
Most of the time you inherit and have to maintain things you aren't responsible for. Sometimes code bases that are over 20 years old.
>>
>>56472632
Well, that sucks.
>>
>>56472273
>>56472354
Why did you even respond to her?

It's clear she's baiting for responses, but people like that don't care about negative attention; she just wants the attention either way.
>>
How do I get into declarative programming? I'm starting to learn Prolog but it's damn near impossible for me because of how different the thinking is.

For those that have learned it, how did you get into the right frame of mind?
>>
>>56472348
>>56472407
countyList.SelectedItem
doesn't have a value before I actually try to use it, according to Locals.

>This is happening before you have a chance to interact with it, yes?
With countyList? No, the NullRef occurs after interaction; the list populates after I select a state and I can click on elements in the list, but when I go to stateBox to switch states, the NullRef occurs.
>>
>>56472696
>her
(You)
>>
>>56472670
That is called having a software development job. Welcome to reality when that happens.
>>
C++ is a pretty cool guy, eh optimizes and doesn't afraid of anything

$ cat switch.cpp
template<bool B>
char function1()
{
if (B) {
return '1';
} else {
return '0';
}
}

template char function1<0>();
template char function1<1>();

char function2(bool B)
{
if (B) {
return '1';
} else {
return '0';
}
}


$ g++ -S -Wall --pedantic -std=c++14 -c -o switch.s switch.cpp

$ cat switch.s
    .file    "switch.cpp"
.section .text._Z9function1ILb0EEcv,"axG",@progbits,_Z9function1ILb0EEcv,comdat
.weak _Z9function1ILb0EEcv
.type _Z9function1ILb0EEcv, @function
_Z9function1ILb0EEcv:
.LFB2:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl $48, %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2:
.size _Z9function1ILb0EEcv, .-_Z9function1ILb0EEcv
.section .text._Z9function1ILb1EEcv,"axG",@progbits,_Z9function1ILb1EEcv,comdat
.weak _Z9function1ILb1EEcv
.type _Z9function1ILb1EEcv, @function
_Z9function1ILb1EEcv:
.LFB3:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl $49, %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE3:
.size _Z9function1ILb1EEcv, .-_Z9function1ILb1EEcv
.text
.globl _Z9function2b
.type _Z9function2b, @function
_Z9function2b:
.LFB1:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl %edi, %eax
movb %al, -4(%rbp)
cmpb $0, -4(%rbp)
je .L6
movl $49, %eax
jmp .L7
.L6:
movl $48, %eax
.L7:
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE1:
.size _Z9function2b, .-_Z9function2b
.ident "Haha no fuck off"
.section .note.GNU-stack,"",@progbits
>>
>>56472761
This.

Even at a small company with few homebrews, I still got handed a website that was outsourced a while back.

It was hilarious at times seeing terms like
>Upgradation
>Authentification
>Destinational
>>
>>56472696
>her
I'm interested, what made you think I'm female?
>>
>>56472964
It's very optimised. It can solve fizzbuzz at compile time as an error message.
>>
>>56472964
meanwhile in Haskell the fact you have a value without IO in its type (that doesn't come from a function with unsafePerform) means you can theoretically have all such values constexpr by default
>>
>>56473047
He does it because he's a faggot. This isn't the first time.
He literally goes out of the way to refer to anons as her, knowing full well they're male.
>>
New thread!
>>56473311
>>
>>56473299
Same for C++ and C.
>>
>>56473299
kys
>>
hey /g/uys
i'm thinking of programming a general media manager.
basically software which manages all kinds of media on your device.
Pictures, videos and so on, supporting tagging and so on.
does something like this exist in a proper form?
are there good media managers which i can use or take a look at?
>>
>>56473371
What makes you assume that everyone in this thread identifies as male?
>>
>>56473495
what makes you assume that people in this thread (besides yourself perhaps) identifies as female?
>>
>>56473428
>same for C++ and C
nope


>>56473495
>identifies as male
I thought trannies thought gender and sex were different
>>
>>56473371
>He
Anon...
>>
>>56473590
>nope
And this is wrong.
>>
>>56473599
you are biologically male. let's call a spade a spade.
>>
>>56473475
I don't know of anything open-source.

Roku seems to do a decent job, considering it's just a harddrive that serves up media.
>>
>>56473632
kill yourself
>>
>>56473695
Why so mad at being called out at your bullshit?
>>
>>56473695
>>56473740
wrong person i thought you were the haskell tard
>>
>>56473632
Haskell
x :: Integer
x = somefunction somevalue
-- somefunction is known not to use "unsafePerformIO"

x can be calculated at compile time

C++
Integer x = somefunction(somevalue);

x cannot be calculated at compile time

>>56473798
Holy shit you're such a little faggot lol
>kill yourself
>w-wrong person sorry
>>
>>56473798
Are you the carposter? I may forgive you if you bow 10 times in front of me.

>>56473859
>x cannot be calculated at compile time
And this is absolutely wrong. Whoever told you this was lying.
>>
>>56473859
You can do that in C++ with templates.
>>
>>56473859
So you can essentially implement non-IO Haskell code as giant LUTs?
>>
>>56473859
you're fucking retarded kill yourself

>x cannot be calculated at compile time
yes it can if it's a constexpr function or if the function doesn't have side effects
>>
>>56473647
that streaming device to tv?
>>
>>56473994
Yeah, a friend had one, and it just sat on a hard drive near the TV and just said "Here's your movies, here's your music, etc." with built in players for everything.
>>
>>56473859
It can be calculated at the compile time. In C, the compiler can do absolutely anything as long as the executable has the same behavior with respect to I/O and volatile objects.
>>
>>56473949
>>56473963
>>56473984
>>56474103

1) Templates (and even constexpr) are extremely limited vs baseline C++ without IO. Template metaprogramming does not resemble the language at all.
2) The point is not "given the compiler also has an attached advanced proof solver and the source code to all the other libraries". Even tagging unsafePerform is already in place via SafeHaskell (with the Safe extension you can't even import unsafePerform)
3) It would be both inefficient and complicated in C++ and C, especially if you also wanted intellisense and IDE style live error checking. In Haskell you just check the type of the expression.

>>56473981
Very giant LUTs, my point was just that if you have a value that isn't IO x (and doesn't use unsafePerform)
>>
>>56474340
kill yourself
>>
>>56474397
>>56474340

sorry wrong person i thought you were the haskell tard
>>
>>56474340
There is a big difference between impossibility and inefficiency of a solution.
>>
>>56474340
>1) Templates (and even constexpr) are extremely limited vs baseline C++ without IO. Template metaprogramming does not resemble the language at all.
I said nothing about templates, please do not reply to me about things that I did not say.

>2) The point is not "given the compiler also has an attached advanced proof solver and the source code to all the other libraries". Even tagging unsafePerform is already in place via SafeHaskell (with the Safe extension you can't even import unsafePerform)
How is this relevant to anything?

>3) It would be both inefficient and complicated in C++ and C, especially if you also wanted intellisense and IDE style live error checking. In Haskell you just check the type of the expression.
What?

Anyhow, as I said, Integer x = somefunction(somevalue); with no changes at all can be done at the compile time if it has no side effects, same as the haskell version.
>>
>>56474458
haskell is trash you delusional retard
>>
>>56473299
>can theoretically
>yet no compiler does it

>that doesn't come from a function with unsafePerform
this is the critical part for why that argument is pointless in the first place.
>>
>>56474656
kill yourself
>>
Oh, and in Haskell Integer is an arbitrary size integer.
That complicates things a great deal for the C++ people.

>>56474586
>I said nothing about templates, please do not reply to me about things that I did not say.
That's awfully selfish, I wasn't just replying to you.

>How is this relevant to anything?
In every way?

>Anyhow, as I said, Integer x = somefunction(somevalue); with no changes at all can be done at the compile time if it has no side effects, same as the haskell version.
SIGNIFICANT changes to the compiler.

>>56474823
>can theoretically
It shouldn't be that complicated, it might even be done.
It would probably be trivial to do. Certainly with regards to KNOWING what can or can't be done at compile time, which was the point. (You can tell from the types in Haskell, not from C++ - constexpr excluded)
Basically, it's like asking "what's the point of constexpr?"

There are issues with stuff like non-termination, but that can be ignored with things like bang patterns (force evaluation, like !x = somefunction value) and the Strict extension

>>that doesn't come from a function with unsafePerform
{-# LANGUAGE Safe #-}
import GHC.IO.Unsafe (unsafePerformIO) -- error, Unsafe is not safe
>>
>>56475107
>That's awfully selfish, I wasn't just replying to you.
You quoted me in the part where you talked about this. It is not about being selfish, it is about you being retarded and quoting things that weren't being said nor claimed by someone you quoted. Something truly terrible.

>In every way?
I can't see how.

>SIGNIFICANT changes to the compiler.
What are you rambling about? When did I say anything about any compiler? And what compiler exactly are you talking about? You are not making any sense.
>>
>>56475256
>You quoted me in the part where you talked about this. It is not about being selfish, it is about you being retarded and quoting things that weren't being said nor claimed by someone you quoted. Something truly terrible.
Maybe you should follow your own advice and reread my post.

>I can't see how.
>What are you rambling about? When did I say anything about any compiler? And what compiler exactly are you talking about? You are not making any sense.

Sorry, it is clear that you have no idea what we are talking about.
>>
>>56475321
>Maybe you should follow your own advice and reread my post.
...what?

>Sorry, it is clear that you have no idea what we are talking about.
Maybe because you are saying things absolutely unrelated to the topic?

The topic was that you claimed that something like Integer x = somefunction(somevalue); can't be evaluated by C++ in compile time if somefunction is pure, which is false. The topic what nothing to do with whatever bullshit you were rambling about.
>>
>>56475107
>It shouldn't be that complicated, it might even be done.
Unlike haskell where "it might be done sometime by an implementation", in implementations for other languages such as C or C++ it is already happening.
>>
>>56470846
>It greets you and sends random NSFW pics and jazz from my computer upon request.

sounds kinky

>There are hundreds of projects that you could clone and fuck with.

I know but there is just so much I don't know where the to start

>What are your interests?

Tech wise I'm kind of interested in making a mod for a game, or maybe my own text adventure.

>What software with interoperability do you use every day?

What mean?
>>
>>56478555
go to new thread, anon, and ask questions there

This thread is ded.

>>56473311
>>
>>56478627
Damn already, thanks anon
Thread posts: 372
Thread images: 30


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