/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

en.wikipedia.org/wiki/Devanagari
en.wikipedia.org/wiki/Lexicographical_order
pastebin.com/KQFrs16v
github.com/ghdl/ghdl
pastebin.com/spx5fG2h
youtube.com/watch?v=qv5b1Xowxdk
twitter.com/SFWRedditVideos

First for C++ > rust

>Author: Shiririram Clstrfckocnsnnts
Do Pajeet names look that bad in their native moon runes, or is it just English's retardedly small set of consonant letters that makes em look that poo

What container is better suited for quickly checking if a node exists? HashSets? The node is unordered of course. i.e. I am going to check if a string exists in the container.

it's not bad, like a mixture of moon runes and sand nigger script
en.wikipedia.org/wiki/Devanagari

what are the alternatives you're considering?

Dictionary/Hash Table/Associative Array

Not anything in particular. Problem with HashSets is that the nodes have to have an ordder, iirc. Random strings don't have an order.

>Problem with HashSets is that the nodes have to have an ordder, iirc.
wait wha?

to be more precise, IIRC hash sets require the type to be hashable.
Tree sets, on the other hand, might require it to have an ordering.
However, if you're working in Java, I assume that they'd just expect the type to be hashable and then order based on the hashes.
Talking out me arse, obviously

also,
>Random strings don't have an order.
that's where you're wrong, kiddo:
en.wikipedia.org/wiki/Lexicographical_order

can someone please explain to me wtf is going on here. Yes, I did just start doing this. The most basic logic is not working, I can't figure out why it's doing this. It should clearly print "1 is less than 2".

On the chance you're not trolling, ">" means "greater than".

the alligator eats the bigger number

oh my fucking god, sorry

nigga you should have learned this in 1st grade

the underage problem sure is getting extreme.

Here's a great tip I learned in my computer science PhD! Just remember, the fish wants to eat the bigger number!

...

you might as well post a blank canvas at this rate.

...

that's reserved for either the french flag or an argentine's skin

kek

Learn PHP and node js to build Sup Forums clone

...

please just give me a break. It was a freak accident, I didn't sleep last night and I wasn't paying attention. I'm in calc 1. I swear I'm not retarded senpai

>babby's first math class
>swear I'm not retarded

>I'm in calc 1
you are literally confirming yourself to be underage and still in 8th grade/freshman

don't know what school you went to, but earliest opportunity for calc 1 in my high school was senior year
it's often a freshman year course in university too

>it's often a freshman year course in university too
no wonder college grads are so worthless.

college grads aren't worthless because of your superiority complex, they're worthless because the courses themselves aren't taught in a practical manner

No, it's because of all the useless review courses, """"general learning"""", 101 classes, and the yearly bar lowering. College shouldn't be Highschool++. and calc1 should definitely be a pre-rec for any related degree.

The exaggeration of ""general learning"" courses is silly, and both Calc 1 and 2 can be done in high school before college if your high school teaches AP courses and you're so inclined.
They aren't "review courses" if people haven't taken them before. A university can only assume people coming into it have the minimum requirements for high school education laid out at on the federal level.
Grading sheets of paper harder isn't going to produce better programmers or engineers (though I don't think grading on a curve should be allowed).

What are some personal machine learning projects? I don't want to be left behind when everyone has their own AIs running tasks and counter-intelligence for them.

nth for

htdp > sicp as a programming primer.

Should I read effective java?

stop saying mean things about C

so you're saying sicp is better?

c++ is the greatest language of all time

no one answered my question about floating points in vhdl

is /dpt/ too retarded for vhdl programming :^) ??

no one wants to do your fucktoilet homework
chew poo

/dpt/ absolute btfo!!!!

Why does rust have a code of conduct? Wtf?

to protect sensitive people from mean words

Lisp is the most powerful programming language.

>prog
>prog*
>progv
lmao

>IRC
>Ask for a library recommendation
>A highly enthusiastic user pops up to self-plug his library
>Go to the repo
>Everything from documentation, acronym, issues is full of sheer autism
>It's a she, likes cats
>Can't go back to the channel because her library is kinda useless for me

I really hope this is a bot.

Can someone help me understand what's wrong with a program I wrote? I have to find the largest and smallest number in an array, but the function to find the smallest number isn't working right. I have no clue what the issue is either. Not asking for code just guidance.

pastebin.com/KQFrs16v

You don't need two functions for that, just use the same function but multiply all numbers by -1.

I just glanced at your code and didn't see anything that stuck out. What behavior are you seeing?

>she

I'm not getting what you mean by that
This is the output I'm getting right now. Everything seems fine to me and it's like I said high count works perfectly.

Working on a shitty iOS game
any mobile game developer here?

>count

>count

Yep that fixed it. Thanks guys

quality b8 m8

Hey Sup Forums, I'm having a bit of a problem.

#include
#include
#include

#define BUFFER_SIZE 4096
#define CHAR_SIZE 1
#define INT_SIZE 4

int main(int argc, char**argv) {
if (argc < 2) {
puts("my-zip: file1 [file2 ...]");
return 1;
}
FILE *ifile = NULL, *ofile = NULL;
int i, ipos, opos, count, result;
char *ibuffer = NULL, *obuffer = NULL, curr = '\0';
for (i = 1; i < argc; i++) {
ifile = fopen(argv[i], "r");
*strchr(argv[i], '.') = '\0';
ofile = fopen(strcat(argv[i],".zip"),"w");
if (ifile == NULL || ofile == NULL) {
puts("my-zip: cannot open file");
return 1;
}
ibuffer = malloc(BUFFER_SIZE);
obuffer = malloc(BUFFER_SIZE);
//Optimize this line later
curr = fgetc(ifile);
count = 1;
while (!feof(ifile)) {
result = fread(ibuffer, CHAR_SIZE, BUFFER_SIZE, ifile);
opos = 0;
ipos = 0;
for (ipos = 0; ipos < result; ipos++) {
if (ibuffer[ipos] == curr) {
count++;
} else {
//Might be faster than memcpy?
memcpy(obuffer+opos, &count, INT_SIZE);
opos += INT_SIZE;
obuffer[opos++] = curr;
count = 1;
curr = ibuffer[ipos];
}
}
fwrite(obuffer, CHAR_SIZE, opos, ofile);
}
fflush(ofile);
free(ibuffer);
free(obuffer);
fclose(ifile);
fclose(ofile);
}
return 0;
}


This code works compresses a raw text file, in the form of [consecutive count][character]. Unfortunately, the program core dumps. I went looking through the assembly in gdb, but I can't find the error even there. It core dumps when there is an insanely large file to compress, somewhere above 4097bytes (i tested this to make sure that the program didn't have a buffer issue.) Does anyone see the problem I'm not seeing?

Make sure to change it in the function that finds the highest too.

I did thanks

Increase BUFFER_SIZE

Are you talking about BUF_SIZE by calling setvbuf on the two buffers?

Anyone got a discord invite?

>he considers himself a hacker
>poor
>hasn't hacked himself 100,000,000 USD

You have þe power to use þorn. You can fix þings. Don't act like þe world is totally out of your control.

>considers himself a hacker
>boasts about cracking in weeb forums

Diving blindly into python for the first time to parse EDIF 2.0 files into an AST. Either going to use python or C++ for modeling and simulating the resulting circuit, or stop entirely and move onto something else.

No. Calc 1 is worthless because it tries to be practical. You end up having to unlearn the damn course later.

No one said common lisp baka.

soþlice

A function in python is returning a tuple with 3 elements but I only want the first two. What's the correct way to do this? The following code gives me ValueError: too many values to unpack

for x, y in func(arg)[:2]:
do something with (x,y)

a,b,c = func()

?

but I don't need to use c so I didn't want an unnecessary variable

a,b,_ = func()

is this just a convention for a throwaway variable or does it actually tell the interpreter not to allocate memory for it?

It's probably still a buffer issue. I'm not exactly sure what's going on but the way malloc works means that your program won't go up in flames the moment you step out of where you're supposed to.

convetion, but python will pass a reference, no copying afaict

cool, thanks

you probably better check this, if it's important

Read wikipedia for Single-precision.
1 bit for sign, 8 bits for exponent, 23 bits for fraction.
Multiplying/Dividing are actually easier for floats if I remember correctly. Addition/subtraction you need to make the exponent equal.

Soyboy here getting really comfy with VueJS. Does anyone have any recommendations for doing SQL-like operations in JS? I'd like to dump the data client side and interact with it there instead of making a bunch of requests.

I feel dumb but also finally happy that I finally get what an interpreted language is. Don't get me wrong i could rattle of the definition like anyone else for years but i didn't fundamentally really get it. Was just watching some videos on the Altair 8800 and it finally just clicked.

how do i write a vhdl testbench boys help a retard out will ya :^)

Download a simulator, find some docs then write some? What else do you want?

github.com/ghdl/ghdl

Also, I've never written any VHDL (or verilog).

share some videos, lol

DFAs in Agda

record Andmap : Set1 where
constructor andmap-dfa
field
{Σ} : Set
p? : (x : Σ) → Bool

data Q : Set where
q-ok q-rej : Q

machine : DFA
machine = DFA.⟨ Q , Σ , δ , q-ok , F ⟩
where
δ : Q → Σ → Q
δ q-ok x = if p? x then q-ok else q-rej
δ q-rej x = q-rej

F : Pred Q _
F x = (x ≡ q-ok)

{- target language: strings where p? is true all
- symbols in the string -}
L : DFA.Language machine
L = All (λ x → p? x ≡ true)

module Correctness (impl : Andmap) where
open Andmap impl
open DFA.DFA machine hiding (Q; Σ)

L⊆A : L ⊆ A
L⊆A [] = refl
L⊆A (px ∷ s∈L) rewrite px = L⊆A s∈L

pastebin.com/spx5fG2h
Look up "assert" if you don't want to be manually confirming waveform outputs are correct all day.

well this video is how it actually works in practice:
youtube.com/watch?v=qv5b1Xowxdk

so you go from the a dumb box (the Altair 8800) which is just a box with switches and lights on it. No OS, no assembly, no ROM, no hard drive, just a blank slate. You run a program on it (the interpreter) that's designed to understand input. And you are going from writing machine language to being able to write in a high level language. Of course that's also thanks to the bootstrap tape reader but still, hard to show a simpler example.

nah it's just for a school project but it looks like it's just to indicate that it's not being used and theres nothing special done by the interpreter

I have patches for GCC 7.2, and now that GCC 7.3 is out I want to apply the patch to 7.3.
Will this work fine? or is there some way I should handle this?

>input and output via a typewriter
this needs to be a thing again

>pic related
So this happened the other day.
def fizzBuzz(n):
if not n:
return
if not n%15:
print("FizzBuzz")
if not n%3:
print("Fizz")
if not n%5:
print("Buzz")
return fizzBuzz(n-1)
fizzBuzz(100)

0 decides the next language.

Pencil & paper.

malbolge unshackled

pastebin the new code
also, change "size" to something else because "size" already refers to something in the standard library
and instead of a global variable do this
#define SIZE 10

jai

I'm not as evil as malbolgeanon. unlambda.

Arm assembly

I deleted it because I just realized where I might have made the mistake. I've never used #define before but I'll look into it. Is there something wrong with using a global variable?