/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous Thread:

Other urls found in this thread:

winestockwebdesign.com/Essays/Lisp_Curse.html
pastebin.com/mguaQUj1
cs.utexas.edu/users/moore/acl2/
schneier.com/academic/solitaire/
raw.githubusercontent.com/wiki/ekmett/lens/images/Hierarchy.png
amazon.co.uk/gp/product/0857290177/
gwan.com/blog/20160405.html
twitter.com/AnonBabble

Lisp is the most powerful programming language.

Can Sup Forums count the number of 1s in a binary number without loops or recursion?

Lisp is not a language.

unit32/64 or what?

cat num.txt | grep -c ‘1’

shouldn't the last one be
cuppy.drink();

oblig
winestockwebdesign.com/Essays/Lisp_Curse.html

popcnt

working on fizzbuzz because I wanted to see how approximations work
last time I posted this it was just root now it's got log as well
pastebin.com/mguaQUj1

In Lisp, this is just logcount.

lisp or ats?

from an OOP perspective, yes, the class itself should hold all the methods you need to change it

10/10

No, because 'drink' is not the responsibility of Cup.

externalDrinkingFramework::factory::make_drinker().visit()

cuppy.fill(coffee) would probably change the content attribute of cuppy, so drink is a utility method that should be in cuppy because it changes that attribute back to empty

Not all object systems follow this line of thought.

Any good books on proving program correctness?some user mention dependent types and I got curious

Interactive Theorem Proving and Program Development: Coq'Art: The Calculus of Inductive Constructions

maybe

>Coq'Art
hee hee

cs.utexas.edu/users/moore/acl2/

Fill isn't the responsibility of cup. It should be fill(cup, coffee);

c++ is the greatest language of all time

aight

to
>solitaire cipher schneier.com/academic/solitaire/
cheers for making me aware of it
sounds interesting enough to overcome my laziness

>not coffee.enter(cup)

my automated booking app. Working on the time overlap algorithm for it now.

>not grinding your own java beans

>not fluid.asInstanceOf[Coffee].penetrate(container.asInstanceOf[Cup])

what would be the functional programming equivalent of this?

...

person.drink(cuppy)

>booking app

another one?

Idris is better than every currently mainstream language.

The cup will stay safe and sound due to lack of side effects

>POOlets can't even into POO
Liquid liquid = cuppy.empty();
bob.drink(liquid);

raw.githubusercontent.com/wiki/ekmett/lens/images/Hierarchy.png

yeah, can you imagine
the nerve of the guy
he'd better go back to advancing the state of the art in fizzbuzzology

>bob is not defined

>spilling the coffee on the ground and then drinking it like a dog

mpd client in ATS as mpc doesn't provide playback progress which I need for tmux to display progress in the status and want to learn ATS.

After that it's catwm-xcb in ATS as I need to move away from dwm as it's become a pain to maintain patches to the point where I've just made nixos fetch a source tarball and build from that.

Then a few other utilities since maintaining bash scripts is also a pain.

>bob is not a local variable therefore bob is not defined

>subject object dichotomy
What if that liquid is female?
You're basically raping it.

>I empty the cup
>I handle the liquid, sans cup
>I make bob drink the liquid I was handling
advanced metaphysics up in this bitch

you're missing the point, laddy

>getting the liquid out of one container and into another is the same as spilling it onto the floor

seeing as the liquid is inside the cuppy
followed by inserting itself into bob
I think it's safe to say that the liquid is white cishet male scum raping the poor cuppy and bob, who identify as whatever they want

>liquid goes out of the cup and into bob
>he can't wrap his mind around it

you have not specified where to empty it to so it's just gonna land on the floor

>out of the cup and into bob
If you put thread.sleep() between the two calls where will the liquid reside during the pause?

>you have not specified where to empty it to so it's just gonna land on the floor

Please take discussion of the following languages to because it does not belong in /dpt/:
>JavaScript
>TypeScript
>CoffeeScript
>PHP
>Python
>Ruby
>Go
>Java
>C#

anything between those 2 lines is illegal state

>poothon
>jaba
>see pound

>wdg
oh lawdy

also, go can't into generics, so it's a perfect replacement for shitty c CLI tools

proof that FPtards are just brainlets too dumb to understand OOP properly

>the transient state of the liquid as it's being transferred between containers isn't being modeled
>that means the code models the liquid being spilled on the floor and licked up by bob

so looping the conversation back to the ol fizzbuzz, i'm reading online that you should be checking for both 3 and 5 first (i % 15 == 0) before checking for each one individually to optimize the code, but that doesn't make sense to me. isn't it a waste to check for 15 first since it's the rarest occurrence? i don't know how exactly computers work down in the hardware level so i'm probably just retarded

i feel like i'm being bamboozled though

Person person;
Cup cup;

return drink(person,fill(cup,coffee));

>braindead fptard cultist incorrectly inserts transient state
>defends and deflects when called out on his babby-level understanding of oop
every time

That's not functional programming. That's disgusting.

But wait, what if I want cream and sugar in my coffee

Since liquid takes shape of its container, what will be returned from the call to liquid.shape() after the call to cuppy.empty()?

>fizzbuzz
>optimize the code
thank you for your time

please post a better one for this specific example

>empty cup
>liquid is now floating in the air

It's easy - just sign our code of conduct and file an issue!

dangit i knew it

does this count?
std::string s = std::bitset(5678).to_string();
printf("%d", count(s.begin(), s.end(), '1'));

>anything between those 2 lines is illegal state
Every object modeled is always in a perfectly legal and consistent state, unless you insist that Liquid is also an object (as opposed to, say, an enum) AND that it must refer back to its container, which would be an arbitrary assumption on your part.

cuppy.getLiquid()
which should return the liquid placed into the cup

function fillCupAndDrinkCoffee(coffee) {
val cuppy = new Cup();
cuppy.check();
cuppy.fill(coffee);
drink(cuppy);
}

no
this is the correct solution
x = x - ((x >> 0x1) & 0x5555555555555555);
x = (x & 0x3333333333333333) + ((x >> 0x2) & 0x3333333333333333);
x = (x + (x >> 0x4)) & 0xF0F0F0F0F0F0F0F;
ans = (x * 0x101010101010101) >> 0x38;

fill() would have to create a new cup with coffee in as a return value though, in order to avoid side effects.

>what is SOLID

>t. mongoloid who can't make a coherent argument
There is no "transient state". It's not being modeled.

Thing thing = ThingFactory.createThing() / 10

>Liquid is also an object
Nice try, brother!

using a loop is the optimal solution.

>Since liquid takes shape of its container
This isn't being modeled, so you're basically arguing with your own fantasies.

amazon.co.uk/gp/product/0857290177/
just ordered this and from a sneak peek from libgen it seems good.

there is no transient state in the RL process
yet your damaged brain decided to insert transient state in the program
another day, another fp cultist makes an embarrassment out of the cult

you just mutated cuppy you idiot

>being too retarded for reading comprehension
>being too retarded to make an argument

It's in a functional language.

Functional programming does not mean you have to use immutability everywhere.

apparently i am the best fucntional programmer in the world because NO ONE can offer a better pure soloution

Liquid liquid = cuppy.empty();
// the liquid is currently not assigned to any container therefore it must be floating in the air which is invalid
bob.drink(liquid);

Giant lookup table/switch statement?

gwan.com/blog/20160405.html
dude's spergout would make gee proud
>9. There's an array of 10,000 16-bit values, how do you count the bits most efficiently?
>Me: you shift the bits right on all the 64-bit words, the Kernighan way.
>Recruiter: no.
>Me: there are faster methods processing 64-bit words with masks but I can't explain it over the phone, I must write code.
>Recruiter: the correct answer is to use a lookup table and then sum the results.
>Me: on which kind of CPU? Why not let me compare my code to yours in a benchmark?
>Recruiter: that's not the point of this test.
>Me: what's the point of this test?
>Recruiter: I have to check that you know the right answers.

>Thought: How long is this crap going to last? A 8-bit lookup table can process bytes one after another, while the 64-bit mask-based method processes 8-byte words at a time (on top of that, modern CPU instructions even let you process 128-bit words with a 10x speed gain if portability is not a concern). As a 64-bit lookup table is out of reach for today's computers, there's no doubt on what is faster.

>it must be floating in the air which is invalid
it's in vacuum so everything's fine

is it possible to use the youtube api and reddit api to make a youtube playlist that automatically adds videos that get a certain amount of upvotes on a subreddit?

>fucntional
>soloution
sounds about right for an fptard

I recently fell in love with C. I feel my power growing as my knowledge of pointers grow.

>there is no transient state in the RL process
Of course there is, you subhuman animal. In reality, if you want to think of the liquid as a whole, there's some interval in time where it's not fully contained by any particular vessel, but is being transferred between them.

>yet your damaged brain decided to insert transient state in the program
No, you subhuman animal. As I've already explained, this approach just doesn't model this transient state where the liquid is in both vessels but not fully in either one. All the objects involved are always in a valid state where either the coffee is in the cup, or the coffee is in Bob.

wow le epic oop = poop crowd suddenly falls silent when confronted with writing 5 lines of functional pseudocode lolol

(drink person (cup-of coffee))

Yes functional programming does mean immutability. A functional language just supports functional programming well.

It can be so very soothing to read complaints about not being hired by Google.

>is it possible to use the youtube api and reddit api to make a youtube playlist that automatically adds videos that get a certain amount of upvotes on a subreddit?
is it possible to use ur mums api and dad api to make ur dad automatically suck off dicks that put a certain amount of creampies up yer mums bum

>the liquid is currently not assigned to any container therefore it must be floating in the air
This is a retarded fantasy in your head, not something expressed by the code.