/dpt/ - Daily Programming Thread

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

Attached: 1562166510121.png (602x800, 387K)

Other urls found in this thread:

github.com/paperduck/shiritori
port70.net/~nsz/c/c11/n1570.html#6.3.1.1)
youtube.com/watch?v=f84n5oFoZBc
youtube.com/watch?v=E4RarTAZ2AY
youtube.com/watch?v=xzTH_ZqaFKI
youtube.com/watch?v=edpifsVcurs
youtube.com/playlist?list=PLUFkSN0XLZ-n_Na6jwqopTt1Ki57vMIc3
twitter.com/NSFWRedditGif

Oh my god what's the legit thread now.

TableA
+----+----------+--------+
| id | name | value |
+----+----------+--------+
| 1 | Value 1 | 123 |
| 2 | Value 2 | 321 |
+----+----------+--------+

TableB
+----+----------+--------+
| id | user | status |
| 1 | 1 | 2 |
| 1 | 3 | 0 |
+----+----------+--------+

TableC
+----+----------+--------+
| id | idTA | idTB |
| 1 | 1 | 1 |
| 2 | 1 | 2 |
+----+----------+--------+

I want to select from tableA based on user_id and status from tableB and tableC references and tableA values.

Implementing Linq over the preview ranges before the std lib fags do it

Anone! Anone! I made this for you, because you did so well with your JavaScript lessons!

Attached: c1dde4964c107aec32fb4b3d4fbb2cd5.jpg (800x1200, 90K)

So I'm trying to create a BST that converts english characters to morse code. I need to have my BST balanced and ordered according to ASCII values so I can use something like a strcmp() to do the heavy lifting for my insert_into_bst() and print() functions.

The txt file I'm reading in looks something like:
B -...
Where the english character/number is listed and then the morsecode translation is listed after separated by whitespace.

Thing I'm not sure about, is how do I read this in and store the english character/number so it has the corresponding ascii value.

If I do something like:
char line[100] = "";
input.getline(line, 100, ' '); //stores the first english character or number into line
cout

Attached: getline.png (226x43, 2K)

I made a shiritori game in Haskell, please review my code:

github.com/paperduck/shiritori

Attached: haskell logo.png (1200x847, 15K)

var a : Int = 5 ; get() = ++field ; private set

suggest more boilerplate/autism

do line[0] instead

Haskell is garbage.
review done

seconding this

...

at least you tried

>get = ++field

This mutates the value, does it not?

>Haskell
>review my code
wtf its not a one-liner?

It's a one-function-stack-liner

Attached: thinking.jpg (249x203, 7K)

Thanks but what is it

what are the constraints? foreign keys? what have you tried?

why does ~ turn my 8-bit variable into 32-bit?

Attached: Untitled.png (717x312, 14K)

because printf isnt type safe

because ~ likes to overcomplement

Attached: ().png (350x350, 138K)

It's called integer promotion. Any arithmetic operation on char/short actually gets converted to int (or unsigned) before doing so.
It's an efficiency thing, as computers are actually better at working at their native size rather than a smaller one.

Not to mention, with variadic arguments, char/short gets promoted to int and float gets promoted to double.

interesting

Default integer promotions.
Types smaller than int get promoted to integers in variadic arguments. This is also why some string functions like memcpy take integers not chars. (One of the reasons is that one some machines it would be easier to handle int-sized items than char-sized items.)

If you want printf to treat it as an unsigned character, use the "hh" length modifier (C99+ only). On C99+ with the inttypes.h header, there is also "PRIx8", but this looks uglier, specifically for the uint8_t type (though it's kinda useless, I don't see any way you can have a uint8_t type that isn't the same size as unsigned char).

See C standard 6.3.1.1 (port70.net/~nsz/c/c11/n1570.html#6.3.1.1)

bump

navigationbar in gtk and python

Attached: Untitled_4fe1cfadaff64750ec71a5f53b3bd6f1c6cd2082.png (848x190, 118K)

most programs are

vector preorder(Node *root)
{
std::vector result;
std::deque s = {nullptr};
while (root)
{
result.push_back(root->val);
for (auto iter = root->children.rbegin(); iter != root->children.rend(); ++iter)
{
s.push_front(*iter);
}
root = s.front();
s.pop_front();
}
return result;
}

whats wrong with this pre-order traversal? there's very little brancing (preloading nullptr) but its still only 50% faster than all submissions.

details? Is this like dmenu/rofi or something?

C++

no, lisp

Haskell

could make it read in and print out from cmdline like dmwnu/rofi
planned to become my filebrowser with iconview below the navbar

Why can't I use the ++ operator on a pointer.
eg:
int x = 1;
int *ip;
ip = &x;
printf("x: %d\nip: %d\n", x, *ip);
*ip++;
printf("x: %d\nip: %d\n", x, *ip);

Is it just incrementing the pointer's location?

Attached: 1560032001559.jpg (450x659, 74K)

for what use case?

i don't like dynamic languages because my mind isn't dynamic

general purpose

Use case?

posfix ++ has a higher precedence than unary *, so it's really being parsed like *(ip++).
If you want the other behaviour of incrementing the pointed-to value, explicitly put parenthesis like (*ip)++.

I see. Thanks.

I don't really use LISP much, but goddamn format is useful

>Use case?
A use case means what you want to use the tool for.
For example, I'm not going to write a device driver in Haskell -- I would use C for that -- but Haskell would be a better choice for a journal article documenting a new algorithm.
Different languages are better suited to different situations.

I'm a Pythonlet starting a CHIP-8 emulator in C.
Should I step back and try to whiteboard a design or just dive in? My C is very weak, like only five chapters through K&R weak.

I feel like I could pump this out in a few hours in Python but C might take me this whole week.

format is pretty cool

Plans are more malleable than code.
youtube.com/watch?v=f84n5oFoZBc

If you could do it so much faster in Python then I would write it in Python first.

It was a play on this.

Attached: pebblethrow.png (1000x1000, 89K)

Always design stuff. Actually figuring out what you want to build first helps with anything.

Is there any way to write perl5 without sigils?

>perl
>no sigils

Who the hell is using Perl in 2019?

I have less than a week to make a game for my CS 102 (intro to data structs with C++) class using sfml. What do you think would be an easy game to make? I was thinking snake might be a good one.

Will learning python get me a boyfriend?

everyone does snake. do checkers or something.

Vertical shmup.

The grade is most important, snake is fine

Lisp is the most powerful programming language.

How much autism does one need to have in order to post this shit every thread for the last several months?

Attached: 1543220845606.gif (1050x850, 1.97M)

Reposting in the weeb thread.

depends on a/s/l

Attached: island tribe.jpg (300x168, 4K)

This, even though I write lisp every day

Attached: tiresome.png (1022x731, 643K)

no you don't

huh?

what?

lisp is the most powerful language

do you feel powerful? are you god?

Currently taking the Jow Forums pill and learning C because I dont want to be a OOP brainlet who only knows how to copy code from stack overflow

Attached: index.png (197x255, 7K)

too late, you're already a brainlet for rejecting OOP

i am not, but I am not surprised if masters of lisp have become One with Him.
where do you think all the good lisp programmers go?

I've been a good programming girl today!

Unfortunately I don't have a boyfriend to reward me.

> when someone falls for all the memes

ironic in an effort to not be a brainlet you did he most brainlet thing of them all

they are simply physical manifestations of lisp sent here to guide us. they have received their closed parens. let us honor them.

>the wrong way to avoid OOP

What am i doing wrong anons? I thought real men choose C

Don't worry. They're just indoctrinated POO worshippers.
Keep learning C.

learn lisp bitch!

Trying to keep track of mutable state in C was too hard so people encapsulated it using classes to make it easier.
It helped but it didn't fix the problem.
youtube.com/watch?v=E4RarTAZ2AY

>real men choose C
Real men choose the right tool for the job.
Sometimes that is C.
Sometimes it isn't.

Which one to read/work through? I bought K&R first, then found Practical C for $5 at the thrift store, then got Programming in C as a gift.

Attached: 0714192150.jpg (1920x1080, 280K)

how much experience do you have programming?

Few years with Python

give me a good programming video to watch while i'm falling asleep

K&R is a worth a read for the historic value, though the code will take some tweaking to work.

any of you fellas do a triplebyte interview? how was it?

youtube.com/watch?v=xzTH_ZqaFKI
youtube.com/watch?v=edpifsVcurs

youtube.com/playlist?list=PLUFkSN0XLZ-n_Na6jwqopTt1Ki57vMIc3

I'm trying to get into a strategy role on a motorsport (car) racing team.

I can run a lot of data stuff (Python) and I previously mentioned Monte Carlo simulations in a last thread.

Now, trying to do visualizations but this gets me into web shit.... which I hate.

TLDR -> Working on a car racing simulation. Traffic, tire deg, etc all factored in. Not overly complicated but getting it working right is tricky

poopoo

sounds interesting

>a motorsport (car) racing team
>I can run a lot of data stuff (Python)
You are funny user

Does c++ have a good string tokenizer that can read in whitespace unlike strtok()?

I want to read in a sentence with getline(), then break it down character by character including whitespace.

I've been fiddling with Lisp's metaobject system and made a way for objects to immediately update the SQL database when a slot changes, e.g.

(defmodl docket ()
((name :initarg :name
:accessor docket-name))
(:table :docket))

(let ((my-docket (find-record 'docket :id 1)))
(setf (docket-name my-docket) "new name")
;; automatically runs SQL query
;; UPDATE docket SET `name`='new name'
;; WHERE `id`=1;
(print ":)"))

Attached: alien.png (256x150, 20K)

Scroll to "desirable knowledge"
linkedin [dawt cahm] com/jobs/view/strategist-at-mclaren-racing-1061720420

Why can't you use c_str() for a const char array? or you can cast the pointer to the dereferenced first element in the string and cast that to a char * array, &str[0]

Nice! I've just started reading AMOP.

neat user!

Is a switch for the high nibble in a CHIP-8 instruction and then nested switches for the next appropriate nibble or byte a decent way to handle these instructions?

Sounds efficient to me

There is also string_view that some user says does something here, still not sure exactly what the use case it.

Sounds messy though, can you make move the nested switches to their own fucktions?

calling people names doesn't help

no it won't. If you compile with -std=c89 it should work fine.