/dpt/ - Daily Programming Thread

Old thread: What are you working on Sup Forums?

Other urls found in this thread:

pastebin.com/VfBUVQyn
hackage.haskell.org/package/mtl
twitter.com/NSFWRedditVideo

urllib is part of the standard library and is sufficient for my needs.
What's your idea?

Gonna get a Vocore 2 and write web apps in mips assembly

Next up: building a house out of toothpicks

why is it that in uni the abstract definition is always shown before the concrete example?
why not the other way around?

balls deep into learning assembly, x86 arch NASM assembler.
Any good resource manual?
Art of assembly doesn't look so good.

Because example could limit your understanding, since it would frame it in specific context and some people would think it's only useful in this particular context.

Maybe try GNU's programming ground up book. However I think it's a bit under your difficulty level.

fucking lisp this shit is so hard to read

why can't they just use structure like normal people

Welcome to the world of meme programming.

You have to use an editor that auto-indents for you.

Emacs, Dr racket, gedit, ... You sometimes have to turn it on manually though. Also parentheses matching is must.

Properly indented lisp is quite readable.

>I'm using LISP and I don't like LISP
>Why can't they make LISP be different

>using toothpicks instead of your own cut tiny wood pieces
faggot

Lisp is moldable folks. You can change anything to suit your problem, style and personality.

For example Dylan is lisp with syntax (its macros are bad because of that though)

Really makes you think...

>people who saw the fast inverse square root code thinking it's cool to write WTF in your shitty code

I was more thinking about C++'s sky-high WTF density, even when adjusted for language frequency.

well maybe but I'm pretty sure people who write those comments aren't very good at C++
but I have to admit that sometimes it's hard to understand a piece of code with a fuckload of template and shit

QUICK, MAKE A PROGRAM THAT TAKES AN UPPERCASE LETTER, AND RETURNS SOMETHING LIKE PIC RELATED

not doing your homework faggot

>THAT TAKES AN UPPERCASE LETTER
Then what, what do I do with it? Your picture doesn't require user input at all.

look at filename faggot, I literally took a screenshot of my own output
also, confirmed for code monkey that can't even make a single program

char a = 'A'; //an uppercase latter
printf("%c\nAB\nABC\nABCD\n....",a);

all right
10 INPUT A$
20 PRINT "A"
30 PRINT "ABA"
40 PRINT "ABCBA"
50 PRINT "ABCDCBA"
60 PRINT "ABCDEDCBA"
70 PRINT "ABCDEFEDCBA"
80 PRINT "ABCDEFGFEDCBA"
90 PRINT "ABCDEFGHGFEDCBA"
100 END

what happens when a signal handler gets interrupted by another signal?

does the OS wait for the handler to finish?

or does the new handler start executing immediately, and returns to the first handler?

const " A\n ABA\n ABCBA\n ABCDEDCBA\n ABCDEFEDCBA\n ABCDEFGFEDCBA\nABCDEFGHGFEDCBA"

Usually if signal handler called, no other signal can interrupt it.
If it's not, it's written specifically.

use ur brain

Nigga do I look like professor X to you? Do I sit in a wheelchair motherfucker?

If you install the handler with sigaction(), you get to control which signals are blocked while the handler executes (sa_mask field) and whether the same signal can be received while the handler is executed (SA_NODEFER flag).

If you use signal(), it's implementation-dependent.

If I wanted to make sure every signal was handled, I wouldn't block the signal while handling it, right?

and if that keeps happening, I would have a stack overflow?

haha dude, he used "nigga", hahaa, lmao
>>>/facebook/

Blocking a signal doesn't discard it, it just delays handling until you unblock the signal.

>implying I'm not black

>still replying
die nigger

You're the one who's being a daft cunt and refusing to specify what in the fuck you even meant in the first place. If you're going to post pointless shit that you never intended for anyone to understand then maybe (You) are the one who should stop posting?

foo c = padd $ map baz ['A'.. c]
where padd = let l = length ['A'.. c] - 1
in zipWith (\x y -> replicate x ' ' ++ y) [l,l-1 .. 0]
baz a = let qux = ['A'.. a]
in qux ++ reverse (init qux)

This, tbqh

And then people dare say that lisps are unreadable.

fuck off satan

Excuse you but that looks exactly like a lisp except it has words and shit instead of parens.

You sure?
(defun i-suck-cocks (c &aux (a (char-code #\A)))
(do* ((b 0 (1+ b))
(c (char-code c) c)
(d (- c a b) (- c a b)))
((< d 0))
(format t "~%~v@{~A~:*~}~*~{~A~^~}"
d #\Space
(do ((e 0 (1+ e)) res)
((= e (1+ b))
(do ((e (1- b) (1- e)))
((< e 0) res)
(push (code-char (+ a e)) res)))
(push (code-char (+ a e)) res)))))

I want to append a vector into another vector, what's the best way?
b.append(b.end(), a.begin(), a.end())

// OR

b.append(b.end(), a.cbegin(), a.cend())

It doesn't matter. The two are equivalent.

>one-click it-just-werks screen streaming program (starts web service and outputs URL you link to friend)

lossless mode works pretty decent now, but still requires you to a have first world internet connection at 60 FPS
34 dirty regions
size of entire frame: 1916958
size of encoded frame: 115743
diff %: 6.04%
after compression: 48697
diff %: 2.54%

(dragging a window around)

Guess you really have to video encode it to get usable performance

fun :: Int -> String
fun n = [0..n] >>= (pad letters)
where letters = map offset . symm
pad i s = concat [replicate (n-i) ' ', s, "\n"]
offset i = toEnum (i + fromEnum 'a')
symm i = [0 .. i] ++ [i-1, i-2 .. 0]

Try it with scheme or racket. I admit common lisp can get ugly quickly, its basically the perl of lisps. The only really bad part is format anyway.

I will write racket version when I come home

fun :: Char -> String
fun c = [0..n] >>= (pad letters)
where pad i s = concat [replicate (n-i) ' ', s, "\n"]
letters = map offset . symm
offset i = toEnum (i + fromEnum start)
symm i = [0 .. i] ++ [i-1, i-2 .. 0]
adjust k = fromEnum c - fromEnum k
n = adjust start
start | c `elem` ['a' .. 'z'] = 'a'
| c `elem` ['A' .. 'Z'] = 'A'
| c `elem` ['0' .. '9'] = '0'
| otherwise = toEnum 0

if you replace
[0..n] >>=
with
symm n >>=
you get a diamond

asp.net core web app.

Does anyone have experience with SendGrid or Mail Gun for account confirmation and password recovery?

I'm having problems with getting it to work. Google and stackoverflow offer no working solutions. I assume it's because .net core is such a new technology. Any input would be appreciated.

Even worse, you'll have to use recursion to handle iteration then.

everyone knows an example is easy to copy without fully understanding.

Giving a more abstract definition promotes coming to your own solution, then showing a correct example highlights your mistakes.

Nope, the first one is strictly easier to read and doesn't trigger my autism.
Kys.

iteration is recursion

Daily reminder kore.io exists for high performance web-development.

could you guys help me with the recursion on this? I am not sure how to set it up properly

this is supposed to be the midpoint displacement algorithm but I am not that good at it

pastebin.com/VfBUVQyn

you can use plot dot ly to check the generated points

Why do beginners have to make simple things so complicated?

it's always messy the first time
but then you learn, eh

I just have no idea what I'm doing 2bh

Finally the proper image

Next thread will be Hime

1. Implementing looping macros is trivial
2. Recursion is easy
3. Racket provides a bit more than just usual recursive functions - map, for, foldl foldr, ...

what about fix

I need to do one (1) microwave oven in VHDL or I'm fucked. The thing is my teacher sucks and we don't actually learn VHDL in classes. We "learn" VHDL. Pic is the FSM chart of the controller. Do any of you have any tips, hints, anything to save my ass? (I need to other shit than the controller too, decoders for the displays etc).

Fugggg forgot to crop the monkey speak, now you'll know I'm not a proud caucasian heterofluid cis male

would still be nice to have a bit of help on this
already spent several hours trying to work it out

We use an educational Alterra board btw. And the way we """""learn""""" VHDL is by literally copy and pasting things from the slides into the magic board and see it work. I tried doing my own shit but it wasn't enough.

>you can't use that int as a boolean here pls change xDDD
fuck
java
holy hell

This one is maybe excusable, but null pointers not converting to false is infuriating.

a = ''
for i in range(65, 73):
print((a + chr(i) + a[::-1]).center(15))
a+=chr(i)

65.upto(73).reduce("") do |acc, i|
puts (acc + i.chr + acc.reverse).center(17)
acc

dat ruby

It's actually pretty much like the python version.
It looks even more like it when you do like this:

a = ''
for i in (65..73)
puts((a + i.chr + a.reverse).center(17))
a+=i.chr
end

>using apply and bind when not necessary

I never knew python could be that ruby-like.

they make it much nicer, and that is a completely proper use of bind

what fix?

What resources do you use for learning SFML?

>he uses bind outside IO
lmao, why would you

fix :: (a -> a) -> a
fix f = f (fix f)

If the only monad you use is IO, then you're using Haskell wrong

Writing tests and fixing bugs in a post text parser.

Well, Ruby is a flexible littel beast, you often have a lot of differnt ways to do things. Since there was a big python influence from the start, you can always try to write in a "python-like" way.

In return the newer Python version "borrowed" some nifty stuff from Ruby, so they are getting close to gether.

For me that's a good thing, because I'm good with Ruby and currently have to learn Python. So have my apologies if my python programms don't look "pythonic" to the core, I'm trying to get better..

teach me
where else would you use bind and applicatives
does one have to know Control.Monad / Applicative inside out

aside from the use in the code i posted
hackage.haskell.org/package/mtl

I know both (learned ruby first), then learned python by making a VOIP protocol server, but I don't think your python code looks """unpythonic""".

I'm at an impasse and don't know anymore
I feel stupid and need help
I have an int
and when the int reaches 10 I want to do something
then again when it reaches 100
then again when it reaches 1000
and so on
how do I do that without going full spaghetti code?

if your language support switch statement you can do that and call functions.

for (int i = 0; i < 2000; ++i)
if (i > 1000)
;
else if (i > 100)
;
else if (i > 10)
;
else
;

Take the integer log10 and do something when it increments.

Or just keep a counter of the last power of ten you saw (10, 100, 1000), and if that number*10 is smaller than your number, do your thing.

That's exactly spaghetti code though.

i feel there's going to be some amount of spaghetti unless there's some sort of regularity among the different actions you want to take

No it isn't

pseudo code
let powers = [10^i | i

Thanks!

Right now I'm often confused with "len([1,2,3])" vs. "[1,2,3].length" ..

Oh, well.

its not spaghetti code retard, spaghetti is unformatted and meandering
its perjorative for non-indented code and GOTO statements particularly

that's what I mean by spaghetti code
but thanks
yes it is
it doesn't scale, can't write 10000 statements in my code for every 10^i I could reach
thank you very much, sounds really good

Spaghetti code means code whose control flow is hard to follow because it jumps around like crazy.
Having a hueg switch or a billion manual if statements if just as bad as gotos.

You didn't say it would be every power of 10. You just said 10, 100 and 1000.

I can't believe of fucking autistic most of Sup Forums is, holly shit.
Are you even human?

just kill me now

Do you want to do the same thing or different things?