/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?

Other urls found in this thread:

akaribbs.mooo.com/
github.com/dracula/dracula-theme)
fonts.google.com/specimen/Oxygen Mono)
colorsublime.com/
soundcloud.com/anton-kho/jungle-etude-2-feat-simon-peyton-jones
youtube.com/playlist?list=PLLGk12CjUeW50Xt3-ObW2rqVPZaIG8zio
youtube.com/watch?v=cVVlMQved8k&index=6&list=LLD5Wsn4RKmDg1O3Qg0as2Lw
twitter.com/NSFWRedditImage

Image processor in C++ implementing SSE optimization.

GAS THE TRANSVESTITES

Monads.

Question, How can I improve this? should I include strings? I'm tasked for my assignment to find the amount of profit made after selling the stocks.

My main question is, When I run what I have here, I want to be able to continue the sentence after "stockValue" variable on line 24.

What would be the best way to do that?

goto

You still haven't learned Haskell, have you?

Still working on my C messageboard!
akaribbs.mooo.com/

I added blockquotes and post quoting last night.

>What would be the best way to do that?

Remove the newline?

goto? how i'll look it up, I pretty much just want to get rid of line 25.

monoids, endofunctors, applicatives, GADTs.

This is why college sucks for programming.
They spent too long teaching you to write dumb command line calculators.
They don't even teach you about stdin so you end up making stupid assumptions like getc() is for keeping the window open after you're done.

Can you highlight what you're referring to for me?

I bet that someone make your homework...

workin on stuff

why do you spend so much time on this? You aren't actually thinking of making it a real full site right?

Nope, Im trying here! geez, Goto isn't something I've seen yet in the book.

im learning about storage classes
and I don't understand thread storage
what is a thread, and what does it have to do with concurrent programmin

explain using baby words please, since I'm kind of retarded

Do you know what those are or are you just repeating it?

>Can't detect it's meter
>it's

>why do you spend so much time on this?
Because it's fun and I wanted to to try my hand at webdev in the only language I know.
Also, I don't work on it everyday.

>You aren't actually thinking of making it a real full site right?
You don't have ambitions?

I'm just saying buzzwords. The only thing I've learned about haskell is monads. One of these days, I ought to actually learn Memeskell.

Shit man, thanks. it clicked what you're telling me.

Let's share our editor color schemes.

I'm currently using the Dracula color scheme (github.com/dracula/dracula-theme) with the Oxygen Mono font (fonts.google.com/specimen/Oxygen Mono) in Sublime 3

I'm quite happy with it.

Currently trying to learn C#/Cocoa to start moving out of the command line, and I was wondering why C# handles BOOLs as "unsigned chars" wouldn't it just be easier to keep handling BOOLs as C/C++ boolean variables?

I must be the only person who prefers light color schemes.

Changed the font and colors a bit, but I use XCode's "Anubis" scheme, which is pretty.

I like bitmap fonts and all, but why have you got the size so high?

Gohu is supposed to be used at 8 point, I think.

A functor (in the context of Haskell, not category theory) is a type constructor (like a generic) providing a function called fmap

A functor lets you lift a regular function (a -> b) into a function on your data type (F a -> F b)
Effectively it replaces all the a's with b's, using a function from a to b
For a container, that will apply the function to all the values.
fmap (+3) [1,2,3] = [4, 5, 6]
-- this is also called
(*7) [3,6,9] = [21, 42, 63]

An applicative is similar, except it knows how to take a datatype containing functions, and combine it with a datatype containing inputs (into a datatype containing results), i.e. F (a -> b) -> F a -> F b
For instance, a ZipList will take a list of functions [(+1), (*2), (/3)] and a list of inputs [3, 7, 1] and apply each input to the respective function
ZipList [(+1), (*2), (/3)] ZipList [3, 4, 5] = ZipList [4, 8, 5/3]
The reason there's a ZipList is because the regular list doesn't do this - the regular list produces all combinations (applies each function to every element, and concatenates the results)

[(+1), (*2), (/3)] [3,4,5] = [3+1,3*2,3/3] ++ [4+1,4*2,4/3] ++ [5+1,5*2,5/3] = [4,6,1,5,8,4/3,6,10,5/3]

It also knows how to put a regular value into the datatype (called "pure")
There are some laws for this that are important in some circumstances, but you don't normally need to know them
For lists, this just gives back a singleton list, pure x = [x]
For ZipLists this gives back an infinite list, pure x = [x,x...]

I really don't know... I guess I don't like having too much negative space on my screen, that and I know that Gohu has two variants (8pt and 11 pt), and I chose the higher one out of a whim

what do you think about making a "programming for dummies" visual language for my senior honors project? doable in 2 semesters?

The screenshot you linked is about Objective-C, not C#, and the question makes no sense for C# (where ints/chars are not implicitly castable to bools)

Monoids are extremely simple.
It's a datatype, with an associative binary operation and an identity type.
Basically, you can combine elements and there's some "empty" element

Binary: a b = r

Associative: a (b c) = (a b) c
(The parentheses don't matter)

Identity: i a = a, a i = a

Just write a bunch of #define macros in C and hide them under dummies.h or whatever.
You'll finish your dumb "language" in 20 minutes.

I actually understood this. Thanks. Now when I meme, I can do so with authority.

Wait... (And I fully acknowledge this is full-retard territory) I thought Objective-C and C# were the same thing. I've frequently seen them concurrently in StackOverflow, but that might be me not knowing the difference

I'll def. use a light color scheme if I didn't had eye cobwebs and actually hated my eyes.
A bunch of funtions that will safely allow me to save a .xml, currently it only needs to move the temp file to overwrite the original, and map my object to save it properly.

>I thought Objective-C and C# were the same thing.

Afraid not, chief.

Objective-C and C# are completely different languages (besides both inheriting a lot of syntax and datatype conventions from C).

Place the comments on or above the lines where they are relevant.

I got fired /dpt/, I spent a mere 3 months as an AI developer. How do I write a script that will dispense helium into my lungs?

alright... Reading a SO entry on the difference between them now... Thanks for making the distinction clear, though!

You didn't commented your code right? Those fuckers gonna suffer.

No, because in Javascript
o.m()
is different from
var f = o.m;
f().
Within the body of m, `this` will be bound to o in the first, and null in the second.

Nice work!

The one thing I made was already being replaced when I was fired

If you're developing for macOS or iOS, learn Objective-C. If you're developing predominantly for Windows (and to a lesser extent, Linux), learn C#. C# is probably easier to learn by virtue of having Visual Studio.

Code tags and spoiler tags when?

sounds good, i hope you're not implying i should do something more difficult

implement white space preserving for code and some way to way to make an ajax call to receive more up to date posts. Redirecting is kinda lame

anyone know any good bright sublime text skins? All the ones they have are kinda shit

GADTs/generalised algebraic data types

you've got algebraic data types:
data MyPair a = MkPair a a

on the left is the name of the type (MyPair), the type variables / parameters (a)
on the right are the constructors (MkPair)
the things following a constructor are the parameters to the constructor, "a" is the type variable from earlier, so this
data MyPair a = MkPair a a
translates to this
template
struct MyPair {
MyPair(a, a);
a p1,p2;
}


(if the name of the type occurs on the right side, then it's either recursive (for a parameter to the constructor), or the constructor itself is given the same name as the type, e.g. data MyPair a = MyPair a a)

Multiple constructors:
data MyCases a = Left' a | Right' a

The constructors are all 1 to 1 - all the information in them is preserved.
A different constructor is a different value of the datatype, e.g.
data Bool = True | False
(these constructors take no parameters)

There is a direct translation of ADTs into an OOP style - each constructor becomes a subtype
--

GADTs adds to this, you can now specify the signature of the constructors:
data MyPair a where
MkPair :: a -> a -> MyPair a
-- MkPair takes an "a", and another "a", and gives back a "MyPair a"
-- the result must always be a MyPair something


but you can also specialise
data MyPair a where
MkPair :: a -> a -> MyPair a
MySpecialPair :: MyPair ()


-- (MyPair a)'s in general are now relatively untouched, but (MyPair ()) has an extra value (MySpecialPair)

If you were creating something like an expression tree, you could for instance require that the first parameter to an "if" branch will produce a boolean result

>A different constructor is a different value of the datatype
Sorry, a different constructor makes a different value
So even if they all take the same parameters, because they're different constructors they make different values.
Or if they take no parameters (like for Bool), then they just are different values.

I've already answered these, I was just wanting to see how my answers compared to /dpt/'s response. This is for concepts of programming languages class.

>putting True before False
I bet you count starting from 1 too, you savage.

I always put the Truth first

1. because it's shit
2. they're both used by people who can't program
3. ruby's a numale language so idk
4. trick question; C is perfect
5. not requiring the user be from a village in india

>Cause Sepples wanna have good features.
>They're used mainly as webdev tools, they differ in that JS can be rendered by the web browser, and PHP is executed in the server.
>The capability to compare not only integers.
>IDK.

>concepts of programming languages
>all examples are pedestrian shit

dude that's awesome. Can i get source files somewhere?
I'm learning C

>Forgot the third lmao, ruby operators are treated as objects

Which means you consider Falsity to be greater.

No it doesn't

Not off-hand but this is where I've gotten most of mine so far: colorsublime.com/

According to the autoderived instances of Ord and Enum it does. Prelude defines
data Bool = False | True
for a reason.

I didn't autoderive either
I always put the Truth first, regardless of which way I sort

Next you'll tell me that you order your conses before your nils. I shudder to think.

sort = True : sort

That's a pretty cool list of Trues, but why did you call it sort?

It's in order.

This was all pretty informative. Thanks.

False : Prop
False = (A : Prop) => A

True : Prop
True = (A : Prop) => A => A

ah ok thanks

I'm trying to think how I would implement this without trashing the nice modular design I have going.
Spoiler tags are easy, but code tags now means I have to bypass the whitespace filter somehow.

Maybe if I copy all text between tags into a separate buffer, overwrite the text with "AAAAA" so the whitespace filter doesn't touch it, and then memcpy it back.

CSS allows you to add scrollbars on overly long divs, right?

I'm trying to think how I would implement this without trashing the nice modular design I have going.
Spoiler tags are easy, but code tags now means I have to bypass the whitespace filter somehow.

Maybe if I copy all text between {code} tags into a separate buffer, overwrite the text with "AAAAA" so the whitespace filter doesn't touch it, and then memcpy it back.

CSS allows you to add scrollbars on overly long divs, right?

With GADTs you can then pattern match on each constructor, bringing any relevant details into scope (normally this just means the values they were constructed with)

data MyPair a = MkPair a a

func (MyPair x y) = x + y


data List a = Null | Cons a (List a)
-- a list is either empty or cons (a head and a tail)

len Null = 0
len (Cons _ t) = 1 + len t

-- _ is a wildcard that basically means that I don't need that particular variable, I could have just said (Cons h t) and not used h


The next thing to learn about Haskell I suppose would be type classes

If you understood that, then you're 80% of the way to Monads.

A Monad is an Applicative functor with one more operation
join :: F (F a) -> F a.

That's it. That's literally all there is to them. The only other thing is that all these functions have to obey certain rules when you combine them in certain ways.

Here are the instances:
instance Functor [] where
fmap = map
instance Applicative [] where
pure x = [x]
fs xs = [ f x | f

hello dpt.

not really actual programming, but using select case, instead of for individual users, how do i set it to a security group instead?

eg

WshNetwork.RemoveNetworkDrive "J:", True, True
Select Case lcase(WshNetwork.UserName)
Case "barney.fiddledicks","raynard.goldsteinn"
WshNetwork.MapNetworkDrive "J:", "\\server\control point$"
End Select

for individual users, how to do it for a group? Is it just wshnetwork.*groupnamehere*?

...

Don't forget defining fmap in terms of return and bind:
fmap f = (>>= return . f)

Yes, but we're in a post-FAMP world now, no point in restating the trivial. You could also at least call unit `pure`. `return` was a mistake.

i printed my ABCs

Logisim is neat.

you also don't need the outer while loop.

could you give us some context at least? what lang is this, where is it used, and what for?

functional

programming

""""""""""""""""functional""""""""""""""""
""""""""""""""""programming""""""""""""""""

delet this

soundcloud.com/anton-kho/jungle-etude-2-feat-simon-peyton-jones

...

Give me some programming music. I have some really boring shit to do tonight.

youtube.com/playlist?list=PLLGk12CjUeW50Xt3-ObW2rqVPZaIG8zio

...

youtube.com/watch?v=cVVlMQved8k&index=6&list=LLD5Wsn4RKmDg1O3Qg0as2Lw

I have a collection of 461 songs I like

wait, so all externs are initialized to 0?

>wait

tfw half way through your project you realize you were retarded when designing it but you can't undesign it because it's already live and in use by 10+ people

...

>tfw you thought a lot about a project that literally no one uses

oh man I know this feeling WAY too well

then again my tools improve my life so not totally worthless

you can always make it open source :/

i'd have to start over from scratch but use the same database or migrate it to a new structure