/dpt/ - Daily Programming Thread

What are you working on Sup Forums?

Old thread

Other urls found in this thread:

support.amd.com/TechDocs/25112.PDF
unisonweb.org/2015-05-07/about.html#post-start
cs.cmu.edu/Groups/AI/html/cltl/clm/node44.html
wiki.installgentoo.com/
gitgud.io/users/sign_in
ideone.com/XtLT6L
twitter.com/SFWRedditImages

First for Pelles C!

...

...

...

(define/contract (sum lst)
(-> (listof number?) number?)
(foldl + 0 lst))

support.amd.com/TechDocs/25112.PDF

There's some good shit in Chapter 2.

>be compiler
>tfw void*

It's actually the simplest case, you know.

What esoteric programming language is this?

Someone give me something to do in C++. I'm past the point in Project Euler where I can just brute force everything, so now I'm bored...

Reminder

>contract
what shitty thing is this?

I just wanted to force a joke.

What does /dpt/ think of Unison?

unisonweb.org/2015-05-07/about.html#post-start

The editor looks pretty cool tbqh

Contracts are really nice to be able to quickly create predicates

;; a "reserved thing" is either
;; a name
;; a single index
;; a range:
;; (list )
;; (list 'max) - unbounded
(define (reserved-thing? x)
(or (string? x)
(exact-integer? x)
(range? x)))

(define (range? x)
(and (list? x)
(exact-integer? (first x))
(or (exact-integer? (second x))
(eq? (second x) 'max))))


;; we can make this much shorter with contract combinators, which end
;; with /c in the name

(define range?
(list/c exact-integer?
(or/c exact-integer 'max)))

(define reserved-thing?
(or/c string?
exact-integer?
range?))


You can also put contracts on functions which automatically checks inputs and outputs. It does some comlicated wrapping to guard higher order functions

>yet another irrelevant functional programming language
Don't we have enough of those that go completely unused?

Why bother when you could just use dependent types and make it impossible to send invalid input to functions?

As an aside, Clojure fans seem to miss the point on this too. Cool, you've got Clojure.spec, but it's fundamentally no different from putting a bunch of asserts at the start and end of a Java method. It's still going to blow up at runtime rather than during compilation.

Isn't this just another way of doing type specifiers?

I think Common Lisp has this.

Not that guy, but there's also Typed Racket, however that requires you to specify types at all times, while contracts are an as-you-go sort of deal. Sure, you could specify the types for shit to be Any, but that would just be unnecessary.

Racket contracts and Typed Racket don't aim to be magic catch-all perfect solutions ("dependently typed code has no errors!" is a meme), instead they aim to make it easy to create checks that use idioms you'd usually be using in scheme anyways, like passing some set of symbols as an argument (the contract combinator (symbols ...) or using a symbol as a contract (or/c 'a 'b 'c) ), lists/vectors with a specific number of elements (list/c, vector/c), homogenous lists (listof, vectorof) etc.

Sure, but it produces real predicates, which are objects like any other, making it super easy to create new "types" (they aren't really *types*, they're predicates/contracts). CL uses some weird form of interpreting quoted stuff as a "type" IIRC and has special cases for different types of integers and stuff. Racket's contracts are very intuitive, yet still powerful. Most of them could be naively implemented with just a few lines of code.

How the fuck do I get the Vulkan SDK to work on Debian? Someone already made it? Using a R7 270X btw.

Lmao type specifieres are literally predicates.

I know there's one book in the wiki, but is there any other books or general materal for learning Ada?

Not according to cs.cmu.edu/Groups/AI/html/cltl/clm/node44.html

You build a weird quoted expression and then pass it to TYPEP

>"dependently typed code has no errors!" is a meme
Of course dependently typed code can have bugs, but dependent types allow you to make a large class of boring bugs simply impossible. Having a compiler check the boring bits of programming for me frees up mental capacity to think about higher-level concerns.

But dependent types also require you to write a bunch of boring confusing proofs

They SPECIFY types, they literally are predicates.

>dependent types also require you to write a bunch of boring confusing proofs
How so? C++ templates are a fine example of dependent types that have the proof built in as the program.

Sadly true at the moment. There's huge scope for improvement.

(Not that anyone forced to target the JVM or CLR in order to satisfy peculiar client fetishes will ever see it.)

We seem to be using the term "predicate" in different ways. I meant it specifically to mean functions that objects and return booleans

Lmao C++ templates aren't depedent types

You mean lisp function objects of type 'function
I mean why can't typep work, it gives a boolean.

With contracts you literally just combining arbitrary predicates into larger predicates

Types are first-class in C++ templates and the template system is Turing complete. That's exactly what's required of a dependent type system.

That would probably have a way better answer on Stackoverflow. Off top of my head:

- force non-negative number always
- doubles your max positive number
- anything that touches hardware like arduino code ought to be unsigned most of the time, the 8th bit is usually very important

For jobs C is used for (low level bit fucking and hardware and systems shit) unsigned is baller. For higher level stuff, well there is a reason Python doesn't give much of a shit about it.

So anything with a turing complete static analyzer is "dependent types" now?
I think you need to do a bit more research. Even if C++ types are dependent, they're seriously lousy dependent types.

There are many Turing-complete languages that are lousy but nevertheless Turing-complete.

>Even if C++ types are dependent
C++ template types are dependent.

What is Sup Forumss opinion of Perl 6?

How do you express something like "the result of this function is an integer greater than the argument"

literally who

Perl's strength is in string manipulation

and the logo is cute

i don't python has any limit on ints now

>I gobble them, while they gobble my filth.
>what do i care!?

You can do that in CL
'(or (and (satisfies prime?) integer) character)

It can be an intersection of types, or a union, etc.

qt

how come we don't have a wiki

sticky you nigger
wiki.installgentoo.com/

>upload image of cat in popular blog platform
>click post
>nothing happens
>image is posted

>upload image of nude women
>notification about NSFW, sensitive material, etc
>delete image before posting

how do they do it? AI shit scan every uploaded image posted checking for nude content?

>
There wouldn't be anything interesting in it anyways except for various ways to perform FizzBuzz in languages non one uses.

Yes that's what I'm saying, Python doesn't care if they're signed or not. Hardware and low level bit shit DO care the way an autist cares about the peas being a perfect shade of green and not touching the onion rings, throws a goddamn fit if you screw the tiny shit up.

The fact it's turing complete makes it non-dependent

how come we don't have a gitlab

gitgud.io/users/sign_in

gitgud.io/users/sign_in

how come we don't have an open-source imageboard template using Elixir?

cause elixir sucks

scripting in shen.... Are you trying to drive people to drink bleach?

>>>/news.ycombinator.com/

It is the future

lainchan

how come we don't have a operating system written entirely in Perl and Python, with a DE using jQuery/Java?

Teaching myself java by creating games, so far I made bricks, snake, and now more of a top down zelda like game, I will probably not even actually make much content for it, since I just want to gain some experience from it and create the next one.

Just published a library as GPL, feels pretty good

How come we don't have a deep learning API written in Scheme using a matrix math library written in Io and JSON?

You've got several well documented kernels out there, go to town, build your own os with the only binary being the kernel and your interpreter of choice

Literally nothing is stopping you but your laziness.

Replacing the kernel... that's harder.

Cool make sure you check Game Programming Patterns out too.

gonna check it out, thank you

I believe I am too stupid to understand SICP

You'll fit in just fine :)

How the fuck do you read the purple text on a black background

Combinatorics is the comfiest math

Reposting.

Rate my poker deck simulator, it only uses 52 bytes of memory!

ideone.com/XtLT6L

it is actually more readable, just in the video its hard to read

>goto

aaand droppped.

do you use linux?

That still seems pretty bad to me user

Goto is a perfectly reasonable operation in C

yes and no.

the code is perfectly fine. you don't need to use a goto tho

the alternative is to use a clunky flag variable in a while loop
it's the same thing in a roundabout way

I've almost given up on my genitalia detection neural network. There's too many false positives (pic related) likely caused by how I labeled that data or by the lack of data.
I'm most likely going to narrow focus on just cocks. So far I've labeled several thousand cocks in a new dataset and am aiming to label 1000 images a day.

>rand()

sounds like you're using computer programming as an excuse to eat dicks all day

what do you use?

mt::19937 :^)
but seriously, for c: arc4random

complimentary multiply with carry.

rand is faster and in this program there's no need to use a4r

Your false positives are in the ~right area though, you just need to refine it.

rand % 52 won't actually give you a uniform distribution, numbers less than RAND_MAX % 52 will be about 52 / RAND_MAX more likely to occur, or something like that.

but I'm checking for duplicates so it doesn't matter, right?

In java am I going to be made fun of for using
while (true)
I read somewhere that it is a joke

I admit I get distracted at times by the images, but I only have an academic interest in this problem. I won't be as distracted now that I added a ton of yaoi to my data.
Nah, I want bounding boxes around actual genitals, not where generals should be

if you want an infinite loop it's fine
while (1) is more common though

Well its not like it really matters for pictures like that since your goal is de-censoring.

>not for(;;)

while(!0)

while (35 > 24)

I think it means you will have more spades in the lower k/2 of your deck. If RAND_MAX is fucking huge you probably won't care, since 52 / RAND_MAX higher probability to be picked would be negligible.

I don't remember the right way to do it off the top of my head. I think something like:

do {
k = rand() % 64; // divisor needs to evenly divide RAND_MAX or RAND_MAX + 1, forgot which
} while (k > TOTAL);

def fuck():
while(7 is not 9):
yield True

while(fuck()):
print('dicks')

//file.h

// code

#define FALSE "0"

// other code


#include file.h

// Using while to comment out code
while (FALSE) {
// code
}