/dpt/ - Daily Programming Thread

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

Attached: 1542429760764.jpg (2000x2833, 529K)

Other urls found in this thread:

en.wikipedia.org/wiki/Haskell_(programming_language)#Applications
pbr-book.org/3ed-2018/Preface.html),
nytimes.com/2018/11/24/opinion/sunday/vaginoplasty-transgender-medicine.html
package.elm-lang.org/packages/elm/browser/latest/Browser#element
twitter.com/NSFWRedditVideo

I'm going to do it! I'm going to program a waifu!

Godspeed.

Attached: karen haskell.png (1280x719, 818K)

Thank you for posting an anime image.

cute boy

No, it's a girl, you fag.

kys degenerate
you too

Fucking paedophiles why can't you just neck yourself already. It is that simple.

>Haskell

NO, NOT THANK YOU
THIS IS DISGUSTING

Yes, Haskell.

Attached: 81643.png (300x300, 109K)

redpill me on Haskell

The dick only makes it better, user. Join the other side.

it's great if you have to formally verify that your software is correct and sucks for everything else including but not limited to the process of learning it

It's a statically typed purely functional programming language with an expressive and strong type system.

Sounds kinda shitty then doesn't it, if learning the lang is bad, then how does anyone know it?

first you take a class in number theory, type theory, linear algebra and discrete mathematics.

After that you actually know the vocabulary and theoretical background to understand concepts like monoids, monads, dyadic function etc.

That's the point where haskell becomes fun. If you lack the background or necessity to learn it better stick to more common paradigms

ignore him

Ignore haskell

I generally do, I know a few languages and I generally stick to those

Today I did the Hackerrank question "Kangaroo" which asks me to check if two kangaroos will ever be at the same location at the same point in time.
This is my code:
#include
#include
#include
#include

char* readline();
char** split_string(char*);


char* kangaroo(int x1, int v1, int x2, int v2) {
static char *kangamet;
//Check if kangaroos ever reach same point at same time
for(int i = 0; i < 10000; i++){
if(x1 + (i*v1) == x2 + (i*v2)){
kangamet = "YES";
return kangamet;
}
}
kangamet = "NO";
return kangamet;
}

Attached: original.gif (420x236, 695K)

Good. Nothing of relevance has ever been done in haskell. Don't waste your precious time.
>but some guy has heard it's apparently maybe used in the financial sector for very secret internal financial modelling that no one ever has seen or heard about because it's like, very advanced and very private and shiet

Attached: 1543083928047.jpg (371x370, 80K)

en.wikipedia.org/wiki/Haskell_(programming_language)#Applications

think again

>Used by facebook
That's even more of a reason to steer clear of it

is this some low-key "we wuz kangz"?

That's what I just said, nothing anybody has ever heard of, except I guess xmonad for r/unixporn users.

Attached: 1515873322482.png (1209x1080, 674K)

Okay???

Jow Forumsijutsu, please give me motivation to finish my university homework for today.
I already solved the problem and wrote a working concept down on paper, I just can't sit down and program it.

Attached: 1514416524960.jpg (700x720, 111K)

Virgin Haskell vs the Chad Ada

Attached: IMG_20181118_061410.jpg (830x1744, 527K)

You can do it user!

>writes concept on paper
>doesn't write it as code immediately
why even chose a less expressive medium? All this does for you is double the writing work

geez, printing out words in a loop is so hard.

good luck

Attached: 1520662034224.png (171x553, 125K)

>less expressive
Are you literally stupid?

Attached: 1534133245401.gif (411x500, 218K)

>one can test if your idea actually works
>the other is a piece of paper

Take a good look at yourself animuposter

>Returning the result as a static variable
>Not treating string literals as const
>Forward declarations when they're not necessary
>Missing (void) on functions which takes no arguments
>Shit style
2/10

Attached: 1374577061478.png (303x323, 119K)

...

I don't think you know what the word "expressive" means. Not surprising considering how inadequate your posts are. I guess the leverage of formal logic is the only crutch you have. It's OK, I see a lot of programmers like that. Of course those are the people who give the rest of us a bad name, so, you know, fuck you.

do your homework yourself

How to program???

You don't need a computer to prove your program correct.
Running it for some random input means fuckall.

Attached: 1540481920707.gif (500x511, 759K)

imagine being such a butthurt autist to type that down

...

How not to program???

...

...

That is the question. Whether tis nobler in the console to compile the memory leaks and segment faults of outrageous coders, or take arms against a sea of inefficient practicality, and by opposing make them minisculely less profitable.

...

JavaScript rocks!

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

...

What is the end var? I don't see it referenced before it is called

A harddisk can only either write or read at any given time, right?

I just want to write Java or Python code and not have to deal with Javascript, CSS, and 10000 frameworks. What kind of work should I get into? Cloud stuff? Software as a service? I'm going to get a Master's eventually for Data Science but until then I gotta get money somehow. Graduating soon. What would you guys recommend?

Made a simple "guess the number" console application, having previously lost everything I made when my HDD took a shit, I'm still very new to coding but looks better than my first attempt at it.

First program replaced, now onto a custom calculator I used with frequent conversions I use built in.

Attached: 1486847180_apustus.jpg (1000x800, 53K)

I know the basics of programming but a honest question Jow Forums
How i can reset my mind about this field? Im stuck on loops/variables and want to start again

You mean like real job? Just be back-end. Nobody who has any money wants their UX/UI guys to be the same as their back-end guys. Any job that they're going to give to an entry-leveler like you would be one or the other.

'Physically Based Rendering' is officially free (pbr-book.org/3ed-2018/Preface.html), but does anyone have it in epub/mobi?

just finished the warmup ones in python, gonna skip to that one and see what the fuck is that about

import Text.Printf
import Text.Read (readMaybe)
import System.Random (randomRIO)

readInt :: IO Int
readInt = do
putStr "Enter number: "
num > nextTry
GT -> putStrLn "Too high, try again." >> nextTry
EQ -> printf "Correct! It took you %d tries.\n" tries
where nextTry = guess' (tries + 1) num

guess :: Int -> IO ()
guess = guess' 1

main :: IO ()
main = randomRIO (1, 100) >>= guess

Attached: 1516648685389.png (940x720, 376K)

>recursion

that doesn't look like c#
thought ">>" was a python thing, no?

ahah what the fuck
def kangaroo(x1, v1, x2, v2):
dist = x1-x2
speed = v1-v2
print(dist, speed)
if dist == 0: return("YES")
if dist > 0 and speed >= 0: return("NO")
if dist < 0 and speed 0: return("NO")
else: return("YES")

How do you exit?

By entering the correct number, baka

Bzzt, wrong

LITERALLY works on my machine

Attached: file.png (1139x258, 37K)

Random random = new Random;
int correctNum = random.next(1, 21);
string guess = 0;

while (guess != correctNum)
{
string input = Console.readLine();
if (!int.TryParse(input, out guess))
{
Console.WriteLine("invalid entry nigga")
continue;
}
guess = Int32.Parse(input);

etc etc

I was under the impression four spaces before a line of text would cause it to post as 1337 code, I've been had

Attached: 1540783906467.jpg (842x699, 50K)

read the sticky before posting

>completely missed that
Gosh darn don't I feel like a retard

Attached: 1517686064_1516710225628.jpg (600x485, 40K)

Jow Forums always talks about how one shouldnt become a code monkey who just knows syntax or copies stuff from online. However, how should one learn programming and from what sources to avoid such bad habits? Im currently learning basic bitch C because thats whats recommended and thats whats relevant for me.
However, I feel like reading into C alone wont allow me to do stuff beyond basic calculators and shit. Are there any books/concepts to look up?

Attached: 1491830911011.png (1024x768, 676K)

6.0001, 6.006, and 6.046 from MIT Open Courseware are a good starting point. You can find playlists for all of them on youtube
The actual MIT site has problem sets, materials, etc.

>What are you working on, Jow Forums?

This random integer generator:
!
! Generate a random integer in the range of 0..(m-1).
!
integer function Random_int(m)
implicit none
integer, intent(in) :: m

real :: rnd_num
integer :: rnd_int

integer, dimension(4) :: timeArray
integer, dimension(12) :: seedNum

! Get current hours, minutes, seconds
call itime(timeArray)
seedNum = 1*timeArray(1) + 2*timeArray(2) + 3*timeArray(3)

! Initialize the random number generator.
call random_seed(put=seedNum)

! Get random number 0.0 .. 1.0
call random_number(rnd_num)

! 0.0 .. 1.0 * m, convert to integer
Random_int = floor( rnd_num * real(m) )

end function

How to force memdump a C program in a POSIX compliant system?
if it's impossible, what is the closest thing possible to memdump?

I'm a beginning Java programmer, right now as a hobbyist but planning to switch to doing it professionallylater in the future. I don't have great ambitions, I just want a better job than what I have now. I'm also not picky when it comes to what I would actually work on. I think I'll be ready to apply for entry level jobs 6 to 12 months from now. So far I've learnt basic Java and Spring, as well as the basics of SQL and JUnit testing. I don't know Javascript, HTML or CSS very well but I'm willing to learn if need be.

Are there any new technologies or frameworks I could start learning now or soon to have some kind of a head start over other beginners a year from now? Something that's not very popular now but will be much more important in the near future?

Java is old. If you are trying to invest in the long term, you shouldnt be getting into Java. I think Java is still the biggest language there is, just in terms of how much code is actually running in the world right now, but thats a different question from how many _new_ projects are written in Java. Not as many. If you are getting into coding, you will be contributing to new projects, not old existing projects.

The projects I have worked on have had their backends written in:
Go
JavaScript
Scala
Ruby
Elixir

And I would say Elixir, Scala, and Go are better representations of the future than Java.

I dont think you really have to learn JavaScript, HTML, or CSS. Maybe you should know it a little bit. People seem to go frontend or backend in their specialty. Learn JavaScript HTML and CSS if you want to go frontend, otherwise dont sweat it.

Hope that helps. You might know better than I do what the actual requirements for the opportunities youll face.

>using continue in C# does not increment the loop variable
Lmfaoing at microcucks so hard right now lol

More information needed.
Source?

search on libgen pdf version

def fastexp(x,y):
p=1
s=x
r=y
while (r>0):
if (r%2==1):
p=p*s
s=s*s
r=r/2
print("%s^%s = %s" % (x,y,p))

def slowexp(x,y):
out=1
for each in range(y):
out*=x
return out
def timeit(x,y):
start=time()
fastexp(x,y)
end=time()
print("total time for fastexp: %s" % int(end-start))
start=time()
slowexp(x,y)
end=time()
print("total time for slowexp: %s" % int(end-start))
start=time()
builtin=x**y
end=time()
print("total time for built-in exponentiation: %s" % int(end-start))

>>>timeit(1000000,100000)
total time for fastexp: 9
total time for slowexp: 5
total time for built-in exponentiation: 0


They told me it was faster

>total time for built-in exponentiation: 0
Better to use the built-in exp then.

guess so

1. You are printing in the 'fast' one, which is very slow

2. If you are worried about speed like this in python, you should stop using python.

>Random random = new Random;
Already fucked up in the first line

Attached: 1520944146549.png (316x317, 152K)

Your bug is that division in python promotes to floating point, so you're iterating about 1000 extra times until floating point can't represent a smaller number. You want the floor division operator //
Also, use the python profiler, i.e import cProfile to time python, not time(). You could improve performance by dividing and checking r == 0 before you do the s*s multiplication, since that's a very expensive operation.

nu/g/ BTFO
My New Vagina Won’t Make Me Happy
nytimes.com/2018/11/24/opinion/sunday/vaginoplasty-transgender-medicine.html

My current code in python 3. How the fuck do I fix this to follow the prompt? I know I'm missing some parts of the prompt with this.

import random


def main():

nums = []

for n in range(8):

nums.append(random.randint(10,100))

print('Here is the list of randoms')

for num in nums:

print(num,end=' ')


print('the highest number on the list is',nums[7])

print('The smallest number in the list is',min(nums))


list2 = change_list(nums)

print('change_list returned this sorted list...')

for num in list2:

print(num,end=' ')


def change_list(mylist):

nums2 = mylist[3:-3]

print('The size of the list is now',len(nums2))

nums2.sort()

return nums2


main()


I know this isn't the exact results for the prompt.

Attached: vivaldi_2018-11-25_10-31-36.png (1141x694, 80K)

It's a powerful and elegant language. It ignores tradition, even relative to other functional languages, so it's a bit hard to learn, but it's fantastically powerful once you have some experience.

>what happens when baby tries writing his code from memory outside of an IDE
my bad, here..
Random random = new Random();

Attached: 1541550804908.png (248x200, 14K)

Yeah a real job. I hate Javascript, I hate it. HATE IT. I just want to code in a real programming language and not have to deal with all that bullshit.

Install Elm, it has a specific feature to slowly let you convert your JS codebase to Elm.
package.elm-lang.org/packages/elm/browser/latest/Browser#element

Trying to get tf-gpu working in my new build, the one thing that absolutely needs to be installed on bare metal is a huge pain in the ass, competing solutions, finally I'm just trying conda install tensorflow-gpu because at least I don't have to sift through 50 github issues.

I remember when I did this on my mbp I gave up because it wasn't really worth it.

Attached: Screenshot from 2018-11-25 10-49-46.png (726x427, 78K)

didn't people say that about lisp as well?

they're equally useless.

Friend wants me to make him a small system that handles incoming contracts automatically in his company and is accessible from web. Django or Laravel if I care mostly about development speed?

Attached: 1543102406429.png (1677x1080, 1.87M)

Hope he's paying you.

Yes.

dumb frogposter

Version 2 of random int generator.
!
! Generate a random integer in the inclusive range of n..m.
!
integer function Random_int_get(n, m)
implicit none
integer, intent(in) :: n
integer, intent(in) :: m

real :: rnd_num
integer :: rnd_int
real :: temp1, temp2, temp3

! Get random number n .. m
call random_number(rnd_num)

! Get difference between (max.+1) & min. values
! Value := m+1 - n
temp1 = ( real(m) + 1 ) - real(n)

! Scale difference with random 0.0 .. 1.0 value.
! Range of values := 0 .. m+1-n
temp2 = rnd_num * temp1

! Min. value is added.
! Range of values := n .. m + 1
temp3 = temp2 + real(n)

! Conversion to integer. int() rounds downwards, so for
! example int(1.9) = 1
! Range of values := n .. m
rnd_int = int(temp3)

Random_int_get = rnd_int
end function


How I tested it:
!
! Randomize the contents of an integer array "a" of size "n".
!
subroutine Array_shuffle(a, n)
implicit none
integer, dimension (:), intent(inout) :: a
integer, intent(in) :: n

integer :: rnd_num
integer :: i
integer :: j
integer :: t

do i = 1, n-1
j = Random_int_get(i, n)

! Swapping a(i) and a(j):
t = a(i)
a(i) = a(j)
a(j) = t
end do
end subroutine

but why