/dpt/ - Daily Programming Thread

/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

www-s.acm.illinois.edu/webmonkeys/book/c_guide/index.html
imagefap.com/photo/1079700765/
twitter.com/SFWRedditVideos

First for D

thank you for not posting a fag thread

third for feminine d(ick)

Let's continue the constructive debate on the merits of Haskell from the previous thread.

Some norsk-posting would be nice too.

Working on converting every drop of my PHP knowledge into Node

Anime is cancer. Good to see a thread without it.

That's like going from pig shit to horse shit.

>tfw i have all more than 100 photos of this girl

How do I build website backends?

I don't want to learn JS.

From my understanding the algorithm checks if the last solution can be improved/minimized with the respective sum of A[i]+the B values.
(C[n]>sum)
And in that case we know that there might be more values in the interval a[last],b[last] that could be improved.

In Figure 1 we then look start looking from j=n-1 down to a[last] for the first j where C[j]>sum and update the intervals accordingly.

Which of course brings the runtime up to O(n^2)

In Figure 2 we only check if C[j]>sum is true for a[last] and the paper argues:
Note that if C[j]>sum holds for j = a[k] for some
k, it follows from Observation 1 that this inequality also holds for all j > a[k]. Hence, it is sufficient to check this condition for all starting points a[k] of non-empty intervals.

This check however, can never be true as j (at least when calculating it as in the pseudocode on Figure 2) is < i meaning that there is no sum for C[j] that would start with A[i].

Granted, but F# has always been the 'oh camel'ly red-haired step child of the .NET family. C# is where the real action happens.

>merits of Haskell

>3dpd

Understanding is a amazing skill to develop. People started shitting on haskell due to a build up of annoyance due to the constant haskell elitism and constant push to convert others to haskellism.

It's for their own good. Countless developers are wasting their lives fighting against limited, crippled languages and tools.

Seems an improvement to me.
Whats the back-end-lang approved by Sup Forums if not Node.js? Perl?

Much better than weabshit

And then anti-Haskell shitters have nothing but memes, leading to the clusterfuck we had last thread. Which then leads to
>WE DINDU NUFFIN, DOSE MEAN HASKELLERS KEPT DEFENDING THEIR LANGUAGE

W-what? I forgot a ' and was bothered by it but it's not that big a deal.

About a bit more than 15% done implementing the C Standard Library. Shit's fun. I need to refresh on the Taylor expansions for trigonometric functions before I tackle math.h though.

here's my take in python

inf = 99999999999
def calculate(n, lst):
a = 0
for i in range(n):
a += lst[i]
return a

c = []
for j in range(n):
c[j] = A[1] + calculate(j, B)

a[1] = 1, b[1] = n, pred[1] = 0
last = 1
for i in range(2,n):
if C[n] > A[i] + calculate(n-i, B)
b[i] = n
j = a[-1]

while C[j] > A[i] + calculate(j-i, B) and j >= i:
C[j] = A[i] + calculate(j-i, B)
a[-1] = inf, b[-1] = inf
last = pred[-1]
j = a[-1]
if j >= i:

## not sure what write here
## probably write a helper bin search function
## to find the lasrgest value j

else:
b[-1] = i-1, a[i] = i
pred[i] = last
last = i
else:
a[i] = inf, b[i] = inf

desu, I would probably learn Haskell if I were truly smart enough for functional programming and had even the most basic grasp of what a proper type system looked like.

>Normann brevning
>dkn ditt språk inte är ett jag-jag

That's pretty nifty, what sections do you have completed so far?

You're using haskell as a tool to satisfy your ego. Because you are using haskell you perceive yourself as better than the "countless other developers" who follow a different route. You think your truth is more valid than the truth of another.

Arguments and viewpoints formed of purely ego only attract strife and violence.

You shouldn't use Taylor series for trig functions. Consider Chebyshev polynomials instead, they are more efficient.

uncurry (++) . partition (9 /=)

Just look at this oh my GOD it's so fucking beautiful I can't even believe something this pure could exist in our plane of existence.

I'm going in order as according to
www-s.acm.illinois.edu/webmonkeys/book/c_guide/index.html

Just finished float.h

that line calls 10000 lines in the background.

lmao

And what does it do?

I'm using Haskell because it lets me write correct code faster. I have used mainstream languages and found them all wanting.

Thanks! I'm a bit rusty on the maths.

I think you're missing the point of high-level languages.

Any specific reason you are doing your own implementation?

It monoids your types into higher lambda calculus applicative functors. Trust me it's extremely useful and anyone who programs in a language without equivalent capabilities is basically a literal retarded baby playing with blocks.

That is fine. However, it does not conclusively prove the languages you found wanting are not the best language for others to use. It also doesn't excuse calling anything or anyone not using haskell "wasting life" or "crippled" and ardently trying to push others into your "truth".

Looks very similar to what I have, probably wouldn't work either though. See: aux[0] = B[0];
for(int i=1;i=i) {
C[j]=A[i]+aux[j-i];
a[last] = UINT32_MAX;
b[last] = UINT32_MAX;
last = pred[last];
j=a[last];
}
if(j>=i) {
uint32_t start = a[last];
uint32_t end = b[last];
uint32_t middle;
while(start

Well memed my dude

I said that the languages they use are crippled, not that they themselves are crippled. I see so much boilerplate in other languages that would not have had to be written in Haskell, and it is deeply dispiriting.

I find Xinu's library is rather unfit for how I want to implement my OS.

Going for the ultimate goal here folks,
An os running on hardware I designed under an ISA I've designed. The OS is written in a language I designed and compiled in a compiler I wrote and then ported to build in that language itself. I want a self hosted-everything. Except for maybe fabrication. I'm horribly clumsy with small things.

Assembly

this thread is so fucking retarded, it's even funny
fucking autists, top kek

aux[0] = B[0];
for(int i=1;i=i) {
C[j]=A[i]+aux[j-i];
a[last] = UINT32_MAX;
b[last] = UINT32_MAX;
last = pred[last];
j=a[last];
}
if(j>=i) {
uint32_t start = a[last];
uint32_t end = b[last];
uint32_t middle;
while(start

>uint32_t last
wew lad, just use size_t both for last and all i,j loop variables

Thats what an underage btard would have replied
Mind giving a serious answer?

learn Go

any lewds?

machine language

>Go, created by Google
nice try FBI

Damn, good luck my lad, that's quite the undertaking

Wew lad. Everyday I learn something new

Isn't wasting life the same as being crippled? Both imply inability to live up to full functionality.

I'm not that guy but I am missing the point. But really is there a situation where you can come up with this short piece of code, be amazed by it this much without it having taken you a lot of time already? Give me a picture of how much it's saving you.

There's also the issue of your users time being spent processing things unnecessarily, wasting energy etc. Is your software really usable if this kind of code would generate thousands of lines of code? Surely you're not doing such incredibly trivial stuff that you never run into performance issues.

I have parts of each task a good part done.
I rotate the sub-projects so it doesn't get dull ever. I think I'll have it in about 5 years.

Just use a C++ webbackend framework. Like Facebook.

user asked
>any lewds?

...

Her name is Mandy you filth. You aren't high class enough to lay eyes on her. None of you are.

nooice

What's your favorite language feature of any language?

>pinky hurts
>keep going
>middle of palm hurts
>fearing SRI
What do?

booleans

I think in terms of high-level combinators. If I am using a language that does not support them, I must then transcribe the code. It is much quicker for me to write in Haskell and avoid any need for transcription.

Type classes are pretty cool, nice way of fine-tuning how generic you want a function to be.

Trying to make a snake game, trying to store the snake as efficiently as possible. Outside of that everything is pretty easy.

donate to stemcell research

retard

>imgur
link to the gallery?

just store the snake on the actual map, and when the snake moves, move the tail cell to where the cell of the head moves to.

reverse image search OP's pic

Bump on this question chain

who wants to see what I came up with since the thread with Rob Schneider

meh, just learn F# if you're already on .NET
i really do like row polymorphism, since it seems to clean up so many of the "problems" with static types. like you can get rid of all the boilerplate that even plain HM type inference won't give you (you still have to define types or classes). plus, it lets you reuse labels for records or sum types which is pretty cool.
one of the really cool things you can do with it is create nanopass-style compilers without having to define the types all over again for each pass (and that actually lets you write shorter code than the equivalent Scheme code)

the best feature is still probably macros, though, because you can basically implement anything else with them

Shuffles all the 9s in a list to the end.

partition filters a list into two lists: one whose elements satisfy the given predicate and one whose don't.

uncurry turns a function of two arguments (here list concatenation (++)) into a function of one pair.

(.) is function composition, (f . g) x = f (g x)

>link to the gallery?
i only have links to individual photos, not gallery or album.

i run a python script to download all photos

r8

def getChunks(spawns):
iterations = 5
def chunks(spawns):
maxDistance = .250
foundIndexes = []
output = []
for i in range(0,len(spawns)-1):
found = []
for j in range(0,len(spawns)-1):
skip = False
if j not in foundIndexes:
d = getDistance(spawns[i]["latitude"],spawns[i]["longitude"],spawns[j]["latitude"],spawns[j]["longitude"])
if d < maxDistance:
found.append({"latitude":spawns[j]["latitude"],"longitude":spawns[j]["longitude"]})
else:
skip = True
if found:
newPoint = avg(found)
output.append({"latitude":newPoint[0],"longitude":newPoint[1]})
foundIndexes.append(j)
elif skip:
output.append(i)
return output

bigout = spawns
for i in range(0,iterations):
length = len(bigout)
bigout = chunks(bigout)
if len(bigout) == length:
break
return bigout

>Milf
This is mislabeled surely. She doesn't look old enough to classify as milf.

The thing is I'm trying to do it like the atari would have done.

The atari 2600 had 128 bytes of memory and the Surround game had a playing field that's 18x33.

I doubt they stored the snakes as matrices.

Sounds a bit memey desu (claiming it solves almost all your problems) but I'm interested

wow so elegant muh monads lol xdDDD

> girl

>The atari 2600 had 128 bytes of memory and the Surround game had a playing field that's 18x33.
What were the cartridge size on these? That sounds like the far more interesting statistic.

It doesn't use monads.

>for i in range(0,len(spawns)-1):

do you know that range starts at 0 by default?

might be have lil kids, i'm guessing she's in her early thirties

Now blame Haskellfags for being so pretentious that they forced you to make that post

> People started shitting on haskell due to a build up of annoyance
People who shit on Haskell (and FP generally) do so mainly because they'd prefer to believe that they understand "programming" rather than "imperative programming".

It's important to note the distinction between criticism and "shitting on". And it's rarely all that hard to determine which is at play.

here's your reply, you attention seeking faggot

I assumed she's younger than me and I'm 23.

>meh, just learn F# if you're already on .NET

I should.

The game carts had 4kb of ROM, so there's no way they were swapping between that and the main memory to store the snakes.

Proof?

Ah, you meant efficient regarding space rather than time. Definitely just an array of the coordinates of the snake's cells and then the direction of the snake; I don't think there is a different way.. Shoving the entire array every frame seems horrible, so I may be wrong.

So i have these two functions written in Java and i'm looking for PHP implementations for both such that data can be encrypted/decrypted by both PHP and JAVA interchangeably.
private static Pattern PEMDecoder = Pattern.compile("\\s*-+[A-Z\\s]+-+\\s*([A-Za-z0-9+\\/=\\s]+)-+[A-Z\\s]+-+\\s*");
public static String encrypt(String publicKey, String data) throws Exception {
Cipher cipher = Cipher.getInstance("RSA");
Matcher m = PEMDecoder.matcher(publicKey); if (!m.matches()) throw new Exception("Invalid key.");
byte[] bytes = Base64.getDecoder().decode(m.group(1).replaceAll("\\s+", ""));
cipher.init(Cipher.ENCRYPT_MODE, KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(bytes)));
return DatatypeConverter.printHexBinary(cipher.doFinal(data.getBytes(Charset.forName("UTF-8"))));
}
public static String decrypt(String privateKey, String encrypted) throws Exception {
Cipher cipher = Cipher.getInstance("RSA");
Matcher m = PEMDecoder.matcher(privateKey); if (!m.matches()) throw new Exception("Invalid key.");
byte[] bytes = Base64.getDecoder().decode(m.group(1).replaceAll("\\s+", ""));
cipher.init(Cipher.DECRYPT_MODE, KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(bytes)));
return new String(cipher.doFinal(DatatypeConverter.parseHexBinary(encrypted)), Charset.forName("UTF-8"));
}


The only library i found is phpseclib which is extremely slow and gives me decryption errors if i try to decrypt a cipher encrypted with java.
Pic related.

>Using Java when glorious Haskell exists
Really ate to see your potential go to waste like that.

imagefap.com/photo/1079700765/

You are now my bitch.

Make me a sammich,bitch

it doesn't solve everything really, but it's a nice way of making statically typed code a lot closer to the dynamically typed version
you can just introduce new data structure in your code without defining them (the same way you can write new data structures using objects in javascript).

function f(x, y, z) {
return {a: x, b: y, c: z};
}

is like
let f x y z =
{a = x; b = y; c = z}


you can use that to perform what's essentially structural subtyping in OOP code, so say you could have two types that are subtypes of an interface you never defined:
class X = object
method greet = print_endline "Hello!"
end

(* In Java, this would have a different type than X, so you can't use them without declaring an interface
or base class and having them extend or implement it *)
class Y = object
method greet = print_endline "Howdy!"
method greet_person name = print_endline ("Hi, " ^ name)
end

let f o = o#greet (* Calls the greet method on any object *)

so in the above code, you could use the two different classes interchangeably for the function f because they define the same methods

>falseflagging

> iterations = 5

Do you know it still would have executed if I didn't have spaces around the =?

you can reverse image search!

wow. want a cookie?