/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?


Previous Thread:

Other urls found in this thread:

software.intel.com/en-us/intel-opencl/download
stackoverflow.com/questions/3467279/how-to-create-a-polyvariadic-haskell-function
en.wikipedia.org/wiki/Three.js
hexgl.bkcore.com/
twitter.com/NSFWRedditVideo

"The most powerful programming language is Lisp. If you don't know Lisp (or its variant, Scheme), you don't know what it means for a programming language to be powerful and elegant. Once you learn Lisp, you will see what is lacking in most other languages." -Richard Stallman

s/Lisp/Javascript

why isn't this allowed ?

It pains me to say this, because it implies I have some knowledge of the worst and most cancerous language of all time, but I believe you forgot a colon

oh right.

Go is a cute

where can i find test cases for my parser?

i mean, files full of integers, doubles, booleans to see if my parser is working correctly

Go is a cute decompensated heart failure

random open source code ?
Q3A for C etc ?

new challenge when?

It's 2017 why the fuck is compiling for android still so convoluted?

yeah kinda

i just want text files that have for example
true
false
123132
5.2
9.0e+9
3555e9
...


or do i have to write it myself?

I demand an AI themed challenge.

It's 2017 and why the fuck are you compiling for android?

Business.

I answered you faggot what do you want
An already-parsed test to test your """"parser"""" ?

what you mean?

you just have to click "Build"

Solving P=NP in Haskell.

>not just importing the solution in python

>the client changes their requirements at the last second
what you mean?

you just have to click "Build"

>you ask your boss for a raise
what you mean?

you just have to click "Build"

but i wrote the library

P != NP

prove me wrong (you can't)

Does anyone have experience with WebGL and plain JavaScript? How's the workflow compared to OpenGL (3.x) and C++? I've made some 2D on the Canvas with the simple Context2D before, and thought I would give WebGL a shot, but I know that browsers don't like complex code and may cause FPS drops which otherwise runs perfectly fine if it's in a standalone executable. Or was that only because I was only relying on the CPU before?

Any tutorials or documentation worth reading?

How mandatory/helpful would three.js be?

I just felt like you could use this smug anime girl

someone click this link and tell me if the free download for linux button works?

webpage won't load for me I've been trying for 45 minutes

> inb4 "le it's a viruse xDDDDD"

not asking you to download anything

this link

software.intel.com/en-us/intel-opencl/download

>How mandatory/helpful would three.js be?
it's THE lib for webGL but feel free to reinvent the wheel if you want to quit half way

Does not load.

Lambda calculus has no a sequential computational model to calculate a function of an input n, pajeet.

Recommend me the best resource for learning laravel framework.

nope

what does that have to do with compiling? during development it's just a key shortcut or a click and doing release builds isn't something you should need to do very often but it's not that complicated you whiny babby

Does Haskell support variadic functions? I was let down when this wouldn't work in GHCi (+) 1 2 3 , because (+) takes an two numbers and returns a number.

You can make variadic functions using type classes, but it's normally not a good idea.

Printf would be an exception.

>but it's normally not a good idea
Why not? I'd rather write (+ 1 2 3) than sum [1,2,3].

Why?

And it'd cause havoc for the typing.

Remember that Lisp deals with lists, and that you are complaining about lists.

Because the former looks cleaner.

It sounds nice until you realise how nonsensical it would be syntactically

it should just work but it doesn't

aren't you supposed to use some fold or zip cancer

>let n = 1 :DD

sum = foldr (+) 0

>cancer
how?

Besides sum, one could use foldr1 (+) [1,2,3], but it still looks meh.

what the fuck is wrong with
sum [1,2,3]

May I ask what do you mean by reinventing the wheel without three.js? Is three.js something like GLEW?

Nothing, but my point is that (+ 1 2 3) looks cleaner.

No it doesn't.

Plus, what about operator sections?

Should (+) be 0? How would you refer to addition?
Should (+ 1) be 1? Should people have to write (flip (+) 1)?
What should the type of (+) be?


It makes no sense whatsoever to do that, except in Lisp where everything is a list and dynamically typed

I think 1 + 2 + 3 looks a great deal cleaner than (+ 1 2 3)

>No it doesn't.
Yes, it does.
>operator sections
As in partial application?

Operator sections aren't just regular partial application, they're an extension of infix syntax

(x /) and (/ x) are two different things
(/) is its own thing

Your idea, which only sounds good to people who use lisp, and which would reach into and make every other part of the language worse, is not a good idea.

Just use

1 + 2 + 3

or

sum [1,2,3]

OK, so no variadic functions for me.

You can make them if you want, but the type inference is normally god awful and you may even need to write the type of every argument

stackoverflow.com/questions/3467279/how-to-create-a-polyvariadic-haskell-function

printf is an example of an excellent variadic function (Text.Printf)

90% of the time, you do not want a variadic function

and even printf would be better dependently typed

Not everything is a list in Lisp. While Lisp is also dynamically typed, the programmer can provide type annotations that can be checked at compile-time (SBCL, for instance, does static checking when it can, if declarations are made).

In fact printf is even better than a variadic function, because it also doubles as sprintf

Is the for loop the most kawaii loop?

What the fuck did I tell you, you stupid damn frogposter ape?
Go back to r9k and take your shitty C loop with you

#include
#include
#include

typedef struct result {
int64_t result;
uint64_t steps;
} result_t;

result_t fib1(uint8_t n)
{
result_t result;
result.steps = 1;

if (n >= 1;
result.steps += 1;
}

result.result = d;
return result;
}

result_t fib2(uint8_t n)
{
result_t result;
result.steps = 1;

if (n

fibs = 0 : 1 : (zipWith (+) tail) fibs

Computes fibs 100k pretty quickly
How fast does that?

>inb4 too big for int64s

If you use arbitrary precision integers instead of 64-bit ones, then fib1 is logarithmic and fib2 is exponential. I guess your Haskell one is linear?

yes

Trying to organize my objects properly.


I have a "container" file object that is basically an interface to opening a zip-like file

Container.Open("blah.container")

and I want to be able to just read files from this container

should the "Container" have a "current file" context?
like Container.SetCurrentFile("/foldername/filename.txt")
Container.seek(0xbeef)
Container.read(0xbeef)

or should I have it produce some "ContainerEntry" type that stores a reference to the parent "Container" object

Entry Ent = Container.GetEntry("/filename.txt")
Ent.seek(0xbeef)
Ent.read(0xbeef)

What would GetEntry return if the file didnt exist?

would I be using a weak_ptr within the Entry type to point to the Container file that produced it?

Does the Entry-Type set "Container" as its friend class and hide its constructor so that "Container" is the only thing that can produce Entry instances?

Hell any resources involving knowing when to use certain OOP patterns in certain situations would help.

I always hear about the patterns but I never see proper case-studies of them being put to use.

fib (10*100000) is definitely much more than 10x slower

In fact it is probably 100 times slower.
Also this isn't memoized, a memoized array version would be much better.

en.wikipedia.org/wiki/Three.js

public class ConsoleMain
{
public static void Main()
{
double[] numbers = { 1, 2, 3, 2, 5 };
double m1 = M(numbers); // should return 3
double m2 = M(new double[] { 1 }); // should return 1
double m3 = M(new double[] { 3, 3 });
double m4 = M(new double[] { });
Console.WriteLine(m1);
Console.WriteLine(m2);
Console.WriteLine(m3);
Console.WriteLine(m4);
}
public static double[] M(double [] numbers, double M)
{

}
}


How do I return the number from this array that is closest to that array's average?

Just found an insanely fast fib on the wiki
Effectively uses the matrix form

import Data.List
import Data.Bits

fib :: Int -> Integer
fib n = snd . foldl_ fib_ (1, 0) . dropWhile not $
[testBit n k | k

I'm looking for an online weather service I can request without making an account. I'm using NOAA right now, but I can't find one for outside of NOAA's scope. Does anybody know of any?

so it's basically for making websites. i think user just wants more of a plain opengl for games or something

js and webgl runs like shit like what are you even trying to do

Ugly.

Thanks!

Yes, basically. I've done that before with plain JS on the canvas, and I'm experimenting with OpenGL for some time now, and wondered how the two looks like together.

Games.
Yeah, I've looked up some examples now, and for some reason I get a small freeze every 5-6 seconds for no real reason.

>so it's basically for making websites
no.

hexgl.bkcore.com/

Ugly but insanely fast

>autism
unless you're trying to be the next agar.io or slither.io i don't see why you'd do it in webgl specifically. you could use a more full-featured game engine and port it to webgl instead of learning something as web-specific as three.js

Thanks for your thoughts on that kode.

who gives a fucking shit he was asking if three.js was mandatory for making webGL apps, yes it is

>full-featured game engine and port it to webgl have you ever coded something functional in your life ?

js should be banned on the web, http stands for *hypertext* transfer protocol

you don't even have to make the engine yourself (but with three.js you're basically doing it because it has such basic functinoality) but for example the unity engine supports webgl/html5

>hexgl
what a shitty "game"

No es un argumento

halp

>Properly round float average (in math.h)
>Iterate again to find the smallest difference between your new int average and your values

>compute average
>loop through it again, compare abs(i - avg), save lowest distance to average and the corresponding number

apparently you're not supposed to directly access a char* by index and assign data to that?
void foo(){
if(globalChar != nullptr){
delete[] globalChar;
globlaChar = nullptr;
}

globalChar = new char[20];
for(int i =0; i < 20; ++i){
globalChar[i] = theSameSequenceOfBytesEveryTime;
}
std::cout

you forgot the null terminator
also use std::string

>globlaChar

He should use bounded stri... Oh wait.

So I was thinking about training a neural net to make trades on the stock market. What do you guys think? Is such a thing even possible?

Yes.

but it's not supposed to be a string, it's just bytes

>but it's not supposed to be a string, it's just bytes
But you're treating it as a null-terminated string.

then use std::vector

you're writing the pointer value to stdout, not the actual bytes in your array.

HFT companies thought of this long ago, and have been pouring millions of dollars a year into machine learning applications for trading. You're up against them, because short-term trading is a zero sum game.

Checking out Crystal, its pretty good

cout prints char *s as strings, not addresses.

cout assumes char * are null terminated strings.
Use a function that takes a char * and a count if you wanna print out just 20 chars.

Not to mention that they have the money to run fiber through mountains and get servers next door to exchanges, some random on Sup Forums doesn't.