/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 155907705415711.png (917x1105, 332K)

Other urls found in this thread:

vocaroo.com/i/s0EkDdSP8xuN
drive.google.com/drive/folders/1JNjTFSMYfLJoKOWRPFAkyaMod95imSwg?usp=sharing
lolcode.org/
github.com/justinmeza/lolcode-spec/blob/master/v1.2/lolcode-spec-v1.2.md
twitter.com/AnonBabble

>try to learn how to program
>distracted by normalfags playing outside becuase summer

Attached: 1919238418293.jpg (1280x720, 96K)

tried doing FFT of an audio stream using numpy. My calculated peak frequency of any pure tone is about 10% lower than what the tone actually is generated/played at originally.

What could cause this?

finally, a good OP

s-sorry about the previous threads, i guess?

Attached: 1560106741006.png (1920x1080, 1.39M)

You are given the following function to write in LISP in a job interview
defun SPLIT-LIST (L)

That takes in a List L and returns 2 sublists of L
(1 2 3) --> ((1 2) (3))


You should be able to do this, I can help you write it if you need some

>LISP
>job interview
lol

does it need to split it in a particular place?

in Haskell this is just
spltList l = ([], [])
-- 2 sub lists of l

I only know scheme
(define (f l) `((,(car l)) ,(cdr l)))

does it matter which sublists?

If the list size if even split along the middle
(1 2 3 4) --> ((1 2) (3 4))

else split on n/2 + 1 element

based

if the list is length 3 then split it into the first fizz elements

Has anyone here implemented a Red and Black tree? How was it?

baste

You don't update the config on the machine that changes it from the db but directly from the change you just made.

Is this gud enuf?
(defn split-list [l]
(let [n (quot (count l) 2)]
[(take n l) (drop n l)]))

I miss her, bros

I know you were anticipating an answer, so here it is.
(defun SPLIT-LIST(L)
(cond
// set mid_odd = n/2 + 1
// mid even = n/2
((atom L) (list L))
((oddp (length L) (list sublist 0 mid_odd)
... and so on
)

)

function SPLIT_LIST(arr) {
let arr1 = arr.slice(0, -1);
let arr2 = [arr[arr.length-1]];
let arr3 = [arr1, arr2];
return arr3;
}

let arr = SPLIT_LIST([1, 2, 3, 4]);
console.log(arr);
// [[1, 2, 3], [4]]

Walk away right now webshit

Attached: peltor.png (1000x1000, 301K)

here's the short version:
function SPLIT_LIST(arr) {
return [arr.slice(0, -1), [arr[arr.length - 1]]];
}

Let's be friendly. It's more fun.

>woah that's an elegant solution, I wonder ho- wait it's in JAVASCRIPT???????? WEBSHIT ALERT !!!!

Attached: 34twergfrsdeg.jpg (800x450, 44K)

this is the biggest cope post i've seen in /dpt/

>implying what I said isn't true
>cope

Attached: 0f3.png (3340x3176, 205K)

absolute seething

kys

webdevs pls go and stay go

struct list
{ int* b;
size_t n;
};

void split(struct list in, struct list* out)
{
out[0] = in;
out[1] = in;
out[0].n /= 2;
out[1].b += out[0].n;
out[1].n -= out[0].n;
}

I don't webdev but what do you have against them? You might learn something from them.

The job interviewer says nice solution, user!

However, I'd like to ask you a few more questions..

How would you identify a bottleneck in your program? Your program is written in C, compiled using gcc. You have GNU software at your disposal, what tools would you use?

gprof or perf
easy, next question

they can't program and have their own general

pajeet pls

>they can't program
lol okay
>they have their own general
yeah, it's called dpt

>they can't program
compared to what?

gprof is a great answer. Onto the next question..

If you wanted to broadcast a message regularly to 1000 peers, would you use UDP or TCP and why?

Following up on that question. Say you have a site that is similar to Youtube.com with videos that are stored in memory somewhere. Would you use TCP or UDP for playing those videos?

Reduce 2-SAT to 2-COLORABILITY.

Ask them to do anything that is not webshit related, they will literally freak out. They learn to do webdev and only webdev with absolutely zero understanding of any theoretical concepts

use http

the answer i gave is merely appeasement, it means nothing that you find it unconvincing. out webdevs are unwelcome here, if you want to remain you should cover up your webfaggotry and beg for the mercy of real programmers (read: not webdevs)

>anything that is not webshit related, they will literally freak out
because all web devs know is code in javascript, well memed good sir!
>any theoretical concepts
bahahahahahah, and you complain about not having a job

UDP. There is no support for broadcasting in TCP.

TCP. With UDP, you get no guarantees for e.g. orderliness or arrival. You would have to re-implement this yourself. While it certainly would be possible (e.g. BitTorrent), the gains would be very small as this use case matches the intended use case of TCP well.

cringe

Attached: 3852319728_3ee25c2251_b.jpg (1024x681, 209K)

>"webdevs are shit"
>can't back it up
You can't have a programming job with and IQ less than 5

did you do that in css, webfaggot?

lol

based

>71350637
>ad hominem
disregarded

>did you do that in css, webfaggot?

Attached: 1560116368380s.jpg (201x250, 7K)

Great answers again. Now consider the following, why would you want to utilize C++ (instead of C) if you're building software that will be sending all kinds of different Packets?

For what are we optimizing? For a performance-critical application, I would probably opt for C. For anything else, C++ has the advantage of providing a greater level of abstraction through object-based encapsulation, which makes it easier and less error-prone to build large software.

i can do css too
you are gay

I was more so trying to trigger your 2nd answer. Fun fact, I was asked all of these questions at a job interview recently

>I was asked all of these questions at a job interview recently
what role/position? no coding session?

...

What were they on about?
I don't know what the supposed advantage of C++ would be. You can make everything very convoluted, but this is hardly a feature.

It was for a software engineering internship at a company that builds network models and simulations. I was invited to have an onsite 2-3 interview this week that will have whiteboard coding

vocaroo.com/i/s0EkDdSP8xuN

I initially opted for C as C++ didn't seem needed. But the interviewer wanted to emphasize OOP with a Packet parent class that all Packets share and have different child Packets

>that will have whiteboard coding
can you solve hard leetcode questions on the spot?

>all packets have a parent packet
What?

Usually yes. UCLA's rigor has helped me prepare. I've done two internships in the past two summers as well

Not all datagrams are the same, but they do share some attributes

Well, /dpt/, I finally did it. After eight years of being a hobbyist, I finally got a comfy job as a software engineer that I start tomorrow morning. Pretty nervous t b h. Also I still don't really know how to use git properly.

What am I in for? Serious replies only.

Attached: 1559656995808.gif (429x592, 2.8M)

You learn how to use git by using it. Don't worry, it clicks after a little while. Also, unless you're at a top 4 company, expect to meet some really fucking stupid people and some really smart people.

Attached: gitgud.png (164x86, 8K)

Attached: congratulations.jpg (1569x564, 726K)

I got my program to play audio files backwards, now I just need to figure out how to pitch shift as well. I probably should have stopped several innovations ago but if I get them all in there I will have something like 100 billion years of audio.

will it be enough?

who here actually finds operating systems to be a comfy subject?

Check out the kabzudak (the music alphabet from which all the recombination takes place).

drive.google.com/drive/folders/1JNjTFSMYfLJoKOWRPFAkyaMod95imSwg?usp=sharing

I hope its enough, but overall there will probably be less than a good full day out of the 100 billion years that a human would even enjoy.

I have Base abstract class and Derived classes.
I have a vector of Base pointers, which has derived objects.
It's fine when I try to access methods declared in base, but I get an error if I want to access a method declared in one of the derived classes.
I could move the method to the base class but then I will have to implement it in every derived class in order for them not to be abstract and I don't want that.
What do?

post code?

It's split into multiple files.
Item.h has
virtual std::string get_type() = 0;


Physical.cpp has
bool Physical::is_occupied() {
return occupied;
}

std::string Physical::get_type() {
return "Physical";


And Library.cpp has
void Library::find_title() {
cout searched;
for (auto title : this->storage) {
if (title->get_name() == searched) {
if (title->get_type() == "Physical")
if (title->occupied) // here's whats wrong

...

are you casting them to the derived?
you even have the ability to determine which type they are for fuck's sake

Me too brother

you need to cast them

One day... One day I'll write my own compiler.

why not today, llvm has a good tutorial for writing a frontend, the theory of which can be applied elsewhere, independent of llvm

Wow! Shitlang compilers are super performant. I made a shitlang compiler with no intentional optimizations and the only thing that beats it in terms of speed, memory, and size is C. I now understand why dinosaur languages are so performant. If you keep it simple it has the blessing. Bloat is what kills efficiency.

>why not today,
I also want to create my own esoteric language

It doesn't help that garbage languages like C++ are trying to solve the halting problem in their language grammar, and just love to compile the same shit over and over again.

how hard is it to build something like this?
lolcode.org/

I think I'm doing it wrong.

Attached: file.png (1259x874, 129K)

github.com/justinmeza/lolcode-spec/blob/master/v1.2/lolcode-spec-v1.2.md

kabzudak?

you're right, you're using C style casting
use
dynamic_cast(title)->is_occupied();
iirc reinterpret_cast also works, without requiring RTTI, but i'm not 100% sure

do C++ users really have to do something this unwieldy just to cast a variable

Thanks user it worked.

unfortunately
but really, how would you do it?
reinterpret_cast is closest to C-style casting, and is what it says on the tin; dynamic_cast has overhead because it's safer; and static_cast is evaluated at compile time
how would you separate between them?
dynamic_cast is bloat, admittedly
but static_cast and reinterpret_cast are actually useful

I'm just happy if you know how to make a compiler you've already completed the big step and making a lang with instant compilation that's close to C's efficiency is so trivial. Maybe I should try to make a non-shit sepples for fun.

Kab is the opposite of dak, like front and back. Zu means through. Kabzudak is just a word to represent the concept of an abugida of music (or any list that contains all elements of a type).

Every time I start thinking sepples is better than C I see shit like this. Why can't there just be C with templates and dynamic containers?

>abugida
This one I can find on wikipedia. :-)

because next you would ask, "why can't there just be C with ?"

So you know what I mean then, the songs are analogous to phonemes or letters, and the software spells random words based on the two monsters on screen.

Attached: Screenshot_20190607-183037.png (1080x1920, 169K)

oh, now I get it!

this looks interesting, are you building this?