/dpt/ - Daily Programming Thread

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

Attached: 1567114293861.png (789x1000, 1.09M)

Other urls found in this thread:

better-dpt-roll.github.io/
godbolt.org/z/KFeowS
htdp.org
pastebin.com/nZsijY1x
esolangs.org/wiki/HQ9+
twitter.com/NSFWRedditGif

C and Haskell

>What are you working
advanced fizzbuzzery

post your code

Attached: www.png (1920x1080, 186K)

>What are you working on
really important shit, obviously.
type FB = enum
Raw, Fizz, Buzz, FizzBuzz

proc classify(n: int): FB =
let
by3 = n mod 3 == 0
by5 = n mod 5 == 0
FB((by3.int shl 1) or by5.int)

for n in 1 .. 100:
case classify(n):
of Raw: echo n
of Fizz: echo "Fizz"
of Buzz: echo "Buzz"
of FizzBuzz: echo "FizzBuzz"
and benchmarking it obviously.
it's very competitive with C but I'm more interested now in the stdlib buffering weirdness with both versions: they're significantly faster if not piped to /dev/null

Hey, user! How's your JavaScript project going?

Attached: 7534b5f0acb8a771d0f663b936fb296e.jpg (800x1200, 85K)

Lisp is the most powerful programming language.

type classes and interfaces are for pussies, all you need is universal quantification to get all the polymorphism you need

in python this is just
for i in range(1,101):print ("FizzBuzz"[i*i%3*4:8--i**4%5] or i)

>What are you working on
Finding the inspiration to make a program about anything. Fuck me I'm not a creative person.

Attached: 1530793919714.jpg (1018x768, 87K)

based and System F pilled but add type level lambdas and it'll be based and system fω pilled

user... when you say "in X this is just" you're supposed to produce better code, not worse code.

gotcha

better-dpt-roll.github.io/

it's better because there is no branching, only direct access to the array thus very efficient

oh yeah, all that efficiency and it's only 15.2x slower than the Nim solution.

been a while since ran posted in here, haskellfags are getting too comfortable!

do you mean hankel?

>i*i%3
explain this mighty mathemagician

who's hankel?
I mean the smug ran avatar fagging

sounds like hankel
the /sci/ shitposter

Oh shit. Thanks man. This helps a lot.

who also yukari posted
incidentally why do LGBTs use Rust when there's literally a language called ForTrans?

>the /sci/ shitposter
yes

I can't make heads or tails of it.
Python accepting 1--2 as 1-(-2) officially makes it the worst fucking language in the world.
oh yeah real Guido hours here.
proc `or`(x: string, y: int): string =
if x == "":
$y
else:
x

for i in 1 .. 100: echo ("FizzBuzz"[(i*i) mod (3*4) .. 8 - -((i shl 2) mod 5)] or i)

>muh zero cost abstractions
godbolt.org/z/KFeowS

I understand how it works I don't under stand the maths, is it just a coincidence ?

Fucking hell. And then ** is power of. What haha

twenty-fifth for anime image

but do you know How To Design Programs, user?

htdp.org

nice

Attached: 1553858253128.png (500x768, 299K)

>no branching
prove it

oh honey modern CPUs don't need branching to
1. stringify numbers
2. handle invalid indexes into a string

pastebin.com/nZsijY1x

my code ıs too long and full of kebab thıngs

bless Our Lord and Savior Jesus' Fizzbuzz

Attached: 1548062967440.jpg (899x1284, 112K)

>JUMP_IF_TRUE_OR_POP

fucking kill yourself retard

Attached: 1538121331986.jpg (1280x720, 65K)

Py_ssize_t
PySlice_AdjustIndices(Py_ssize_t length,
Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t step)
{
/* this is harder to get right than you might think */

assert(step != 0);
assert(step >= -PY_SSIZE_T_MAX);

if (*start < 0) {
*start += length;
if (*start < 0) {
*start = (step < 0) ? -1 : 0;
}
}
else if (*start >= length) {
*start = (step < 0) ? length - 1 : length;
}

if (*stop < 0) {
*stop += length;
if (*stop < 0) {
*stop = (step < 0) ? -1 : 0;
}
}
else if (*stop >= length) {
*stop = (step < 0) ? length - 1 : length;
}

if (step < 0) {
if (*stop < *start) {
return (*start - *stop - 1) / (-step) + 1;
}
}
else {
if (*start < *stop) {
return (*stop - *start - 1) / step + 1;
}
}
return 0;
}

New Game!!! when?

>54: JUMP_IF_TRUE_OR_POP goto ->58
>58: CALL_FUNCTION 1

that's just calling the function

if I ever make a programming language, I'll add a dedicated fizzbuzz optimization

Attached: 1543615417250.gif (1200x1200, 479K)

it's branching on whether the extracted string is empty or not

make it a language instruction, similar to malbolge's crazy operator

esolangs.org/wiki/HQ9+
the worst-implemented language in the world. Not even correctly documented here. shameful.
but it's obviously missing an instruction for modern users.

>HQ9++, an object-oriented extension of HQ9+.

Attached: bjarne_stroustrup.jpg (442x293, 20K)

Is talking to clients and users on tweeter and social media a new meme or should I just fucking quit?

meme

if you mean actual clients, why would you want to broadcast your dealings out in public?

companies are quick to ask you to take it to DMs. social media engagement is mainly about shutting up influential critics.

c++98 is the most powerful programming language

Great as if putting a smiling npc profile pic was not enough. now I have to actively talk about open source good and diversity good.
I thought that this shit was only for megacorp slaves.

I'm writing code to stitch images together into a texture atlas. It works, but for some reason when you add an image that's taller than it is wide it only copies in the first $width rows. Very weird.

Leaving a terminal open with cat >> todo.txt to paste urls and type random shit in worked better than expected. Much easier than leaving an editor pointing at the file.

Attached: gay_alley.jpg (1079x1050, 616K)

whence come the need to shut anybody up?
GIMP has always been shit and derided as shit, yet people still use and download it for a lack of a viable open source alternative

>what is Krita
I said companies though. They just don't want to pay people a lot of money for marketing and then have that counteracted by unhappy 'influencers'.
There are some nice UIs for the twitter firehose. One of them's a stream of bubbles going across the screen. Larger the bubble, more followers. Red/green bubble, automatically determined to be speaking positive/negatively about you. Or about the subject of the stream, if you switch to viewing a competitor. There are people who's main job is to watch for big red circles and shut them up. That these people also respond to any random jerk on twitter is just what they're doing while watching for bigger redder circles.

One way of doing it in Raku:
say (('Fizz' if $_ %% 3; 'Buzz' if $_ %% 5).join or $_) for 1..100

Here, %% is the divisibility operator and a..b the range operator. Printing Fizz, Buzz, FizzBuzz or the number relies on whether ('Fizz' if $_ %% 3; 'Buzz' if $_ %% 5).join evaluates to false. If it's false, print the number. Otherwise, join its content and print.

"Don't call us, we'll call you."

wow, that's really impressive.
162.4x slower than Nim!

>for a lack of knowing a viable open source alternative
ftfy

Is FizzBuzz real or just a meme? My one (1) job I got a paid take home assignment for a test. What is your FizzBuzzing ability supposed to determine other than that you're not a literal retard? Even those meme algorithm questions are better.

the only open source interaction we do is submitting issues we have with open source libs we use in the most passive aggressive way possible.

>What is your FizzBuzzing ability supposed to determine other than that you're not a literal retard?
that's exactly what it's trying to determine

But why bother? If you can't FizzBuzz you definitely will not succeed at an actual interview question. I'm assuming no one is hired on the basis of understanding for loops and the modulo operator alone.

sweet summer child

why do you think whiteboarding is disliked so much?
it's because people actually exist who do well at interviews until you ask them to write any code at all

Where can I find a simple introduction to Emacs that teaches just enough to be productive. I don't want to play Doom or watch porn on Emacs, just use it as a simple IDE. Right now I only use it for taking notes with org mode, but I would like to start using it as an editor as well.

I'm learning Rust.

Attached: 1542603935780.jpg (1320x2560, 643K)

you have to go back

haven't slept in 36 hours, what should I program

muh dick

does anyone know if exist any way to control a paper scanner speed? I would like to slow down the speed of sheet while it travels through the scanner

even with universal quantification, life without type classes is pretty painful

An alarm clock.

just pass your instances manually lmao

>need to rewrite all my machine code programs after changing from 8-bit to 16-bit addresses

Attached: 1564160558260.png (1080x1080, 856K)

no shit

just use Kate.
It's time to eat.

Attached: 860cc63fff444597d6d95ba430f320c5b4950e5e.jpg (472x472, 24K)

Great images

Attached: letsu-sleep.png (381x328, 98K)

krita is only good for drawing

increase the scan dpi

but can I sleep with them?

Is learning i3 + VIM actually worth the investment or is it a meme?
I come from an XFCE + VSCode background and it's working quite well, but if I can optimize my workflow that would be great.

i wanted to know if there is a method to directly set the speed without touching the dpi

Make a combinatorial auction service

xfce is all you need

I'm trying to use the Haskell "req" library. It uses Aeson behind the scenes and returns type "Value" if you query an endpoint that returns JSON. How do I transform a "Value" type into the record type I want from it?

There's not much to learn in i3. If you want to be productive, just memorise a few commands and in 5 minutes you can be done. If you want some crazy setup that you would screenshot and post on those stupid desktop threads, then you will probably spend some time on that. Vim/Emacs are 100% memes and you don't need to use them unless you're the type who likes to customise everything

The rendering pipeline for my game engine with a focus on map rendering. I have almost 10 sheets of notes. Turns out this is not as trivial as I always thought, but I think I make this work.

>making a game engine instead of a game
ngmi

Brainlet cringe.

How do I enlarge fonts in menu in QtCreator? I want to enlarge whole QtCreator gui.

>kotlin
it's bretty good

New to programming pls b nice
Why does my rock paper scissors game return wrong answers half the time its ran? extremely rough draft:
import random

rock = 'rock'
paper = 'paper'
scissors = 'scissors'

paper > rock
rock > scissors
scissors > paper

computer_choice = [rock, paper, scissors]
players_choice = raw_input("Rock, paper, scissors? > ")


while True:
if players_choice == 'rock' or 'paper' or 'scissors':
roll = random.choice(computer_choice)
if roll > players_choice:
print roll
print "YOU FUCKING SUCK\n"
break
elif players_choice > roll:
print roll
print "YOU FUCKING ROCK BABY\n"
break

Thanks

fuck off retard

user what r you doing

he's trolling

because you're comparing strings numerically

ganbarimasu

Attached: 1552926067980.png (1200x675, 733K)