/dpt/ - Daily Programming Thread

Fortran edition
old: What are you working on, Jow Forums?

Attached: fortran_books.jpg (600x450, 321K)

>I'm working on this
nobody cares

Just wanted to let you all know that C is the best language and if you are using another language other than assembler you are a giant faggot.

Lisp is the most powerful programming language.

t. language war shitposter

Attached: 1454872203109.jpg (485x465, 55K)

I've contacted a few anons in these threads to work on small jobs.

nobody cares?

I am going to create a better, smaller faster, safer libc

Has everyone done their AoC, yet?

Attached: e5f58daf7659a84b396ea5b63a2216c4103438a8_hq.jpg (1024x576, 45K)

do I look like somone whose capable of giving a shit?

no and ryuko a whore

>start with musl
>???
I wish you luck user. Keeping POSIX compliance while remaining lightweight is deceptively challenging

It's okay to be tasteless user, but those people have a containment thread

Attached: DpOQrnRUwAAXJWa.jpg (849x1200, 131K)

>trigger
>taste
at least upgrade your taste, faggot

everything else they've done ranges between mediocre and shit but klk was a wonderful show in every regard imo. Are you angry? Is there something I can help you with?

ye, trying sepples17 and hasklel this year

>Is there something I can help you with?
yes, commit suicide pls

I've been working on my haskell the last couple weeks, but I gave up on C++ because templates would just arbitrarily shit the bed once when combining them with lambdas and default arguments.

Fortran is still being used?

Fortran is worse than C.

how? you have no way of determining which is which. i could be you.

Right after C.

Yeah, I find that default arguments are pretty shit also, while the problem of lambdas is more or less lessened by annotating them with a trailing return type.
Still feels clunky tho.

i would assume in niche market old languages are often used.
i think big banks have old languages no one knows about and pays big money to people who can manage them, since the market is so distilled.

Use C which is superior.

lol no generics

B but macros and void*

Default arguments will be much less shit when we no longer have to separate declarations and definitions i.e. when modules arrive.

Is there a textbook that'll teach me machine learning? Like one that is well known

JavaScript rocks!

Attached: js_rocks.png (1433x779, 473K)

󠛡 󠛡 󠛡 󠛡 ▲
▲󠛡▲
every time you post this, a fairy dies

Attached: south korean banter.png (743x294, 11K)

C for life

>ouch, why does stabbing myself in the face hurt

Attached: unknown.png (1726x662, 32K)

I'm trying to work on some algorithm in java and am having a bit of trouble.

Basically what I want to do is something like this:

(any time I encounter an 'a', I change it to an '@', anytime I encounter an 'o', I change it to a '0')

String: "baot"

First character is "b"
ArrayList: ["b"]

second character is "a" -> "a" must get changed to '@', so what I do is double the contents of my arraylist, add 'a' to the first half, and '@' to the second half

ArrayList: ["b" , "b"]
ArrayList: ["ba", "b@"]

third char is 'o', so same thing happens

ArrayList: ["ba", "b@", "ba", "b@"]

ArrayList: ["bao", "b@o", "ba0", "b@0"]

4th character is 't', so I just add it to all

ArrayList: ["baot", "b@ot", "ba0t", "b@0t"]


Essentially, what this does is generate permutations according to some criteria of rules.

My question now is, how the heck do I use arraylists to do this?

Attached: 1529540342722.png (540x606, 542K)

...

congrats dumbass

use recursion

damn, I guess c++ is broken too

Attached: unknown.png (454x368, 10K)

>char*
>nums
so this is how dynamic typists work

Let me ask you, without you sperging out, why do you put the incrementer on the left as opposed to the right?

faggots i want to learn how to set up boots and machine learning shits on azure, where the fuck should i start? please help

that kind of trivial minutiae is incredibly important to C++ users, how dare you question it

>using c++ in current year
brainlet use C instead

>brainlets use C instead
Agreed.

Habit.

Attached: 1541169065449.jpg (300x240, 32K)

you've not only proven that you're probably the sort of /wdg/ faggot that likes javascript, but that you're new here (or otherwise need to lurk more) AND that you have absolutely ridiculously garbage ideas of what constitutes
a sane language

>only way to put anime girls in VSCode is to install an extension
>it requires admin rights and is full of errors
>all the documentation is in Chinese

What should I do, Jow Forums?

Attached: akko_crying2.png (857x934, 802K)

Nice try but no. You've neatly demonstrated that you do not know C++ and you think JavaScript is good. Kindly depart to and never return.

Write your own, baka

like seriously did you think nobody had come here and given this speech before about how it's actually being given implicit arguments? did you think people would go "woah i guess i was wrong actually this is cool"
no it's fucking dumb as shit

>shitlang does nonstandard thing
>"but actually it does it on purpose! haha you lose, losers"

purity should be the default

Brainlets dont use C because they are brainlets. C is the best language, all OS runs om it.

Not true, I'm 100% sure the windows nt kernel is written in C++. Not sure about npcOS.

Don't mix 2D and 1D

Actually I take that back, I'm wrong.

this algorithm's memory usage will scale as O(2^n) so on anything other than short strings will pretty quickly cause it to shit the bed

if you want to print out all permutations it might be easier to simply keep a second array of all the indexes of 'a' and 'b' in the input array and use that to generate and print one permutation at a time

>call a function that takes 2 arguments with 3
>expect a result as if only 1 was passed

Attached: 1433497841701.jpg (817x880, 67K)

Wrong.

Are typeclasses good or bad?

The reinterpret_cast Chad
vs
The dynamic_cast virgin

Attached: 1515611937146.jpg (720x707, 23K)

it's like you haven't even read

what do you mean by how do you use arraylists to do this?
arraylists are dynamic arrays.
you can think of permutations as trees.
b
ba, b@
bao, ba0, b@o, b@0
etc
and you're just doing tree transversal
you can use a arraylist as a queue, and push on each row of a tree and generate the next row.
excuse my terminology, i'm not properly educated.

>call a function that takes 2 arguments with 3
>language just silently proceeds with no errors or warnings and fucks up your data
>now you get to have fun debugging the application and hunting down where it fucked up

it's just default arguments. lots of languages have them. are you going to say those arguments are bad too??

No, but combined with ignorable arguments like javashit has, you get this unintuitive as fuck behaviour. map is map, map-indexed is map-indexed and they are 2 different things.

Where are applicative functors in Java and C#? Why aren't they in the standard libraries?

...

No HKTs lmao

Wait, really? How the fuck do they not have HKTs?

wow, it's almost as if you can't do that yourself
function constrainedParseInt(string, radix) {
check: {
switch (arguments.length) {
case 2: if (typeof radix !== "number") break;
case 1: if (typeof string === "string") break check; else break;
case 0: return NaN;
}
throw TypeError("user you're such a fucking faggot holy shit");
}
return parseInt(string, radix);
}

I don't understand this. I thought a hashfunc was supposed to take a key and return some integer (called a hash) that you would immediately take as representing an index in a hash table. Why is there this extra step of this "f" function? I guess it's so you can decide the length of your hash table, because "the hash is independent of the array size". My problem might be that I don't get how a hashfunc would actually be defined (I know there's many different ways to do it).

Again, I was under the impression that a hashfunc was defined like hashfunc: U -> {0,1,...,m-1} where U is your universe of keys and m is the size of your HASH TABLE. but in this pic, m would be the size of.... something else, and your hash table size would be defined in this "f" function.

also, I'm kind of confused about terminology. Like what the fuck is a dictionary? Is a hash table a dictionary? What's the "simplest" example of a dictionary data structrue there is?

Attached: f_function.png (714x288, 34K)

they're different though.

sure love having to implement basic compiler features with 10 lines of boilerplate at the top of every single function i write

>TypeError
Why do people just accept this backwards shit instead of realizing how important static types are?

if you are defining a custom hashfunc specifically for this one table that is probably how you would do it, but in many languages the default types already have built-in better-than-you-could-write hash functions

having one function that returns a value from 0 to MAXINT or whatever means you can re-use it in hash tables of any size without having to rewrite the function again for every implementation

That's basically what it does. The index might be out of range though. The f function just combines hashing the key with making sure the index is in range which is dependent on the number of buckets you're using.

hashfunc is U -> Z, distributing its shit uniformly over Z. that way your hashing value is independent of any table's size. what's U -> [0,m) is f.

stop posting my wife

>what the fuck is a dictionary? Is a hash table a dictionary?
yes, a dictionary is the same thing as a hash table: a mapping of keys to values. it's just renamed for high-level programming babbies who don't want to think about data structures

>JS
>compiler
now you have gone full retard

why would I do that when the compiler can just do it for me?

They serve different purposes. To the left ++i (pre-increment) increments i then returns the result. To the right i++ (post-increment) saves the result increments i then returns it. The latter is less efficent because of the whole save the result step and may require more instructions when compiled. Take a look at the generated assembly (without optimization ofc).

okay, that does make sense. because yeah in my view you'd have to have different hashfuncs for every table size. which i guess wouldnt be good. are there languages where it's something like hashfunc(key, tablesize) rather than hashfunc(key) and then apply that to f? that would be easy to do obviously. what's the "real life" standard there
and Z means what here?

the set of integers.

hashfunc(key) % tablesize is not really any harder to use than hashfunc(key, tablesize)

isn't the set of integers basically what U is? how would you uniformly distribute 0..MAXINT across 0..MAXINT again?

You said yourself that U is the universe of keys. It may happen to be Z, but it can also be anything else you can use as key in your program, no?

Most languages don't have them. Only JVM Lang that had them that I'm aware of is Scala.

>bikeshedding

I think you're wrong. I just compiled two separate binaries, and the diff showed no difference.

I should use your notation, my bad
hashfunc is U -> (0 .. MAXINT) distributing its output uniformly over (0 .. MAXINT). that way your hash function is independent of any table's size. It's f that's U -> (0..m-1).

what is the purpose of unistd.h?

Contain the definitions it contains, i. e. the basic Posix shit that's not in more specific headers like fork+exec, pid_t, abort (I think), etc.

well if a string is a key for example isn't there a totally separate "prehashing" process where you come up with a unique integer to represent a string? and theres other methods for float keys or any other type of key. so U is effectively always 0..MAXINT.
unless prehashing is not considered separate and is implemented in the hashfunc i guess?
like, in a "real life" language, if I did hashfunc(420) what would I get back? just 420?

Can I get the code for this? Thanks guys

Write a program that simulates a lottery. The program should have an array of five integers named lotteryNumbers. Using a method and the Random class (from the Java API) to generate a random number in the range of 0 through 9 for each element in the array and display the lottery numbers. The program should also have a method that accepts an array of five (5) integers that represent a person’s lottery picks. A third method is to compare the corresponding elements in the two arrays and return the number of digits that match.

If a user matches all 5 numbers, display a message that they have won the grand prize. Matching 4 digits is second prize and 3 digits is third place prize. Matching 2 digits or less should display a message to try again.

Attached: aerbvi.jpg (1200x800, 41K)

That's funny, most idiots ask for help with their homework.

Attached: 1519366595400.jpg (1600x1040, 147K)

Yes there is for some types, but U is still not 0..MAXINT, it's whatever the keys currently are. on some systems you have hashfunc(420) = 420 (e.g. Python, but not Clojure), but you also have hashfunc("someshit") = 420, and you wouldn't argue that "someshit" is in (0..MAXINT), would you?

Just make a function called lottery that returns false. It'll be more realistic that way, and no one will be able to tell anyway.

>5 numbers = grand prize, 4 numbers = second prize, 3 digits = third place prize
That's not how lottery works anyway...