/dpt/ - Daily Programming Thread

Old thread: What are you working on, Sup Forums?

Other urls found in this thread:

msdn.microsoft.com/en-us/library/1h3swy84.aspx
youtube.com/watch?v=QwygwfqOHsI
ccs.neu.edu/home/matthias/HtDP2e/
en.m.wikipedia.org/wiki/Hyperoperation
github.com/id-Software/Quake-III-Arena/blob/master/code/game/bg_pmove.c#L260
twitter.com/SFWRedditImages

first for trap love

Fuck off, tranny

nigga you ghey

Thank you for using an anime image.

Rude!

2D traps aren't gay.

kys drink the biggest bottle of bleach degenerate

Thanks for a picture of Japanese origin

>2D traps aren't gay.
>>>/tumblr/
smhtbhfamalam

How the fuck do I read PDFs on my laptop without getting distracted?

force yourself to read and hopefully you'll shift in to auto pilot and reading becomes a breeze

>be at job interview
>whiteboard rolled in
>asked to write fizzbuzz
>except you can only print if the sum of all primes up to the fibonacci iteration of that number divided by 2 also a prime number

Why does the Sup Forums wiki have no recommendations for data structures books? They're all just books on programming languages.

* FIZZBUZZ.COB
* cobc -x -g FIZZBUZZ.COB
*
IDENTIFICATION DIVISION.
PROGRAM-ID. fizzbuzz.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 CNT PIC 9(03) VALUE 1.
01 REM PIC 9(03) VALUE 0.
01 QUOTIENT PIC 9(03) VALUE 0.
PROCEDURE DIVISION.
*
PERFORM UNTIL CNT > 100
DIVIDE 15 INTO CNT GIVING QUOTIENT REMAINDER REM
IF REM = 0
THEN
DISPLAY "FizzBuzz " WITH NO ADVANCING
ELSE
DIVIDE 3 INTO CNT GIVING QUOTIENT REMAINDER REM
IF REM = 0
THEN
DISPLAY "Fizz " WITH NO ADVANCING
ELSE
DIVIDE 5 INTO CNT GIVING QUOTIENT REMAINDER REM
IF REM = 0
THEN
DISPLAY "Buzz " WITH NO ADVANCING
ELSE
DISPLAY CNT " " WITH NO ADVANCING
END-IF
END-IF
END-IF
ADD 1 TO CNT
END-PERFORM
DISPLAY ""
STOP RUN.

What the fuck is this?

FizzBuzz, clearly

Whom quotest thou?

sauce pls

You don't know the superior language yet ?

On rest day from the gym and it hurts to move. What language should I fail at learning? I've tried some C, Python, Scheme. I think my learning material was more an issue than the languages. Anyone have a favorite book for beginners?

What language should I use to prove the genre of any given anime using the type system?

Python is piss easy to learn. How can you fail at learning Python?

I guess I just stopped. Maybe I'll continue Think Python 2nd Edition.

Alright spill the beans what are you talking about?

I need recommendations for a C# project

I know the syntax from books and experience with higher level languages. Just not sure what there is to do. My interests are with programs and games.

thanks /dpt/

Make a mod for your favorite game

Creation from destruction. Hopefully they'll get what's coming to them. I personally can't wait for it.

I've made two mods for ESO in Lua before. Got a few thousand downloads for a few days of effort.

I don't want to do it again in a different language because I don't think I would learn anything

but thank you for the suggestion user

Try out Unitale. Undertale game engine using Unity but use Lua to program it. Post projects in /r/unitale

I want C# projects. Unity uses C# so that's not a bad idea

/fit/izens on Sup Forums? Am I not the only one?

Guess the trap images make more sense now.

Clarify yourself.

@59779245
@59779260
@59779371
@59779377

I'm actually a Sup Forumsentoomen on his first week working out

What even is there to clarify?

I'm one of those people who can never learn a language unless I have a real project to frame my learning around. Maybe it's the same for you too.

>using the type system
So, right here you've restricted yourself only to languages with a turing complete type system, in which case, Haskell or C++ are your best bets. Although strictly speaking, you're going to have a hell of a time encoding anime into the text of the program. I don't know about Haskell, but C++ does not allow you to go read arbitrary binary files at compile time into constexpr arrays. The only compile time I/O you've got is #include.

Honestly, you'd be better off doing this at runtime, instead of in the type system, because statistical classification in and of itself is a fucking hard problem, especially when you're operating on what, audio and video data? What features would you even use to generate a model for this? I mean, maybe if you were able to just rip the subtitles and run them through something like naive bayes...

Hm. Thanks for the tip. That could be it.

public static void Main (string[] args)
{
//hot to call myMethod to grab 'b' and
//pull it or a copy of it, up here to do math on?
int c = b + b
Console.WriteLine(c);
}

{
public static void myMethod ()
{
Console.WriteLine("type a number");
int a = Console.ReadLine();
int b = a + a
}
}


how to pull the results of a method out and into another method?
C#

msdn.microsoft.com/en-us/library/1h3swy84.aspx

What's the best language for writing a kernel using only the type system?

Anybody upload the humble bundle python books?

idris

@59779528
>So, right here you've restricted yourself only to languages with a turing complete type system
Of course I would do that, why does this deserve a comment?
>Haskell or C++
Both of them have type systems where the equivalent of this is approved by the type checker, so every type is inhabited.
data Void
a : Void
a = ⊥

Stopped reading your mindless retardation right there.

Fact: OCaml programmers are the most powerful race in the world.

>O

OCaml is as much about objects as astronomy is about telescopes.

tyvm
also, this video helped make sense of that page
youtube.com/watch?v=QwygwfqOHsI

It is in the set of object oriented languages. Meaning it and its users belong on plebbit.

People always say that if you aren't using LINQ, you're using C# wrong... but it doesn't seem too useful outside of database stuff.

How could I integrate LINQ into my general practice? Is there any real benefit?

>People always say that if you aren't using LINQ, you're using C# wrong
This is correct, since any usage of C# is wrong.

why

Because C# is shit itself.

Explain this incorrect opinion
Why is C# shit

Where did I state a single opinion?

ccs.neu.edu/home/matthias/HtDP2e/

Even with a fancy type system, he'll never be able to 'prove' the genre of something.

He's also better off using a language with full-blown dependent types, like Idris.

Idris.

>he'll never be able to 'prove' the genre of something.
Why not?
>full-blown dependent types
As opposed to "non-full-blown" dependent types?

>Why not?
You can certainly take an heuristic approach, but unless you have a particular mathematical proof in mind...
>As opposed to "non-full-blown" dependent types?
He was suggesting Haskell, which does not have dependent types, though is attempting to approach them in various ways (e.g., refinement types).

why is LFB access so extremely slow?
I'm only trying to do a full-screen color fade at 640x480. I didn't think that would be too demanding, but it's only displaying about one frame every three seconds.

is this a joke?

>Idris
I checked it out and this appears to be valid Idris, meaning it's also inappropriate for my purposes. I don't know why people seem to think that dependent types somehow rid a language of any core problems it might have.
data Empty
a : Empty
a = believe_me 5


>unless you have a particular mathematical proof in mind
I'm working on it as we speak.
>though is attempting to approach them in various ways
Then they aren't dependent types, but merely ways to "simulate" them. Which is probably caused by the language being crippled in the first place.

When you said that C# was shit
explain your reasoning and I'll believe you

That wasn't an opinion.

fine then, back up your theory with evidence
If a theory is good enough for gravity then it's good enough for C# being shit. Prove it.

>Then they aren't dependent types, but merely ways to "simulate" them. Which is probably caused by the language being crippled in the first place.
Jesus Christ, this was my actual point. This is why, when Haskell was recommended, I said he needed 'full-blown' dependent types, like Idris.

Honestly, learn to fucking read.

>he needed
Not necessarily, you can prove things even in the simply typed lambda calculus.
>'full-blown' dependent types
Something either has dependent types or it doesn't. There isn't anything "full-blown" about it.
>Idris
Actually having a type system which doesn't allow you to prove absolutely anything is a lot more important than just having a more sophisticated type system.

>Honestly, learn to fucking read.
I know what you meant, I just thought it was wrong/poorly worded.

>'full-blown' dependent types
It's a turn of phrase; if you knew what I meant then you're deliberately sperging out, and deserve every insult you get.

Me knowing and agreeing with what you were trying to say doesn't imply that I agree with what you actually said.

Clearly: see 'sperging out'.

I'm not aware of having Asperger's.

That's why I'm informing you :)

I don't know what you're trying to imply with this.

Just started with some simple website stuff, never bothered with html before. Any tips?

I didn't imply anything, only stated.

mysqli_real_escape_string
filter_input(INPUT_GET, "thing", FILTER_SANITIZE_STRING);

if you enter into php sql

otherwise, use a designer, nobody writes their own http in 2017

there is no real benefit, it can make code harder to read, use resharper if you want to oneline some foreach stuff where you can

sometimes parallel.foreach is wrote easier in linq, too

use object serialization and deserialization instead of database stuff, i have an entire class devoted to this that uses a timer to save to file if it needs, a final save when destroyed, and an autoload from a file based on the class's name at creation, very fast, much faster than the most popular sqlite lib on nuget that had locking problems and retried 10x on queries i expected to fail

...

What is this? Searching hyper doesn't help much.
I don't quite comprehend how you go beyond arrow notation (presumably user did that) without it just being 1 more arrow.

>quake source is terribly formatted with a seemingly random number of spaces and tabs thrown in everywhere and huge decorated comments that break the flow of reading

just lint it nigga

it really is, sadly

Who said this?

>random number of spaced and tabs everywhere
Post example?
Quake source is very easy to read in my experience.

www.sdmsolutions.ca/pnis

I made a base-803 numeral system.

Nevermind found it.
en.m.wikipedia.org/wiki/Hyperoperation
That would be absolutely brutal.

how I document my functions in C for professional® works

Just do something like this

// includes the file we need to print
#include
// stating the main code
int main()
{
// printf() displays the string inside quotation
printf("Hello, World!");
// returns 0
return 0;
}
// end of code

xd

But who is it quoting?

>Post example?
typedef struct cmdalias_s
{
struct cmdalias_s *next;
char name[MAX_ALIAS_NAME];
char *value;
} cmdalias_t;

cmdalias_t *cmd_alias;

qboolean cmd_wait;

cvar_t cl_warncmd = {"cl_warncmd", "0"};

//=============================================================================

/*
============
Cmd_Wait_f
Causes execution of the remainder of the command buffer to be delayed until
next frame. This allows commands like:
bind g "impulse 5 ; +attack ; wait ; -attack ; impulse 2"
============
*/
void Cmd_Wait_f (void)
{
cmd_wait = true;
}

/*
=============================================================================
COMMAND BUFFER
=============================================================================
*/

sizebuf_t cmd_text;
byte cmd_text_buf[8192];

It's useful literally any time you're working with collections of things.

Say you want to start with a root directory, and delete all PNGs in any subdirectory that are greater than 3MiB, but only if the subdirectory has "muhdick" in the name:
Directory.GetDirectories(path, "muhdick", SearchOption.AllDirectories)
.SelectMany(x => Directory.GetFiles(x, "*.png"))
.Where(x => new FileInfo(x).Length > 3145728)
.ForEach(File.Delete);

Note that ForEach() here isn't really a part of LINQ; it would be perfectly fine to use a traditional ForEach here after storing the query in a variable, but the point is that no heavy lifting was actually done until the call to ForEach. LINQ is lazily evaluated so that it isn't expensive until you actually need to use it. If I would have just put it in a variable, that variable simply holds a set of instructions on where to get the result collection, and waits to be enumerated.

Depending on what you're actually doing, I could show you some examples where you might be able to make code you've written more concise and actually easier to read.

Doxygen

Do you even comment?

// see LICENSE section for licensing information
// preprocessor statement to include standard library input/output header file so we can use printf
#include
// entering main function of the c runtime that returns an int to the environment, argc/v are implied
int main()
// opening brace of main function
{
// printf() displays the string inside quotation with null termination, see man 1 printf
printf("Hello, World!"); /* a classic text string
used by many of the greats of programming
often used to confirm your programming
environment is working */
// returns 0 to shell, note this is a statement not a function so we don't use parentheses
return 0; /* i forgot to mention depending on your terminal you might
want to use sprintf instead, see the
relevant man pages
for more information
*/
// closing case of main function
}
// end of code
//
//LICENSE
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
//(c) 2017 pinkypie-best-pony.github @facebook pinkypie twitter: pinkypieclop

What do you mean? Where's the screenshot from?

That images is cute, but I don't really like your post overall.

You do get points for the apparent effort, but your wording is a bit forced in the would-be humorous comments.

I'll give you a 6/10 for your official Sup Forums Post Score™.

I feel like contributing to this code. Care to share your code of conduct?

Thanks bro 6/10 is fine.

My CoC is basically only trannies or pseudo-trannies can contribute so if you're a cisshit white male I'm afraid your are out of luck.

this shit + LINQPad, better than bash or powershell

>seemingly random number of spaces
But qboolean and cmd_wait here are seperated by type. Why should they share whitespace pattern?
>huge decorated comments that break the flow of reading
But that's intentional. They're using it as paragraphs for COMMAND BUFFER here for instance. You're supposed to understand some different context here. It's true that the first decoration here doesn't serve any real purpouse usually. But for completeness sakes it's needed.

And it's clearly code someone decorated for presentation, someone applied themselves to feel they did their job when the code was GPLd. I don't think all of the comments in Quake are good for understanding the game as a whole but rather for piece-wise learning.
For example the movement code:
github.com/id-Software/Quake-III-Arena/blob/master/code/game/bg_pmove.c#L260
Why comment alternative solutions in your code? It makes no sense to call it a bug either. It's consciously replicated from earlier games. It's not even the same as earlier games, it's modified for gameplay reasons. So why even call it a bug and "solve it"? It's plainly clear that the author is just putting that in there to assure people that they know how to write code without air acceleration. Imagine doing that in your code. It's terrible.