/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1538931808092.jpg (1024x906, 64K)

Other urls found in this thread:

hackage.haskell.org/package/turtle-1.5.14/docs/Turtle-Tutorial.html
en.m.wikipedia.org/wiki/Timsort
twitter.com/AnonBabble

c++ was a mistake

Scala

breaking my Jow Forums addiction

Hey, Anone. I came over for the JavaScript lesson. Shall we begin?

Attached: 828c7ad865db58d10aae949ef1dae3e1.jpg (731x1024, 166K)

hmmm

Attached: 1562623001504.jpg (754x297, 43K)

nth for being locked in "which implementation is least shit" paralysis

('ba' + NaN + 'a').toLowerCase()

You're doing a great job.

first for SICP scheme

Attached: sicp.png (441x421, 176K)

Low latency microcontroller network communication

Python's syntax is garbage and javascript's behavior makes me want to puke, what popular language can I use for general scripting?

ruby

>classmate hard coded 48 functions that do the same thing instead of just receiving a parameter in one of them
I thought people made those kind of code just to get some laughs.

Attached: 154863287569251.jpg (600x600, 30K)

dumb android question: how should I be moving data from my fragment (a form for user input) to its view model?

people new to programming produce some truly retarded code
even more so if they don't care at all about the subject

A diahrrea language isn't better than a puking language

C#

suit yourself

>scripting
>C#

Attached: _91408619_55df76d5-2245-41c1-8031-07a4da3f313f.jpg (660x574, 31K)

that book
is ancient

>frog
Fuck off back to your containment website. You're not welcome here.

Attached: 1542859598835.png (538x538, 492K)

Grow up, webcuck

Attached: The ms paint troll family here are all the troll_93155f_4198195.jpg (720x720, 148K)

ancient wisdom

Why is line 12 O(nlogn)? The comparator isn't O(1), it does a O(klogk) sort, so isn't it O(klogk*nlogn)?

Attached: asdf.png (582x494, 164K)

sure why not? i write C# scripts all the time.

should be DETH(klogk)

Even slower than Python.

Not dedicated to scripting.

can't believe it's gone

Attached: sachiko.jpg (667x798, 63K)

hackage.haskell.org/package/turtle-1.5.14/docs/Turtle-Tutorial.html

Anyone has a recomendation for gfx framebuffer library for linux? Nothing fancy, I need to display lots of status text and some graphics.

Attached: jigsaw-puzzle-companies-use-the-same-patterns-1.jpg (758x590, 264K)

most scripts are going to be io-bound anyway

based, any good resources user?

Jow Forums is the containment website user

Did I do this in the worst way possible?
Seems awfully convoluted.

Attached: automate_question.png (1920x1080, 281K)

you're right, but you can say O(n log n) if you're only focusing on the complexity with relation to the length of the list. k is constant as n changes.

TimSort
en.m.wikipedia.org/wiki/Timsort

Make stuff and read source

Then why not use bash/awk/sed/perl instead? That sounds like a roundabout way to do it in haskell.

looks fine to me user. when you are starting out worry about problem solving and writing comments and thinking about the process iteratively in a way that makes sense(step 1 then step2) etc, efficiency and such will come later

>perl
it's dead, user
let go

Lua or common lisp.

God fucking damn it.
I really don't wanna fucking use python for christ sake. I can't even create one liners with that.

>Releases library
>Doesn't release documentation
why are people like this anons?

Attached: 1558675870228.jpg (720x960, 127K)

I dont know, I always considered Turtle a novelty. It seems to be fore people who like type safety but are very familiar with bash and would prefer to use wrapper functions named like bash programs over Haskell standard library functions.

no, there isn't really any better way.

Are nested for loops common? I suppose they would be with data structures, just seems to get a bit messy.

sometimes there is no way around nested loops. Many sorting algorithms need to utilize them. they arent necessarily bad, but once you start learning about data structures and algorithms you will see that nested iterations compound the runtime and turn O(N) into in this case O(N^2). Again its not really that important right now

People perfer to avoid nested loops (because it suggests that their aproach might be slow) but if you're going though a nxn matrix, the only way to do it is with nested loops

I did it like this
def print_table(table):
widths = [max(map(len, c)) for c in tableData]
for i in range(len(tableData[0])):
for c,w in zip(tableData, widths):
print(c[i].rjust(w+1), end="")
print("")

>surely they'll have atleast one example
>surely they at least commented
>issue opened, and in the nicest possible way, the grievances are stated
>dev gets extremely defensive, makes excuses and closes it
ah yes

Whoops, "tableData" should be "table" of course

Hmm, I see. Some methods in there I haven't learned yet, thanks for posting.

Got it, thanks

Rewriting my outdated django service

bash

Thanks.

hello friends, just started learning programming. Starting out with Python cuz my industry is chock-full of it.

I have two questions:

1- Do I need to convert all my variables to int like so manually or is there a way to convert all of them at once?

2- the function mydmg() makes the program crash (it used to work properly when it wasn't a function, but I'll need it to be one for later on). It says the local variable 'myatk' referenced before assignment, but it is obviously declared before I put it in the function, so I'm not sure what's going on here.

Attached: retard.png (656x389, 14K)

inb4

Attached: retard2.png (487x445, 39K)

1. This isn't C. You don't need to typecast everything. You only need to keep the odd lines for declaration.

2. The variable myatk doesn't exist in the scope of your function. Functions have their own scope. You perfectly can have a myatk inside and outside of a function and they'd reference different values. I don't exactly know what your function does (use more explicit function names please, so people know what they do) but you simply could have a parameter passed to the function and you could manipulate that variable like so.

def mydmg(myparameter):
myparameter = ...
.
.
return myparameter


Then in your main code, you simply pass the variable you want the function to treat like so:
myatk = mydmg(myatk)


hope that helps

I started learning programming about a year ago to work with a friend on medium sized company, started as frontend for webforms. I eventually fought my way through stackover flow as my papa.
Now that most of my code is clean and organized, I feel that I should learn a few more things.
Should I learn more languages or I should dive into testing?

Typescript?

Lisp is the most powerful programming language.

only thing i would recommend is use enumerate.

myhp = 1000
myhp = int(myhp)
You dont need to do this. Open the repl and do
>>> myhp = 1000
>>> type(myhp)

You can see myhp already an int. This is one reason I dislike python, its dynamic type system is supposed to be easier but ends up just being confusing.

functions only have access to stuff you pass into them. rewrite this as:
mydmg(my_attack):
print(my_attack)

#to call
mydmg(myatk)

How fucking new are you?
This is a serious question
You have an anime reaction image saved from last week

"le alt right meme frog" has been on this website since 2008
And if I could find every one of these dipshits that can only communicate their emotions through cartoon frogs and kill them all, I would. But you are a bigger idiot than them if you think pepe is a "reddit meme"

I gave up Perl because nobody uses it, do you REALLY think I want to use typescript over that lmao

Why is "other people don't use it" a negative, lack of libraries?

You can change any JavaScript library into a Typescript library with a Vim plugin. It's neigh identical

You're a stupid fuck. Where your stupid forced meme started is irrelevant.
It took off with redditors, and they drove it into the fucking ground and kept going, like they always fucking do.
That stupid frog wasn't even funny or endearing in any way to begin with, and should've fizzled mere hours after it was first posted.

No, that's a Jow Forums meme. Please only use 4channel memes.

import Text.Printf
import Control.Monad

padRight :: Int -> String -> String
padRight n str
| spaceLeft < 0 = take n str
| otherwise = replicate spaceLeft ' ' ++ str
where spaceLeft = n - length str

printTable :: [[String]] -> IO ()
printTable columns = forM_ rows $ putStrLn . unwords . map (uncurry padRight) . zip columnLengths
where
columnLengths = map (maximum . map length) columns
maxRow = subtract 1 . minimum . map length $ columns
rows = [[col !! index | col

Attached: 1544772124705.jpg (600x725, 65K)

Thanks for the help anons. I'll tinker for a bit and come back if I have results

>It took off with redditors
Jesus christ you are so fucking divorced from reality.
You can't even appreciate how divorced from reality you are. Stop just regurgitating some dipshit post you heard on reddit that they heard from some dipshit post on CNN.

The pepe ship sailed, came back, and then sailed again about 7 times before reddit discovered it in the year 2015.

What happened to this fucking website where trogladytes like you think it's acceptable to walk in and just say such abhorrently stupid things.
Seriously. What is it. The lack of Anonymous?

I will form Anonymous 2.0 if it means that retards like you will stop wasting digital real estate.

>map after zip
zipWith?

It's a negative because I wanna land a job. Otherwise I'd stick to what I know. It sucks but I need to advertise myself better. I just wanna know a neat scripting language, that isn't python or javascript, that is somewhat popular.

I'm working on my first sort of non-trivial project (a discord bot using discord.net). after failing to figure out how to read in my bot's secret token with environment variables, i figured out how to do with an XML config file. But it took me 3 hours to do. am i retarded?

Attached: BLkQYYy.gif (360x298, 554K)

This is probably wrong, but the cases i tested it works

Idea: find the len of the biggest word, and fill a buffer with that len. Then add the words to the list reversed so that the beginning of the word is aligned to the right with spaces.

In the end, just print the new table
def printTable(table):
glob,ss = [],0
for ele in table:
max_len = len(sorted(ele, key=len)[len(ele)-1])
lst = [" "*(max_len-len(j)) + j for j in ele]
glob.append(lst)
ss = len(ele)

for i in range(ss):
for j in range(len(glob)):
print (glob[j][i], end=' ')
print ()

if __name__ == '__main__':
tableData = [
['apples','oranges','cherries','banana'],
['Alice','Bob','Carol','David'],
['dogs','cats','moose','goose']
]
printTable(tableData)

tableData = [['apples', 'oranges', 'cherries', 'banana'],['Alice', 'Bob', 'Carol', 'David'],['dogs', 'cats', 'mouse', 'goose']]
reversedTableData = tableData[0].map((_, i) => tableData.map((_, j) => tableData[j][i]))
longestWords = tableData.map(data => data.reduce((a, b) => a > b ? a : b))
spacedTable = reversedTableData.map(data => data.map((str, i) => str.padStart(longestWords[i].length)))

lol, lambdas.

I'm sorry to break it to you user, but yes. taking time to learn something you haven't done before indeed means you are irredeemably retarded

>am i retarded?
Not really, the first time doing anything is usually slower. Next time you want to read an XML file it should be much quicker. I'm not sure you chose the best approach for it though, an XML config seems like overkill.

Thanks for the help, I got something working now.

Attached: slightlyLessRetard.png (636x307, 11K)

People die if they are killed!!!

Attached: 1531350755727.jpg (823x675, 79K)

CL-USER> (let ((table-data '(("apples" "oranges" "cherries" "banana") ("Alice" "Bob" "Carol" "David") ("dogs" "cats" "moose" "goose"))))
(format t "~{~{~,5:~^ ~}~%~}" (apply #'mapcar #'list table-data)))
apples Alice dogs
oranges Bob cats
cherries Carol moose
banana David goose

amazing

what's happening there

What languages are used for mobile game development; both iOS and android? Please respond

do you realize how much longer it took you to post this to Jow Forums.org then to simply google it

What languages are used in Unreal Engine and Unity?

english

How true is the claim that the gap between a novice and a competent programmer can be bridged fairly quickly with interest and dedication?

~{ is the list iteration operator
~< is used for justification
~a is an aesthetic operator, which just means the arg is printed without escape characters
~^ is the escape operator. it terminates the iteration if no elements are left to process. i use this in conjunction with a whitespace, so that a whitespace is output until the last element, then the iteration terminates.
~% is a newline operator.

Define fairly quickly.

wowie thanks for the positive responses!

And i used XML after not knowing how to use environment variables cuz i had no idea what else to do!

Do you mean i should have used JSON? or something else..

I was reading up on it and i heard XML is more than what's necessary for a lot of stuff but you can do more with it. so i figured i should just practice XML only and get super good with it then i will know how to use it when i make bigger stuff that it makes sense to use it for.

Or does that not make any sense? Idk i'm new to this.

Umm I think you can use C# for cross platform mobile game development with Xamarin iirc. I haven't used it myself yet but i read about it in a C# book that i'm using for other stuff.

Attached: 4193_Kirbyhappy.gif (128x128, 13K)

look at him, you're making pepe sad

very nice.

do you use common lisp in your daily job?

i wanna fug maya

lol nope i don't use that dead ass language for money
it's fun to play around with though.

All I meant is that if you only needed to input your token maybe command line arguments or even just hardcoding it might have been much simpler. Depends on your application and how much configuration it needs. Out of the 2 formats I prefer JSON, XML is very verbose and if you want to write in a text editor it sucks. Since it's already XML, keep it that way. Although I think .NET favors XML, so it might be the right choice but I'm not a C# dev.

What's the best language for a 22-going-on-23 yo?

Japanese

haha veru funi