Old thread: What are you working on, Jow Forums?
/dpt/ - Daily Programming Thread
Other urls found in this thread:
better-dpt-roll.github.io
godbolt.org
htdp.org
pastebin.com
esolangs.org
twitter.com
C and Haskell
>What are you working
advanced fizzbuzzery
post your code
>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?
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.
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.
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
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?
nice
>no branching
prove it
oh honey modern CPUs don't need branching to
1. stringify numbers
2. handle invalid indexes into a string
my code ıs too long and full of kebab thıngs
bless Our Lord and Savior Jesus' Fizzbuzz
>JUMP_IF_TRUE_OR_POP
fucking kill yourself retard
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
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
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+.
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.
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.
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
no shit
just use Kate.
It's time to eat.
Great images
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