/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: dpt.png (1618x1308, 1.95M)

Other urls found in this thread:

github.com/airbnb/javascript
zelda30tribute.com/
xml.com/ldd/chapter/book/ch13.html
sarabander.github.io/sicp/html/1_002e2.xhtml#g_t1_002e2_002e2
en.wikipedia.org/wiki/Knapsack_problem
en.wikipedia.org/wiki/ACID_(computer_science)
smatchcube.github.io/SICP/Ex1.13/
github.com/lukehoban/es6features
twitter.com/NSFWRedditGif

nvm I figured it out

fuck the ackerman function

>Baby's first compilation

Trying to go through the Programming Pearls book exercises. For some reason though I can't understand the solution of one of the first exercises related to bitwise operations, guess I'm just retarded.

Attached: 47b.jpg (665x574, 29K)

Which scheme do I use?

guile or racket

C++22.

>implying c++ will still be used in 2022, and that people won't write every program on electron

fn longest y.len() {
x
} else {
y
}
}
[
>rustfags will defend this

Ahem

Just wanted to say

FUCK JavaScript

That's it

this doesn't work if you dont have that pepe image with the microphone

More like C++32

Is there a linear iterative solution for the problem of finding out how many ways we can spend AMOUNT of change given N unique coins (their monetary values are given too of course) (assume you have infinite amount of coins) (i.e. you can't run out of coins)

>It's a purposely writes verbose code episode

The same code in C is half the length. Rust is literally just for memers and SJWs.

>it's a "let's make everything concurrent" episode written by people who don't know what they actually want is parallelism

Attached: 516R4ZoMqBL._SX258_BO1,204,203,200_.jpg (260x321, 15K)

chicken scheme

do you mean find the next way in O(n)? i assume there are more than n ways of finding coins

im learning sicp right now, it describes recursive functions which recurse lineraly as "linear iterative", in contrast with "linear recursion" and "tree recursion"
basically, this describes how much that stack grows
linear iterative = no stack growth
linear recursive = n stacks added if n recursions are done
tree recursive = exponential number of stacks added because more than 1 recursion was done for each recursion done

How am I supposed to compute the elements if they're in a triangle.

Attached: 2018-12-16-031806_308x218_scrot.png (308x218, 4K)

Winter Break is starting this Thursday. What functional language should I write in this winter?

Erlang?

Any reason to use it over Haskell? I think I'm between those two.

Can someone give me a run-down of "web" ""frameworks"" for a mostly embedded C/C++ dev? What exactly do these frameworks do, let you code up, basically, a custom apache/nginx backend? Then programatically generate html and javascript? Seems useless, but it's all I see on reddit and HN nowadays.

Think of it as a right angle triangle instead and store it in a 2D array where each row is longer than the last.

Hey Jow Forums

I'm newer to programming still, but I'm writing this little chrome extension that basically just adds some filtering options to a table on a certain webpage.

I just wanted to get any general feedback, is there anything super wrong with the image, red flags? Any bad habits I should break etc.

Attached: Code_2018-12-16_03-31-25.png (848x616, 27K)

Brainlet here
Can I use CodeBlocks to learn Python or am I better off using some embedded deal online?

>javascript

Do you have another suggestion for this particular application?

Also, why do you not like javascript? It's seemed pretty nice to me so far.

Why the hell are you not indenting the function? And before the buy.childNodes, why are you indenting there? There's a lot of other style issues there.

While this script is small and they will probably not matter a lot, they really impact when you start writing bigger codes.

A highly recommended style guide is the Airbnb Style Guide github.com/airbnb/javascript

>Why the hell are you not indenting the function?
Oh yea, I did forget this, my other functions are indented.

>And before the buy.childNodes, why are you indenting there?
I indented to separate the foreach function, seemed more readable to me that way.

>While this script is small and they will probably not matter a lot,
It is small, but it's a fair bit bigger than what's shown, but that function seemed like the best example.

As far as style and readability, it's most;y subjective right? I feel like everyone has an opinion how how to structure your code, it's kinda silly to me that so many people insist on their way being correct when there seems to be very little consensus on the subject in general. Anyways, thanks for the feedback ^^

>tree recursive = exponential number of stacks added because more than 1 recursion was done for each recursion done
Can be logarithmic

That's a terrible idea, you would have a triangle of the same size full of zeros

Each line is one longer than the next, so you can calculate the next index pretty easily

n is the row of the element starting at 0
k is the index of the element in the row from the left (or right because symmetry) starting at 0
element formula is n choose k or

n! / (k! (n-k)!)

>they're in a triangle
checkmate atheists

>buy.childNudes

Attached: 1499522777662.jpg (500x500, 39K)

I heard from my proff that Elixir is the future?

>you would have a triangle of the same size full of zeros
2D arrays don't have to be square doofus

Learning sfml

>sfml
Why not SDL? SFML is a meme

I hope you make lots of sexy videos with it

>Needing libraries to wrap over your native window system
What a baby. Real programmers use libxcb or libwayland-client directly.

Attached: 1520933874594.png (782x1021, 330K)

>programming games on linux
ishygddt.jpg

I read a little and avoided my project today. I'm working on a game using electron.

I also found the github repo of the 3d voxel version of the original Legend of Zelda zelda30tribute.com/

All the assets are still there. I hosted it on my local machine using node and it still works in Firefox. It won't load in chrome for some reason.

Attached: the-legend-of-zelda-04-06-16-1.png (1600x770, 230K)

Who said anything about gaymes?
Also, why wouldn't I program for GNU/Linux?

>I'm working on a game using electron
Please user, we've already been over this.

Attached: 1497355531744.jpg (236x113, 8K)

If your program needs a gui use electron.

My program is actually the display server itself, but can run nested inside other display servers.
>electron
Never program anything ever again.

I've already got events figured out. I can use the keyboard to change the coordinates of a character and it supports multiple key presses. I've disabled the menu bar and it goes full screen. You autists won't even realize it's an electron app when you play it.

I'll notice the 15GB of memory usage.

Hot reloading, easy to scale concurrency out of the box, convenient build tool (rebar3).

One instance of node and chromium won't eat all your ram. I can run native C code and use the framework for the front end.

>using hardware acceleration for anything that isn't a game
Just use QT you retard

Yes, I know SDL and the like are not actual graphical toolkits. I was acting smug because I've written hardware-accelerated software that is actually useful using both libxcb and libwayland-client.
>Qt
>C++
No fucking thanks.
GTK is shit too.

>graphical toolkits
GUI toolkits, I really mean.

>using a GUI for anything that isn't a game
Just use the CLI you low IQ

Programmer entrepreneur here. Just finished two multi-year projects successfully.

I have skill, time and capital. Pitch me some radical ideas.

Write it in Javascript, then you can deploy it on the web or bundle it as an Electron package that can run anywhere

Write a program that automatically detects, reports and hides all frogposters.

Attached: 1501061418619.png (787x830, 674K)

Attached: vomit.jpg (650x650, 90K)

How is that going to make money?

make an app with which honest people can easily report Kufirs

You're supposed to be the entrepreneur here, buddy.
Make it work.

or this. Yeah, definitely this!

Attached: 9912962-3x2-940x627.jpg (940x627, 57K)

Even I agree with this guy for once.

Attached: hillary-thumbs-up.jpg (296x360, 24K)

You can write that in an afternoon - you just need a dataset of frogs and a neural network.

That's undergraduate level shit.

I know it's not particularly hard, it's just something I want and can't be bothered writing myself; I'm busy doing other stuff and machine learning doesn't interest me.

Depends.
If you are learning programming with SICP go for mit-scheme. If you are learning from another ressource use racket. If you want to create a real program use guile.

You don't actually have to know shit about machine learning to use the libraries. They're so high level even retards can use them.

reading this fun book
xml.com/ldd/chapter/book/ch13.html

Some of your variable names are pretty bad, for example what do e, p, and r hold? Longer variable names won't hurt you and will make your code more readable. Also your really long if statement could be trimmed down by storing all those numbers in some data structure so you can just say something like if (!pileONumbers.search(item)).

You should just use a regular text editor and the command line and not an IDE

This reminds me of a similar problem from SICP: sarabander.github.io/sicp/html/1_002e2.xhtml#g_t1_002e2_002e2
(just go to the counting change example)
Your problem seem to be related to this problem : en.wikipedia.org/wiki/Knapsack_problem which don't have a polynomial time algorithm.

Trying my hand at web scraping for the first time. Site has some data I'm interested in but doesn't provide direct download.

Currently using python requests for get and post requests to interact with the postgres api

Agreed, though the IDE feature of seeing memory is nice.

rate pascal's triangle solution

; sicp 1.12
(define (range row)
(if (= row 1) '(0 1) ; fuck 4channel pretty printing '
(let ((pend (cadr (range (- row 1)))))
(list pend (+ pend row)))))

(defun (row n #:optional (r 1))
(match-let (((start end) (range r)))
(or (and (

I've never taken a proof's class, how am I supposed to prove this?

Attached: 2018-12-16-054031_693x158_scrot.png (693x158, 31K)

Give me ideas you NEETS.

Attached: image.jpg (228x240, 51K)

Attached: just like that.jpg (1000x800, 61K)

They already solved half the problem for you
Just simplify until you get n(n-1)

triangles - I don't see any - 0/5
Pascal - looks like Scheme to me - 0/5

I ask the user if they are vegetarian, vegan, or gluten-free, and then give them a list of suitable restaurants.
boolean asking = true;
boolean chooseV, chooseVg, chooseGf;
while (asking) {
System.out.println("Is anyone in your party a vegetarian?");
System.out.print("\t");
String input = kbd.nextLine().trim();
if (input.equalsIgnoreCase("yes") || input.equalsIgnoreCase("y")) {
chooseV = true;
asking = false;
} else if (input.equalsIgnoreCase("no") || input.equalsIgnoreCase("n")) {
chooseV = false;
asking = false;
} else {
System.out.println("Invalid input. Please enter \"yes\" or \"no\".");
}
}
// repeat for Vg and Gf
// print

The compiler isn't certain that choose(V|Vg|Gf) got initialized. I'm aware I could just initialize them where I declare them, but I wanted to know if that's a good habit or if I should do something else.
>why aren't you using a loop to ask each question
My instructor wants us to pretend to be retarded and not use structures that are introduced later in the book than the exercise we're working on

Why?

Attached: el torito.png (478x523, 14K)

The people reviewing your code will know you didn't forget to initialize them if you set them explicitly.

garbage solution
just use recursion and think of the proper way to use previous solutions to solve the current problem, and the base cases where you just return 1
(define (pascal index row)
(if (or (= index 1) (= row 1) (= index row))
1
(+ (pascal (- index 1) (- row 1))
(pascal index (- row 1)))))


(define (pascal-row index row)
(if (= index row )
(display 1)
(begin (display (pascal index row))
(display " ")
(pascal-row (+ index 1) row))))

(pascal-row 1 6)
=>1 5 10 10 5 1

If you have a database you want to write to and read from, how do you set it up such that the read & write operations don't interfere? Do you basically have to do a double buffer sort of thing? Or does some databases handles this sort of thing for free?

transactions?

Is Composing Programs the SICP heir? If not, which one?

mutex?

Yes

en.wikipedia.org/wiki/ACID_(computer_science)

They do it for you.

If you need to do multiple reads/writes at once, use a transaction.

Is this your solution to exercise 1.12? You don't have to print the triangle, just give the value of an element.
Just follow the hint and use induction.
Here is my solution: smatchcube.github.io/SICP/Ex1.13/
Hint: this has nothing to do with programming and it's the only exercise you can freely skip.

>skipping any exercise
Maybe if you're a brainlet. If you don't know how to solve proofs, our industry is better off without you, desu

there were no specifications though
give me some credit, I only worked with an index
is it garbage because of LOC count?

Relational databases do this by default (google two-phase locking). If you have queries that write values in different tables just enclose that query with begin/end statements.

yeah I should rename it to just pascal

i dont know anything about proofs, the only thing I know is that induction has to do with recursion, maybe i'll work my way from there, thanks

You're not using modern JS. At least use ES2015. github.com/lukehoban/es6features

dumb frogposter

Attached: 93230bca0163142ae327f140415f86b777abeff6.png (1300x1024, 1.53M)