/dpt/ - Daily Programming Thread

Old thread: What are you working on Cred Forums?

Other urls found in this thread:

hackerrank.com/challenges/simple-text-editor
restcountries.eu
doc.rust-lang.org/rustc-serialize/rustc_serialize/json/index.html#using-autoserialization
doc.rust-lang.org/rustc-serialize/rustc_serialize/json/index.html#verbose-example-of-tojson-usage
docs.python.org/3/library/socketserver.html
restcountries.eu/rest/v1/all
dlang.org/phobos/std_algorithm_iteration.html#.reduce
youtube.com/watch?v=4om1rQKPijI
github.com/barosl/homu
catb.org/~esr/faqs/smart-questions.html
composingprograms.com/
isocpp.org/faq
github.com/arkanis/single-header-file-c-libs/blob/master/math_3d.h
github.com/rigtorp/awesome-modern-cpp
gameprogrammingpatterns.com/
gameenginebook.com/
en.cppreference.com/w/cpp/compiler_support
secure.php.net/manual/en/function.is-readable.php
secure.php.net/manual/en/function.file-exists.php
myredditnudes.com/
twitter.com/NSFWRedditImage

Trying to solve this problem on hackerrank:
hackerrank.com/challenges/simple-text-editor

But I'm timing out on test cases w/ 1 million inputs, would love some feedback
on how to speed this up:

import std.conv, std.algorithm, std.string, std.stdio;


void main() {
auto stack = new Stack;
int opCount = to!int(strip(stdin.readln()));
foreach (_; 0 .. opCount) {
string[] inputs = split(strip(stdin.readln()));
int opType = to!int(inputs[0]);
if (opType == 1) {
stack.push(inputs[1]);
} else if (opType == 2) {
stack.pop(to!int(inputs[1]));
} else if (opType == 3) {
(stack.get(to!int(inputs[1])));
} else if (opType == 4) {
stack.undo();
}
}
}


class Stack {
private string data;
private int[] ops;
private string[] deleted;
private size_t[] appended;
this() {
data = [];
}
public void push(string value) {
ops ~= 1;
appended ~= value.length;
data ~= value;
}
public void pop(int i = 1) {
ops ~= 2;
deleted ~= data[$ - i .. $];
data = data[0 .. $ - i];
}
public char get(int charNumber) {
return data[charNumber - 1];
}
public void undo() {
int lastOp = ops[$ - 1];
ops = ops[0 .. $ - 1];
if (lastOp == 1) {
size_t appendLength = appended[$ - 1];
appended = appended[0 .. $ - 1];
data = data[0 .. $ - appendLength];
} else {
string deletedString = deleted[$ - 1];
deleted = deleted[0 .. $ - 1];
data ~= deletedString;
}
}
}

Thank you.

I'm going to potentially add a GUI to my racial slur generator today, and add more functionality.

Is that D?

>racial slur generator
who did bring this idea up?
been browsing too much Cred Forums lately?

Yup - don't hate, I just like to learn new languages.

anime babes are the best...

It was mostly because one user couldn't figure how how to get a list of demonyms, and had only like 20 of them hard-coded.

I wanted to do something with demonyms as a test-case, and this just so happened to be a quick and easy showcase of that. Also, I haven't had much practice with web-scraping, so I did the slur half with that, as I couldn't find an API for racial slurs.

I was planning on showing him source if he showed up again.

i remember an user trying to make a racial slur generator ... he got insulted that his program is "worthy of Cred Forums" afaik :p

> :p
Get the fuck out.

It was worthy of Cred Forums because it was a half-assed piece of shit, not because it had racism.

Cred Forums has always had a culture of light-hearted racist banter.

p:

Just finished a distributed chat server for uni. Java is alright, a bit boring though.

can you show me the source code? how did you implement the demonym list?

so ... why do we need command line arguments again?

It's a fairly simple API pull from restcountries.eu

There's probably a more concise way to do it, so I'll try to clean it up and repost:

var demonyms = new List();

var url = "restcountries.eu/rest/v1/all";
var request = WebRequest.Create(url);

using (Stream s = request.GetResponse().GetResponseStream())
{
using (StreamReader sr = new StreamReader(s))
{
var jsonResponse = sr.ReadToEnd();

var json = JArray.Parse(jsonResponse);

demonyms = json
.Select(x => (string)x["demonym"])
.Where(x => x.Length > 1)
.ToList();
}
}

To pass arguments to your program, of course.
How else do you propose that people do that?

1. start program
2. standard cin / cout ?

Now trying doing that on 300 computers at once.

why do we need arguments to functions?

1. C++ streams are pure trash, as is the rest of the language. It's stdin. stdout, and stderr or file descriptor 0, 1 and 2 if you want to be "Unix-y".
2. It's a pain in the ass
3. Many programs use stdin/stdout for other purposes.

Here's a shorter version that works just as well:
var demonyms = new List();

var url = "restcountries.eu/rest/v1/all";

using (var client = new HttpClient())
{
var response = await client.GetAsync(url);
var result = await response.Content.ReadAsStringAsync();
var json = JArray.Parse(result);

demonyms = json
.Select(x => (string)x["demonym"])
.Where(x => x.Length > 1)
.ToList();
}

>more and more programming tutorials in fucking HINDI, with comments in HINDI

makes you think...

What's the best way to set up a project so it can be easily built on both Windows and Linux?

Depends on the language.

cmake

Build it on Mono.

I'm not entirely sure what you're asking. It depends on what you're doing and the language.

You don't even need functions, look at register machines, they can do anything your precious functions can.

Describe running gcc -Wall -pedantic -o foo foo.c -l bar with this cin/cout method

C and a scheme

I'm not using .NET though

*cries*

No idea about scheme but if your C program is small you could just do a unitybuild.

>open document
>300 lines of code are commented out

What should I do? Just delete it? This code probably hasn't been run in years, surely no one needs it.

Stick that shit in your vcs w/ a tag in case you ever need it first.

if you want to get fired sure just delete it

It is already in version control, so we could go back and grab whatever piece we need, I would think.

>This code probably hasn't been run in years
>probably
How about your lazy ass checks when it was commented out?

Two years and two months ago.

What's the best way to compile a c++ programming using g++ I was using -o2 is that good?

I think using g++ is a very good idea.

>best way to compile a c++ programming
just end it

can someone explain me why the fuck this isnt a statement?

-O2 -std=c++14 -pedantic-errors

You put the verb first and ended it with a question mark, so it's a question, not a statement.

-Wall -Werror

try surrounding it with { and }

Missing braces

You cold go the save route and talk to whoever commented it out, but 2y and 2m seems pretty save to delete.

kek

This is exactly why you should almost always use braces on every control statement.

>talk to whoever commented it out
They got fired.

Fuck it, I'm going to put it on a text file with an undescriptive name and stick it somewhere deep and dark on the NAS.

How is Ubuntu so cucked? It has Eclipse 3.8 in the repository while the latest version is 4.6 or something. This distro is the worst.

Nobody ever said Ubuntu packages would be bleeding edge.

If you wanted bleeding edge then you should have chosen a different distro.

Only a handful of packages are maintained by Ubuntu developers. The rest is synchronized periodically from Debian, every 6 months.
But the jump from 3.8 to 4.6 seems huge even for 6 months, anyone know what version the debian package manager is on?

Why don't you check yourself?

do i really need to master linked lists in c++, if i am not a game developer?

i cannot think of a situation where i have to add an object into an array of a million objects with high performance

It's like you retards don't even know duckduckgo !bang patterns exists. You could have found the answer by searching "!dpkg eclipse"...

Linked lists are a fundamental data structure that is used in implementing other, more advanced data structures.
Also, linked lists actually have pretty terrible performance.

I actually didn't know, thanks.

Yes user.

It's not even that you'll need to use linked lists, it's that if you don't understand them your going to be in trouble when it comes to understanding more complex structures.

What RTOS would you recommend me for AVR microcontrollers, Cred Forums?

>Linked list
>Game development
Kek.
If you use a linked list in game development nobody is gonna hire you.

In game development iteration speed is much, much, much more important than random access or insertions.
The cost for cache misses is just way to high so you want to store your data as closely together as possible.

Games almost exclusively use arrays and hashmaps.

Why is every programming language so shit?

because the internet says so for every language in existence

how can i make a custom type project in an IDE?

so every time i make a new project, several things are already pre-set

Don't use an IDE.

gimme dat

>putting anime references in programming books
ISHYGDDT

>an IDE
You select the option for making custom project types.

>Spic
No surprises there. They're the biggest fucking weebs.

doc.rust-lang.org/rustc-serialize/rustc_serialize/json/index.html#using-autoserialization
doc.rust-lang.org/rustc-serialize/rustc_serialize/json/index.html#verbose-example-of-tojson-usage

As a massive fucking weeb I'm asking you people please learn to hide your powerlevels.

are switches in c++ only possible with integers?

I swear, in 10 years there's going to be fucking touhou on o'reilly's books

starting to fall for go

Integers and chars.

A char is an integer.

Is anyone familiar with yon-chan? I can't figure out how to open a thread.

and enums (which are also ints actually)

Anything that can be cast into int, so also enums and chars. But I haven't used c++ in years so things might've changed.

I'm retarded.

I have a list of elements, pic related.

Whats the easiest way to find the min and max Top values? I'm new to C# and programming in general.

Using reinterpret cast you can turn anything in an integer.

just do a for loop and check

Fundamentally, everything is an integer.
>reinterpret cast
Dumb sepples fag.

Integrating django-wiki into a mezzanine site. Will eventually make a "choose your own adventure" app that describes various structures an organization can adopt, letting you pick an option for each structure. The end goal is to make the adventure app automatically create wiki pages.

elements.Max();
elements.Min();

init max var to the maximum value of the type and min var to the minimum. Loop through elements, check the Top against max & min, setting them if they are bigger/smaller.

Sorry, I'm retarded and jumped the gun responding.

Are you wanting to retrieve just the value or the whole element struct that has that max/min value?

>Restricting the amount of features I can use makes me superior.
Whatever makes you sleep at night.

>Fundamentally, everything is an integer.
Fundamentally, everything can be anything.

What would be a more elegant solution to this ubiquitous programming problem?

The user has to choose between a set of options.

cout input;

switch (input) {
case 0: datatype = "Celsius"; break;
case 1: datatype = "Kelvin"; break;
case 2: datatype = "Fahrenheit"; break;
default: cout

Any recommendations on how to get into network programming? I was thinking maybe something like a simple chat protocol/server/client? Too high-level?

struct Element
{
public string Text;
public int Left;
public int Top;

public Element(int inLeft, int inTop, string inText)
{
Text = inText;
Left = inLeft;
Top = inTop;
}
}

static void Test()
{
var elementList = new List();
elementList.Add(new Element(3, 5, "poo"));
elementList.Add(new Element(1, 2, "loo"));
elementList.Add(new Element(4, 69, "paj"));
elementList.Add(new Element(7, 7, "eet"));

// get max Top value
var maxTopValue = elementList.Select(x => x.Top).Max();

// get Element with the maximum Top value
var maxTopElement = elementList.Aggregate((x1, x2) => x1.Top > x2.Top ? x1 : x2);

// get Element with the maximum Top value (less obfuscated method)
var max = elementList.Max(x => x.Top); // get max value
var item = elementList.First(x => x.Top == max); // get the first element with this value
}

you could avoid the whole switch block by doing
cout

thanks, but please consider I also have to

1. make the user enter a number, instead of the full name of the measurement
2. set a variable to that particular measurement

docs.python.org/3/library/socketserver.html

The user-friendly solution is to evaluate potential misspellings of the actual words and confirm with the user if the system isn't confident in what they meant to type.

Not OP, but is it possible to have multiple reduce functions, so you can calculate the max & min with just one pass?

Thanks, is a simple chat server/client a decent starting project?

I'd prefer a compiled, statically typed language, but Python seems like a good way to slowly wade into the pool.

Also, any decent book recommendations?

>restcountries.eu/rest/v1/all
LINQ is so based.

I'm trying to make a buffer for my game. I want to store screen stuff in elements.

New Game[N]
Load Game[L]
Exit Game[E]

Would be examples of elements, cursor positions are a vector2 x,y position.

What I'm trying to do is take in a list of elements from a screen class.

Have an array of strings thats equal to writing area in the screen size, right now thats

string[] firstBuffer = new string[Window.Height - 2] this is because I want 1 line above and below off limits so the screen doesn't write past its buffer ever.

I want to take every element that shares the same y value and concatenate them while still preserving their respective x positions filling the empty space with " ".

Then I want to have a final buffer that is just a string that concatenates every string in the array to one long string with "\n" in between the concatenations.

Then I can just Console.Write(finalBuffer);

Console.Write/Writeline are slow and cause flickering and shit if you try and just loop and print stuff. Dumping everything in one string solves the problem from what I've seen.

I'm going to have another layer that prints colored elements individually over the other buffer since you have to do separate Write() calls for each color.

I'll look into that fancy syntax you're using.

rolling for real

Can someone please hook me up with a good mobile app idea I can use to make some good boy points?

dumb frogposter

what are good boy points

he meant good goy points, typo

Make 2 whack-a-mole apps, one w/ trump's face, the other will hillary's. Make cash money off both sides.

I'm toying with this now. Not sure how to send two values into the next iteration within LINQ.

Maybe you'd need one additional "holder" variable.

Escape bag app where you are the only user, dumb frogposter.

What would be the best way to monetize small, simple games like this? F2P and donations? Small fixed price?

What's the best practice for gathering pictures, in this case shillary and trump pictures, to not get buttfucked over copyrights?

int[8][2] *measurements = new int[8][2];


Is this how it works?
I want to declare a multi-dimensional array with a pointer.

D does this nicely:
auto results = reduce!(min, max)(myArray);

Never posted code before, so sorry if I fuck up but I have a question.

In c# when creating instances of an object why would you declare it as the base class instead of just having everything be the subclass that you are using?

Polygon polygon1 = new Square(4.5f);
Square square1 = new Square(4.5f);


If I'm gonna have a square then shouldn't I just do line 2? They seem to work the same, but tuts I'm following seem to always do line one.

few simple ideas:
- tick tack toe
- chat
- file transfer with directory browsing and listing

Don't fuck w/ C#, but the first line probably allows you to pass the object to functions that take any Polygon while the second only lets you pass it to functions that take a Square.

Thanks user

Same thing in Java. If you want to change the implementation at some point, you can change from square to circle or whatever if you declare it as a superclass.

Some functions might require the superclass object to be passed as a parameter instead of a subclass.

If you declare the object as a subclass, you're stuck with it.

Here's what I came up with, uses only one pass:
var minTopElement = elementList.First();
var maxTopElement = elementList.Aggregate((x1, x2) =>
{
minTopElement = minTopElement.Top < x2.Top ? minTopElement : x2;
return x1.Top > x2.Top ? x1 : x2;
});

Keep in mind that this is not the min/max of a single-dimensional array. This is a list of objects containing properties that is being evaluated. Your code is not equivalent.

This helps. Thanks user.

nice. really haven't kept up with c#. has that stuff always been there?

For nearly a decade.

These things were added in C# 3.0 IIRC, which was around 2007.

Good point
auto results = reduce!((x1, x2) => x1.top < x2.top ? x1 : x2,
(x1, x2) => x1.top > x2.top ? x1 : x2)(myArray);

I'm 60% sure that this does two passes over the collection.

False
dlang.org/phobos/std_algorithm_iteration.html#.reduce
> Sometimes it is very useful to compute multiple aggregates in one pass.
> That's why reduce accepts multiple functions.

i think that's around the time i checked out

map measurements;
map ::iterator itr;
measurements ["Celsius"] = temperature;
measurements ["Kelvin"] = temperature - 273.15;
measurements ["Fahrenheit"] = ( temperature * (9/5) ) + 32;

for (itr = measurements.begin(); itr != measurements.end(); ++itr ) {
cout

Neat.

I know this is a moot point, but if I really just wanted to go for brevity of my own code, I'd NuGet in that package that lets you just write a one-liner to reduce by a property, or even just write my own extension method that does the work so I can just do elementList.MinAndMaxBy(property); or something like that.

I feel like it's pointless to dickmeasure on things as trivial as this, because it's not like it has to be written more than once before you just abstract it.

Who AA coodaus (Aku Ankka coodi) here?
Cr-peli. Peli name: Akun suuri seikkailu. Taso 1: ankkalinna. viholliset-ei koko: 999 mega,t Pää bos-kyllä. Pää bos kestävyys: 9.

gcc

shut the fuck up with your modern terms for made up bullshit, communist

C# sucked cock in those days.

I'm honestly still having trouble understanding how it could start so horribly and be so good in modern times.

Is that Finnish or Estonian?

this started playing in my mind instantly
youtube.com/watch?v=4om1rQKPijI

Well?

second one is a complete waste of space, especially if there's only 1 statement after the conditional.
>inb4 meh when there's only 1 statement don't use curlies at all
fuck off and die pls

Anyone have a "coding" bootcamp they had to attend at university?

>tfw literally getting confused on Java making circles go in different directions

I'm fucked.

I just don't do well with visual/graphical stuff. Give me numbers and fucking code not shapes and (((draw))) methods.

Go with whatever the consensus is in that language.

I prefer the second one for readability, but I'm more than willing to use the first if that's the style-choice of the language or project I'm contributing to.

if (true)
{
// stuff
}

This. Being flexible > obeying a single style.

IDE for C++ on a mac?

what is the best way to make a menu in c++?

cin >> input;

switch (input)

case 1 : ...
case 2 : ...
default : ...

}


are switches the best method, or is there a better one?

if (true)
{
//stuff
}
[/code

if
(
true
)
{
//stuff
}

if (((true)))
{
// stuff
}

>fell for the boolean jew

As a starter, if I haven't learnt C in how many days should I give up on programming

anyone?

How do you define a constant for a type in Haskell?

Like you have a board and want to make an initial board.

is this correct:?

ChessBoard a = [ [Rows] ] | EmptyBoard | InitBoard
EmptyBoard = -- make everything 0 for instance
initboad = -- do first two rows all white objects, last two rows all black objects

is that how you create constant types?

about 3.5 hours

I thought pic related said sexualize instead of serialize.

Sexualize the homura

That does not include study breaks for more efficient information processing and general procrastination, then it's doable

how old are you and what do you need it for?

>Sexualize the homura
Method threw 'InvalidOperationException'

21, little games while it's just C

>study breaks
read perky breasts

>procrastination
read penetration


ill take a braek

>github.com/barosl/homu
Can't get more weeb than Rust.

You need more than a break mr Freud

Depends on your previous programming experience and time to spare. Assuming you don't have any experience, it might take you two weeks, maybe a month, or even half a year if you don't have that much free time.
It's hard to tell. I've learned C in my summer vacation in the 5th grade.

Did anyone here go to study CS/software engineering at university without previous coding knowledge?

I'm new to Java (and OOP in general) with some background in C.
I could use some advice on Java error handling

I have a method whose constructor parses a string, and expects a string with 5 comma seperated values.

what should i do if the string is invalid?
should i throw an illegalArgumentException?
should i return an error value like C?

what's the tl;dr of handling bad arguments in Java? just some quick notes would be extremely appreciated.

Exceptions in java cost a lot of power/resources afaik, so you should try to avoid them in performance critical functions

>without previous coding knowledge?
You gotta know SOMETHING about programming if you choose to take CS/SE or even just intro courses yourself. Technically you don't have to know a damn thing because professors and schools have to cover their ass curriculum-wise if people wander in from other majors or undecided tracks but you won't last long if you don't have any investment in programming.

Yes?

funny, because exceptions in c++ have pretty little overhead afaik

Normally i would 100% agree, but this is for a second year programming class where the marks are HEAVILY weighted towards reusability, error handling, and design. Performance is actually very, very low priority.

what methods would you suggest for handling bad arguments?

people without any prior knowledge get into CS/SE all the time because muh good paying job.

I always forget about those people.

>this is for a second year programming class
err I think I mightve oversold myself
t. started programming java this summer

Yeah I've used C# in college(UK) so its strange using Java now at Uni.

Any tips on getting by the first year?

Read the god damn textbook. Holy shit, READ THE FUCKING TEXTBOOK. Actually talk to your professor if you have any questions, and don't do some "uh profesuh m8 this scanner class stuff aint fukken mint" garbage either, ask a question based on the information here: catb.org/~esr/faqs/smart-questions.html

Don't be the class smart-ass who sits in the back because he has experience with a programming language before, and don't be the same smart-ass who sits in the front and interrupts constantly with trivial bullshit about how you read on the internet that [x] is a "baby language" or stupid shit like that. Also, try to get on good terms with your professors and see if you "click" with them. If you like them, try to develop a professional relationship with them because that's the perfect time to learn how to. If you don't click with them on a personal level, just be polite and sociable (yeah yeah look at where we are, etc) and they'll respond in kind and be much more willing to help you.

What do you mean a "constant type"?
You just use a regular value
Everything's immutable

data Chessboard a = Chessboard { rows :: [[a]] }

emptyBoard = Chessboard []
initBoard = [ [ ... ], [ ... ], ..., [...], [...] ]

whoops, I guess you meant unoccupied was part of the element type
emptyBoard = Chessboard (replicate 8 (replicate 8 Empty))

>t. started programming java this summer

You're using t. wrong you inbred yokel.

Just don't use memes unless you know what the fuck they mean, newfag.

For the record, how do I use this meme without creating an exception?

What did people do before C++11 came out to model a pair or map?

With a pair, I can't save a value with a name (key). There is no way to model the same thing with classes.

It's basically "signed".

Not sure what you mean - both std::pair and std::map existed pre-c++11 and you could use a struct to make a pair, just a bit uglier...

template
struct Pair
{
T first;
U second;

Pair(T first, U second): first(first), second(second)
{
}
};

Pair something()
{
return Pair("asdf", 5);
}

vs.
std::pair something()
{
return {"asdf", 5};
}

template
struct pair {
a fst;
b snd;
}

Magic.

t. is short for the Finnish word terveiset, which in English is "regards."

It's not a Cred Forums "meme", by the way. You'd have to have been part of a certain community to actually understand the usage properly, but t. (self-deprecation like "babby" or "newfag") is kind of acceptable usage when attached to initial entry-level question posts. Another instance would be the common "t. knower" which is exactly what it sounds like. You're not supposed to use it constantly.

O-oh, thanks.

But would I also be able to access "second" by naming first?

As in
Value = pair ["key"]

?

That makes no sense but you could overload the operator to do so if you really wanted to.

template
v& operator [](map, k key) {
for (auto& kv : data)
if (kv.fst == key) then
return kv.snd;
}

>muh you need to write "someone who" there
>t. autism

Let's assume a scenario, where the user is asked for a key and the program returns the corresponding value.

How'd you do that outside of pairs and maps? Would you run through all your custom-created classes and drag the one out where "key = input"? That takes a lot of time.

(Noob question, I know.)

lurk more

Not like almost everyone uses it like I did and you sperged out as if you only knew about it from kym

data structures and algorithms

Before C++11 something like this would work:
typedef std::pair MuhPair;
std::vector data;
// fill the data

std::string input;
do {
fprintf(stdout, "key pls\n");
std::cin >> input;
} while(!input.size());

for (const MuhPair &pair: data) {
if (pair.first == input) {
fprintf(stdout, "%d\n", pair.second);
break
}
}

>implying i'm this retard
You still need to lurk more because you and are wrong

got it thx!

So I have to learn basics first to solve such tasks... K, thanks, won't ask superfluous questions again.

I'll study these, thank you.

Actually never mind because there were no for-ranged loops so you wuold have to use iterators but still.

>be on github for a year
>no recruiter emails
>check my profile
>i forgot to set a public email address

Yeah, but it'd be applicable today.

>implying that was the cause

which c math library to use for opengl stuff?

That's actually a neat tool.

if (((true)))
{
// stuff
}
Much more readable now.

(if then else)

if
(
true
)
{
//stuff
}

like dis
function foo(bar)
{
if (bar)
{
// stuff
}
}

Reading this: composingprograms.com/
Thank you Akarin!

if
(
true
)
{
// stuff
}

>fp section
>it's just lisp

who would've thought that the sicp successor uses lisp

jelly 'skell-ee?

Yeah, I thought it was meant to be about programming

Post special snowflake FizzBuzz from your language.

Here's some C# LINQ.

Enumerable.Range(1, 100)
.Select(x => x % 15 == 0 ? "FizzBuzz" : x % 5 == 0 ? "Buzz" : x % 3 == 0 ? "Fizz" : x.ToString())
.ToList()
.ForEach(Console.WriteLine);

Has anyone used Soot in Java?

disp x =
case (x `mod` 3, x `mod` 5) of
(0,0) -> "FizzBuzz"
(0,_) -> "Fizz"
(_,0) -> "Buzz"
(_,_) -> show x

main = [1..100] `forM_` (putStrLn . disp)

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100

ul{
list-style-type:none;
}
li:nth-child(3n), li:nth-child(5n){
font-size:0px;
}

li:nth-child(3n):before{
font-size:16px;
content:"Fizz";
}
li:nth-child(5n):after{
font-size:16px;
content:"Buzz";
}

has science gone too far?

is R a language?

private static void FizzBuzz(int bignumberz)
{
var bignumber = bignumberz; string FizzBuzz = "FizzBuzz"; int qwer = -~new int() * bignumber; int? asdf = null; int zxcv = FizzBuzz.IndexOf((FizzBuzz.ToCharArray())[2]); var uiop = Enumerable.Range(1, bignumber * -~new int()); string fz = "Fizz"; string bz = "Buzz"; foreach (char x in FizzBuzz) { if (FizzBuzz.IndexOf(x) == -~-~new int()) { asdf = FizzBuzz.IndexOf(x) + -~new int(); } if (FizzBuzz.IndexOf(x) == -~-~-~-~-~new int()) { zxcv = FizzBuzz.IndexOf(x); } } foreach (var ayy in uiop) { if ((ayy % asdf == -~new int() - 1) && (ayy % (asdf * zxcv) != -~new int() - 1)) { WriteLine(fz); } else if (ayy % zxcv == 0 && (ayy % (asdf * zxcv) != -~-~-~-~-~-~new int() - 6)) { WriteLine(bz); } else if (ayy % (asdf * zxcv) == - ~ - ~ - ~ - ~ - ~ - ~-~-~-~ -~-~-~-~-~-~-~-~- ~-~-~-~- ~-~-~new int() - -~-~-~-~ -~-~-~- ~-~-~-~-~-~- ~-~-~-~ -~-~-~-~-~- ~-~new int()) { WriteLine(fz + bz); } else { WriteLine(ayy); } }
}

For every integer x in the range [1, 100]
If x is divisible by 3, print "Fizz"
If x is divisible by 5, print "Buzz"
If x is divisible by neither 3 nor 5, print x

...

Say, I'd like to relearn modern C++ - what resource /dpt/ recommends?

...

Any book using C++14. Ideally, C++17.

isocpp.org/faq

scott meyer

So there is this single header math library for C.
github.com/arkanis/single-header-file-c-libs/blob/master/math_3d.h

If I have
main.c
#include "math_3d.h"
int main(void) { vec3_t x = vec3(0.0f, 0.0f, 0.0f); return 0; }

It compiles and runs ok.
So then I run another function from it.
#include "math_3d.h"
int main(void) {
mat4_t x = m4_perspective(
0.0f,
0.0f,
0.0f,
0.0f
);
return 0;
}

And I get get linker error undefined reference to m4_perspective.
Why would that be?
Compiling with
cc -lm main.c -o exe

github.com/rigtorp/awesome-modern-cpp

>Ideally, C++17.
are there even any out there yet?

dunno

I want to learn to program better.

I currently am pretty good at C, but OO is a struggle that I'm trying to pick up.

My main desires are to program iPhone apps and program games.

For now I'm going to settle on games. Now I'm not jumping up and down saying "how do I make COD" or whatever it is people play nowadays. I know that my first games will be simple 2D affairs.

But actually, I'm looking for resources that don't focus on the graphics, but teach more about game logic, maybe with very simple graphics included.

Anyone recommend a course or book on that?

OO is bad

>should i throw an illegalArgumentException?
This seems most reasonable to me. Exceptions are cleaner than error values in most cases.

anyone here know how to allow user input on a combo box? I am trying to have it so when the enter key is pressed it adds data to the combo box.

This is in visual basic

I don't know C but after taking a glance at the code I assume you have to add this:
#define MATH_3D_IMPLEMENTATION

Before including math_3d.h header.

>states opinion
>no facts or studies to back it up

gameprogrammingpatterns.com/
gameenginebook.com/
I don't know more resources but those should get you started.

Furthermore it even says so in the top comment:
>It's an stb style single header file library. Define MATH_3D_IMPLEMENTATION
before you include this file in *one* C file to create the implementation.

>>denies membership to cult
>>no facts or studies to justify his heresy

Thanks matey

k, thanks. I think I'll wait for C++17 as it isn't anything urgent for me now, just my whim.

well fuck...

rolling for real [unless its hard or takes long]

seems you're lucky

There seems to be some support
en.cppreference.com/w/cpp/compiler_support

Not that guy, but curious about learning the whole shebang of making games. That's a good resource, but what would I do for a graphics system?

Fuck you C, I'm learning another programming language.

You'd use an existing engine, because rolling your own results in you never actually making a game.

>he fell for the "learn C" meme

So Unity?

I'm looking at iOS dev and wondering what scenekit offers?

What exactly is bothering you about it?

SceneKit sounds like some bullshit.

Just use Unity and tick the iOS targetting pack when you're installing it. You can just immediately make a build for iOS right out of the box then.

Seems a bit overkill for the types of games I'll be making though? I'm thinking I'll be doing basic 2D side-scrollers etc?

Unity is very good for basic 2D games.

>So Unity?
I'd rather use Unreal, but use the one that fits you more.

Not particularly overkill.

Depends what languages you already know.

If you want to learn (or already know) Objective-C and want to put in a whole heap of extra work to make an actual functional game, then sure go right ahead with what I imagine isn't a particularly performant API that was never designed specifically for making games.

Alternatively, you could just use Unity.

I feel like it's stupid language to learn in 2016. I've understood that C++ can do everything same that C but with classes and so on. I'm feeling like even Go is better language to learn nowadays.

Haskell question!
Gotta make a tictactoe game where I have a nested triple tuple. The three tuples are the rows:

( ( , , ) , ( , , ) , ( , , ) )

Now I want to split them into different tuples and make a list of it based on the X mark like this:

( ( , , X ) , ( X , , ) , (X , , ) )

visualised:

| | X
X | |
X | |


I want to split each X into its own tuple:

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

visualised:
list:

[

| | X | | | |
| | X | | | |
| | , | | , X | |

]

Any help please?

Unity is a lot friendlier. And also, it's cheaper if releasing games with it.

I know C. And have a rough idea of how C#/Java works.
As I'm still learning, I'd prefer to learn Swift, instead of Objective-C. I know there's huge support for Objective-C as is, but by the time I get to a stage where I'll be any good, it'll tend to be more legacy things using Obj-C.

Are you sure you want to be using a tuple?

ah fuck the visualisation is fucked i'll paint

why

use code tags, and I might consider reading your post.

>2016
>learning C

>Nested tuple

I don't even know anything about Haskell and that seems entirely wrong even to me.

yes we have to use a triple tuple for this practical

Well ok, I'm still confused by your explanation

You want to turn the board of many Xs into a list of grids consisting of only 1 X?
Why not just their positions?

have you ever heard of linked lists user

I've seen worse.

gotta make potential moves/gamestates based on possible moves (denoted by the X)

check my drawing here for visualisation: Thats why im having such a hard time, but we gotta use this shit :(

>You want to turn the board of many Xs into a list of grids consisting of only 1 X?
yes

>Why not just their positions?
I have made a workaround to acces tuples per indices, but that's the bitchy part. Its hard to manipulate tuples based on index.

Thats why i gotta use this shit so i can IMPOSE each element in my list with the current state of the board and thus create a list of potential board states. I really dont know how else i'd do it.

def cons(x, y):
return lambda m: m(x, y)

def car(pair):
return pair(lambda x, y: x)

def cdr(pair):
return pair(lambda x, y: y)


>python

man fuck python it will only take me 100 times as many lines to write a singly linked list in my favorite language

>gotta make potential moves/gamestates based on possible moves (denoted by the X)
Shouldn't you be turning blank spots into X's then?

explain pls

The tuple thing is really awkward desu

it's like the procedures in sicp that implement a linked list

cons pairs up two things, car extracts the first one, cdr the second one

it uses some lambda and function tricks to store the values and retrieve them

if you trace through the calls you'll see it

>turning blank spots into X's then?
I already did in the first grid (with the three X's). I then split them to each their own grid (see the 3 grids in the list), and then I impose each one of them on the original/current board (didnt draw that one) to create a list of potential board states.

fuck it ill hardcode it by making a function with 9 cases that splits them or something. That should do it i think. Its ugly but whatever.
Thx anyway

it's called lambda calculus you'll get more when you search for that instead

Oh I get it. I was misreading cons return value.

Hmmmm

Would it be accurate to say cons returns a closure?

any of you ever done a google interview?

>can download all of a threads posts
>allows you to view a threads images and download them by clicking on them
>also allows you to download them all at once
D-did I actually code something semi useful /dpt/?

there is nothing here worth saving

0-vanned in 3.4 seconds

This can be abstracted a bit, and you'll have to add the `O` mark:

data Mark = X | None deriving (Show)
type Row = (Mark, Mark, Mark)
type Grid = (Row, Row, Row)


first (m, _, _) = m
second (_, m, _) = m
third (_, _, m) = m


initialGrid :: Grid
initialGrid =
(initialRow, initialRow, initialRow)
where initialRow = (None, None, None)

type RowIndex = Int
type ColumnIndex = Int
type Position = (RowIndex, ColumnIndex)

nextMoveGrids :: Grid -> [Grid]
nextMoveGrids currentGrid =
map (makeMove initialGrid) $ getPossibleMoves currentGrid

makeMove :: Grid -> Position -> Grid
makeMove grid (1, col) =
( makeRowMove col (first grid)
, second grid
, third grid )
makeMove grid (2, col) =
( first grid
, makeRowMove col (second grid)
, third grid )
makeMove grid (3, col) =
( first grid
, second grid
, makeRowMove col (third grid) )
makeMove grid _ = grid


makeRowMove :: ColumnIndex -> Row -> Row
makeRowMove 1 (_, y, z) = (X, y, z)
makeRowMove 2 (y, _, z) = (y, X, z)
makeRowMove 3 (y, z, _) = (y, z, X)
makeRowMove _ row = row


getPossibleMoves :: Grid -> [Position]
getPossibleMoves grid =
getPossibleColumns 1 (first grid) ++
getPossibleColumns 2 (second grid) ++
getPossibleColumns 3 (third grid)

getPossibleColumns :: RowIndex -> Row -> [Position]
getPossibleColumns rowIndex row =
markToPosition 1 (first row) ++
markToPosition 2 (second row) ++
markToPosition 3 (third row)
where markToPosition :: ColumnIndex -> Mark -> [Position]
markToPosition column mark =
if isTaken mark then [] else [(rowIndex, column)]


isTaken :: Mark -> Bool
isTaken None = False
isTaken _ = True

?

λ: nextMoveGrids initialGrid
[
((X,None,None),(None,None,None),(None,None,None)),
((None,X,None),(None,None,None),(None,None,None)),
((None,None,X),(None,None,None),(None,None,None)),
((None,None,None),(X,None,None),(None,None,None)),
((None,None,None),(None,X,None),(None,None,None)),
((None,None,None),(None,None,X),(None,None,None)),
((None,None,None),(None,None,None),(X,None,None)),
((None,None,None),(None,None,None),(None,X,None)),
((None,None,None),(None,None,None),(None,None,X))
]

thx m8, should help!

If, rather than using sockets and the socket.io library which seems to largely malfunction every time I use it, I used a plain 'ol piece of javascript to request new messages in a chat room every 5 - 10 seconds, wouldn't that make building a chat room pretty dang easy?

It'll be pointlessly heavy on your server if there's a bunch of people just idling. And there might be a flood of messages every X seconds instead of a natural flow.

>socket.io
this is a very popular library so it seems unlikely that the fault is there. have you checked their slack? seems well populated

I had used it a few years ago and noticed that my applications always defaulted to the fallback which was, iirc, long polling. my console was chock-full of poll requests

How do you deal with reconnecting people who've disconnected in network (internet) applications?

Do you write a piece of code on the client side that simply attempts to reconnect to some sort of saved session/lobby/connection?

Let's say I lose internet for 20 seconds. Do I simply pause both the client and server until the client reconnects?

I am getting Visual Studio 2015 Enterprise Edition Update 1 installed on a lab machine for research shit. Not the most fun of development environments, but umm... Windows Kernel debugging. Yeah...

>Enterprise Edition

I actually think VS is decent. plsnobully

Should I use MVC?

Visual Studio is actually great, imo

Nothing wrong with long polling. It's what facebook uses for their chats for example.

>one webdev class required for cs degree
>class about making websites
>first assignment is to make a website in html5/css
>make beautiful layout, check requirements for what's left to do
>literally every single html and css feature is required to be on the website
>my perfect layout is reduced to trash
>3 hours of work and design down the drain

fuck I hate web dev

Yep VS is amazing but >Windows Kernel debugging.
Good luck buddy...

>literally every single html and css feature is required to be on the website
I had an assignment like that in my intro to web dev class. It was a shitty assignment that consisted of me throwing everything into a single page.

>literally every single html and css feature is required to be on the website

depends on the application, in a game server you shouldn't wait, or pause.
when this one client's info is needed for other connections (like undistributed blockchains) you have to wait and pause.

It's inefficient. If you don't care about IE

You haven't even licked the surface of the shit-sea that is webdev.
Oh bu hu you had a garbage assignment that you didn't even bother to read.
You don't get to complain until you have worked on meme "web app" for retarded blind monkeys that uses at least 17 front end frameworks, java applets, flash and a mixture of PHP and rails for the backend.

>>literally every single html and css feature is required to be on the website

>one programming class required for cs degree
>class about making programs
>first assignment is to make a program in java
>make beautiful fizzbuzz, check requirements for what's left to do
>literally have to use OO, GUI and networking
>my perfect fizzbuzz is reduced to trash
>3 hours of work and design down the drain

In all seriousness though, it's funny seeing all the extra shit IT students have to do in a simple program because they're using Java

>GUI networked fizzbuzz

Captcha was my area code

Yes, that is correct. The university's paying for it, so I'm not complaining.

I rather dislike Visual Studio. It's a pain in the ass to navigate, and I'm used to doing everything via command line, so I hate having that shit abstracted away. That said, if I'm going to be working in Microsoft's kernel space, I'm going to be using Microsoft's toolset.

Read requirements before opening text editor.

edit
options
fizz
buzz

If I ever get around to hosting a Cred Forums community OSS project it's gonna be this.

wow thats crazy what a coincidence

Rewriting the linux kernel in fizzbuzz

>blockchain based fizzbuzz

>coincedence

>read requirements before opening text editor
the point was to teach me about html and css and I learned way more about them from designing a good website than I did by making the trash he wanted.

I've made this actually, there's now a fizzbuzz contract on the ethereum test network somewhere.

>watching chinktoons when you're old enough to be on this websi--
wait a minute.

>fizzbuzz based cryptocurrency.

No the point was to dance like a good monkey so you can get a piece of paper from an accredited university. You're gonna have to actually learn how to apply the stuff yourself. That's nothing to complain about, it's just how it is.

Why didn't you just append the new features at the end?

This. Self development is important etc. but don't forget your priorities. Which is getting your job done in time and getting a signature on a paper.
No one's gonna care about your grades, but rather when, and if you graduated at all.

I tried my best, but I mean it needed EVERY feature. That includes background colors with hex, rgb, and color names.

Doesn't matter. Read the fucking requirements document front to back before you start coding. If you want a good grade, do as instructed.

how do i go about proving this grammar is unambiguous?

S -> ST | T
T -> xTy | xy

i read the entire chapter of the book and it says nothing about proving something's unambiguous

Draw it as a state machine. Observe how every state only has one output. Alternatively use state diagrams etc.

What do you mean unambiguous?

this seems promising, will do. are all unambiguous grammars convertible into an FSM? is the reason CFG's are more powerful than FSM's because of languages which require ambiguous grammars?
only 1 parse tree per string

My book never talked about this either, so I assumed the class wasn't as rigorous, so I just handwaved drawing a parse tree and saying there were no others. If I wanted to be more rigorous, I would talk about not being able to turn one nonterminal into two nonterminals of the same name. I haven't received the homework yet, so I can't really tell you how that turned out. My school also doesn't seem to be too difficult, so as long as I do better work than most retards I feel fine.

>GUI for racial slur generator
Why?
Oh wait, that font rendering is ClearType. You're on Windows.

update: i still don't get it

What's it written in?
post sores.

Sorry senpai that's all I got, it's been too long since I took those classes.

I'm trying to use PHP's "is_readable" function AND "file_exists", but they return 100% FALSE.
Nothing I do makes them return TRUE.
The file DOES exist, and even the exact path I'm passing will link the image for display.
But it doesn't EXIST and cannot BE READ. Although it CAN be displayed.
What the fuck?
echo "";
echo "Does this image exist? $_SiteVar[BASELINK]media/user/7c713a272e4ac63e8274f29ade920beb0f70712d.jpg "; //Works. It's a nice picture
if(is_readable("$_SiteVar[BASELINK]media/user/7c713a272e4ac63e8274f29ade920beb0f70712d.jpg")){
echo "YESS!! ";
}else{
echo "NOOOOO ";
}//NEVER works. Returns a fucking blank

secure.php.net/manual/en/function.is-readable.php
secure.php.net/manual/en/function.file-exists.php
read you're docs

NEW THREAD!

what lang is this?