/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1546887471829.jpg (456x578, 58K)

Other urls found in this thread:

shenlanguage.org/professional.htm
shenlanguage.org/download.htm
shenlanguage.org/osmanual.htm#10 Sequent Calculus
dreamsongs.com/Separation.html
docs.racket-lang.org/guide/define.html?q=curry#(part._.Curried_.Function_.Shorthand)
cheminfo.org/Tutorial/8._Images/9.7_Create_a_PNG_image_in_javascript/index.html
twitter.com/NSFWRedditGif

cute

Second for Lisps

What do you love most about JavaScript, /dpt/?

A-Anone!!! Stop saying weird things to me when I'm trying to learn JavaScript!

Attached: D-WjvXOVUAEjAIS.jpg orig.jpg (1366x2048, 278K)

Is it elite to write a CHIP8 emulator and some programs for it then move on to C64 emulator?

I want to move on from being a Python babby.

Attached: ching-yeh-ruiner.jpg (1920x2487, 1.56M)

>elite
Not sure that's the right word but you will be better by the time you accomplish those things.

why is OOP considered to be a bad thing? i dont get it desu

multi-inheritance, and the over-whelming chance that any sufficiently complex OOP code-base gets over-engineered and you end up having factoryFactoryClassBeanExtenderFactory everywhere.

because you haven't experienced enough of it yet, or too much...

Given two strings s and t , write a function to determine if t is an anagram of s.

Example 1:
Input: s = "anagram", t = "nagaram"
Output: true

Example 2:

Input: s = "rat", t = "car"
Output: false


Note:
You may assume the string contains only lowercase alphabets.

Just sort it

>be me
>interviewing some dude for a janitor position
>ask him to solve an anagram coding question
>the faggot says: "Just sort it"
>threw him out

Why does
((symbol-function '+) 1 2)

give me an illegal function call error?

name a better solution senpai
protip: a hash map is going to perform worse

int s_count[26] = { 0 };
int t_count[26] = { 0 };
for (int i = 0; s[i]; i++) {
s_count[s[i] - 'a']++;
}
for (int i = 0; t[i]; i++) {
t_count[t[i] - 'a']++;
}
for (int i = 0; i < 26; i++) {
if (s_count[i] != t_count[i]) {
return 0;
}
}
return 1;

I brainfarted on string iteration but whatever.

only works with the english alphabet

doesn't work for
s = 'ayyyylmaoooooooooooooooooooo'
t = 'ayyyylmaoooooooooootoooooooo'

In python3, what is the best way to detect a keystroke? Preferable need a solution that works on Linux and Windows. input() is fine, but I need a way to get input without having to press enter.

that's a Palindrome

Attached: 1555425914770.gif (513x640, 2.69M)

Should I fall for the Shen meme?

install pygame for handling key inputs

Yes it does.

>paying for a programming language
lmao

Because Common Lisp isn't Scheme and requires FUNCALL to do such a think.

Meant for .

In common lisp there's 2 seperate namespaces, 1 for functions and another for variables. Where an identifier is decides how it's evaluated, in your case it's treated as a value. These are 2 different a's.
(a 1 2)
(+ a 2)
That's why when you want to use a function as an argument you need to prefix it with #'. If you want to do that use funcall.
(funcall (symbol-function '+) 1 2)

Scheme doesn't have these problems.

bool Solve(string s, string t) =>
s.OrderBy(c => c).SequenceEqual(t.OrderBy(c => c);

paying???

>s_count[26]
>input has len of 50
>'???
>crash

>missing )
fuck if I can program today

Attached: 6c111faeb9508591da615277eb74971d.jpg (1160x1144, 577K)

Are Schemes the better Lisps?

>OrderBy(x => x)
>GroupBy(x => x)
What a disgusting language.

Retard.

Imagine if there was a lazy Scheme that wasn't just for toying around.

do you consider racket a scheme

>Retard
nevermind i get it now
it's for the letters

ba dum tss

yeah
shenlanguage.org/professional.htm
The free version lags behind, has less features and doesn't even have a manual lol

you don't have to pay for shen.
You're just paying to use their shitty cloud service that comes with libraries, an IDE, and a premiumâ„¢ compiler.
shenlanguage.org/download.htm
shenlanguage.org/professional.htm
If you're interested in Lisp, but want a completely new kind, go for it.You'll probably want to read up on Sequent Calculus though, if you're a mathlet.
shenlanguage.org/osmanual.htm#10 Sequent Calculus

Will check it out, thanks user.

What would you rather have, faggot?
this?
groupBy (\x -> x) $ orderBy (\x -> x) data

>x => x
still better than underscores or special names desu

That is a really stupid way to do inductive definitions.

idk
but I heard once that the best Schemes are the ones who deviate from Scheme but are based on Scheme

doing something very simple like continuously pasting a line in VSCode will use around 20% of all 8 threads in my PC

doing the same thing in Vim uses 1-2% of them

isn't this very bad? my t440s thinkpad with 4 threads just goes to shit whenever I try to draw a moving circle on an html5 canvas for example and have VSCode on the side.

>Scheme
>not just for toying around
fuck

Why do you think that?

from collections import Counter

def solve(s, t):
return Counter(s) == Counter(t)

Who wants to do ASCII art when you can just write constructor : A -> (x : B) -> C (f x) -> D x?

Is there some Scheme->Lisp guide? I feel like I'm bashing my head my head against a wall because I'm stuck thinking in Scheme.
>Where an identifier is decides how it's evaluated, in your case it's treated as a value.
but why?
(symbol-function '+) returns # which is like #', right?

Racket isn't just for toying around

>Counter
>sorted
What is wrong with python lib designers?

That's a value, it's not treated as a function.
(+ 1 2)
(funcall #'+ 1 2)
(#'+ 1 2) ; error
That's pretty much it, you can read some historical shit if you want.
dreamsongs.com/Separation.html

isAnagram a b = sort a == sort b

eh, you aren't wrong. But it's nice to try new things. Especially a language where math(s) and programming meet even closer. But they really need to drop the 1990s freemium software shit regardless.

Is this the proper way to determine Python version in a shell script?

version=$(python3 --version | awk '{ gsub(/\./, "", $2) ; print $2 }')

What are some casual filters in programming?

idk if there's a guide, you're just gonna have to learn common lisp in its own terms and not have baggage thinking from scheme

here are some tips
symbols denote both values and functions
as such, we can do this
(let ((car nil))
(car car)) => nil


which brings me to my next point
nil is a special list in which its car and cdr are itself
(car nil) => nil
(cdr nil) => nil

this is by design because it helps out instead of hinder like () would for when using cdr and car
nil is also a boolean denoting falseness

you can also define functions within let bindings in lisp
(let ((x 1))
(defun x () x))

in scheme you can't do this
(let ((x 2))
(define (vx) x))

vx will be local to that let binding only for design reasons too, such as this
(define (f)
(define local 9)
local)


this is very nice in my opinion and i'd rather have it since I can do closures in scheme too, albeit differently

There's so much more, but you're gonna have to find out yourself.

filter, sometimes where
as long as the language has generics tho

>What is wrong with python lib designers?
they are better than you

writing an actual, non-fizzbuzz level program without using any POO.
immutability
not using globals
purity
basically the things that help prevent shit code

pyv="$(python -V 2>&1)"
echo "$pyv"

#or

racket has lazyness?

Comments.
No joke.

There's the lazy racket language you can use but nobody does.

Just figured out I can use the pychromecast module to control the volume on my tv from terminal:
#!/usr/bin/env python3
import sys
import pychromecast

volume = float(sys.argv[1]) if len(sys.argv) > 1 else None

casts = pychromecast.get_chromecasts()
pucci = next(filter(lambda x: x.device.friendly_name == "Boipucci", casts), None)

if pucci is not None:
pucci.wait()
pucci.set_volume(volume * 0.01)

I tried it before, seems really complicated.
I'll try it again though.
Also, Does it have currying?

Probably not the right place to ask but how do you get vsync to work in vmware? I have a dev environment set up and I'm working with SDL. Enabling vsync on actual hardware works fine but on a similar install on vmware it's not detecting it.

Attached: 1562087840799.gif (500x400, 640K)

Not with that retarded design.

Probably the most noticeable one.

((curry + 1) 1)
or
docs.racket-lang.org/guide/define.html?q=curry#(part._.Curried_.Function_.Shorthand)

I want to learn cobol but don't know where to start. I heard that it doesn't work on PCs and you have to get a used ibm mainframe to use cobol. Can someone clear this shit up for me if it's true?

>I want to learn cobol
We can discuss this through don't kill yourself

is your GPU actually passed through?
Regardless i would not develop a game on a VM

It may not be.
Fuck it, I guess I'll just switch over to linux when programming.

Attached: 1561924666756.jpg (1920x1200, 304K)

Code duplication. Every bad programmer I've seen always ends up duplicating lots of code. Good programmers never duplicate code. This is the number one indicator if you ask me.

Unless you play a game with EAC, or have shit hardware but still want to play AAA games, there's really no reason to have Windows anymore.

Alright, thanks. I'm not really convinced of the benefits yet (how often do you actually want to call a variable just like an already existing function? Seems like it'd get confusing pretty fast), but I'll try to get used to it.

It's 2019, you'd think that by now VMs would have accurate GPU emulation, even with a performance hit it would still be useful for programming multiplatform graphics libraries.

Just use WSL 2. It's a million times better than vmware.
I legitimately think that windows with WSL2 is the best development OS, because you get the non garbage drivers of windows with the nice dev environment of linux.

A module for a drone to shoot or suicide bomb ugly people.

Yeah, I don't have the greatest hardware (an AMD FX8350 and GTX 980) and I still like to checkout newer releases.

I'll check it out. Thanks for the tip.

Attached: 1561803477459.jpg (1476x990, 402K)

>I legitimately think that windows with WSL2 is the best development OS
nah, an OS where you have to cross your fingers everytime you want a system update is not good. Nor are fighting the insanity of KB update dependencies. Never again.
just install linux lad.
Give OpenSUSE tumbleweed a try.

>an OS where you have to cross your fingers everytime you want a system update is not good
you clearly talking about linux there

>What are you working on, Jow Forums?
Maintaining legacy code, patiently waiting for payday.

Attached: the yale thing.jpg (947x404, 93K)

ALGOL? LMAO?

asking here because webdev is dead, and this is the gui of a c++ program of mine
Suppose I have a html webpage that has an image. It usually requires a src path to the image to be displayed.
Using javascript, is it possible to create an image programatically and display it? Or maybe manipulate the pixels of the image and display it?
How should I approach this?

Not at all, but atleast on the off-chance something does go wrong, it actually gives me useful information that i can use to fix. Not just
"whoops something happened :^)". There's been so many times, windows updates "fail" and i just spam try again and they eventually go through. Or the opposite, of no matter what i do, shits just borked and i had to reinstall. I never get that bullshit with linux, probably because i stay away from Mint and other shitty distros you might have used.

works on my machine

I already have. I just was using a virtualized dev environment for convenience so I wouldn't have to reboot from Windows to linux.
Whatever. Having to switch OSs helps me focus anyways.

Attached: screenFetch-2019-07-10_17-39-35.png (3840x1080, 2.74M)

cheminfo.org/Tutorial/8._Images/9.7_Create_a_PNG_image_in_javascript/index.html

Google 'javascript canvas"

rat and art aren't anagrams

you don't know what an anagram is

shieet sorry

hehehe

Attached: 1562795075975.png (1133x984, 157K)

>canvas api

Attached: 47690975_360002311481613_5744804284340907067_n.jpg (540x473, 103K)

Is shellcheck all I need to make sure my shell scripts are written well?

>Annual pay: $40.000

Junior Apprentice Software Engineering Intern?