/dpt/ - Daily Programming Thread

Old thread: What are you working on Sup Forums?

Other urls found in this thread:

hackage.haskell.org/package/data-flags-0.0.3.2/docs/Data-Flags.html
twitter.com/NSFWRedditVideo

First for JetBrains IDEs

way to wait for the bump limit

sage

Second for women coders ^_^

Working through SICP. After the first few sections on basic LISP I'm having a lot of fun.

kek

keep at it and ignore the memes user
it's a very good book

They're good.

In C, how do I prototype a function which returns function pointers with the prototype void (*function)(char *)?

Background: I have a dictionary with a bunch of function pointers in it. I want a function which will go through the dictionary and find the function pointer associated with the identifier provided. I figure it would look something like:


void (*function)(char *) return_function(const char *identifier){
//return the appropriate function pointer
}

I recently began getting into c++, and am now trying to write a simple program which converts all files ening in .webm in a folder to mp4 via ffmpeg, keeping their respective names. It's really just basic, as I've done one like this in other languages before, but I always think It's good practice

Rewriting the linux kernel in Coq

void(*)(char*)

(void(*)(char*)) (*) (const char*)

I read part of SICP during my 3 eight hour lifeguard training renewal courses instead of listening to the instructor. Great read to pass the time during a boring class

I want to make my own language. Have never done this before. Have the basic syntax laid out. It will be similar to LISP.

For writing the compiler I was going to just use C but I've heard OCaml can be better. Does anyone know why or if that is true? Any other good links for compiler writing?

i wrote a script that pulls emails from craigslists and adds them to a list. then another scripts checks if duplicates if no duplicates it sends an email to taht address.

only problem is i get -

550, b'Requested action not taken: mailbox unavailable\nFailure sending mail. Try again later


so i don't know if ti's the email provider i'm using or what. i can't make a fuckinggamil without a phone number.

How would I call the function? And without an identifier for the parameters, how would I refer to the identifier?

Can a developer from, say, France or Germany, get a job at facebook, twitter, etc in United States?

look up lex and yacc, and their newer equivalents, flex, and byacc or bison. These are all in C. Also, if you want to go with a more ground up approach, make sure to look up Dijkstra's Shunting-Yard algorithm for parsing as well as the system calls brk() and sbrk for managing a heap/stack in C when it comes time for that.

only if your name is Dinesh

Taking the time to learn Sepples properly. What a truly ugly language. Sometimes I wish they took the hint and stopped trying to make it "an almost superset" of C

are there haskell ide's?

>how would I call that function
like any other
in fact because it returns a function you can do it haskell style

f (something) (somethingElse)

>identifier for the parameters
doesn't matter when you're calling it

void (*return_function(const char *identifier))(char *) {
}


Tips for working this out:

- Start at the calling site, as if you were to invoke it directly:

return_function("lookup_ident")("arg_to_returned_function");

- Ok, so the returned functions argument must be at the very right:

something(char *)

- something is itself a function, taking some parameter (const char *):

something(const char *)(char *)

- And finally the return value, since it's a function pointer we need parenthesis around the entire something(arglist)

void (*something(const char *))(char *)

Welcome to C syntax.

>C 2016
>still no lambdas
am i doing it right

#define mkAdd(n) \
int addr ## n (int x) { return x + n ; };

mkAdd(0); mkAdd(1); mkAdd(2);
mkAdd(3); mkAdd(4); mkAdd(5);
mkAdd(6); mkAdd(7); mkAdd(8);

(int (*) (int)) add (int n) {
switch (n) {
case 0: return addr0; case 1: return addr0;
case 2: return addr0; case 3: return addr0;
case 4: return addr0; case 5: return addr0;
case 6: return addr0; case 7: return addr0;
case 8: return addr0;
}

can someone clarify the difference between . and $ in haskell for me? i'm a bit confused reading the wiki

whoops, should b e addr 1 through 8

Threadly reminder that you should not refer to the act of programming as coding. It is improper and makes you look like a 16 year old

You are a programmer, not a coder

Software Alchemist is GOAT
Developer is okay
Magician is okay
Software Magus is okay
Software Engineer is okay
Software Architect is okay
Computational Conjurer is okay
Information Systems Sorcerer is okay
Purveyor of Programs is okay
Code Guru is questionable

Archmage is reserved for only the most senior of programmers

Writing in HTML and CSS is not programming, therefore it should be referred to as designing

Except those make you look like a 14 year old.

Hi.
I was working on CIS 194 in order to learn Haskell.
I'm doing the homework of 2nd week and did a function for creating a sorted tree as
insert :: LogMessage -> MessageTree -> MessageTree
insert (Unknown _) tree = tree
insert m (Leaf) = Node (Leaf) m (Leaf)
insert (LogMessage k t m) (Node t1 (LogMessage kn tn mn) t2)
| t

> prescriptivism
This is not how language works, son.

Is there any beautiful feature to use instead of bitmasks as flags in haskell? using Data.Bits seems a bit pedestrian, one can mappend Monoids, but not check individual bits.

STFU
I'm a proud coder.

I want to learn programming.
There is a SICP for python, but it seems like I have problems getting through a chapter.
It takes long, so I wrote a py file with the methods and tried to access it from the python 's root folder.
It doesn't seem to work.
Please, what can I do in order to advance?
I would be very, VERY grateful for your assistance.

Spoken like a real koder kid

c++ isn't really made for string manipulation, that's what scripting languages were invented for. C and c++ are more for abstracting memory allocations and moving memory around and performing calculations on them.

For example, structs and pointers are all just ways to abstract memory. Need 8 bytes, ok UINT64 my8Bytes; or need to define a region that holds a float and int, ok struct {float f; int i} myStruct; Need an array, typedef that struct and make an array out of it, etc.

t. literal pajeet

Want me to roll my eyes ?

Can somebody fucking explain to me what lambdas are and where are they useful? I've gone through like 10 videos and a few articles and I still can't understand them.
Can someone explain them to a stupid person?

u see what u have to do...is instal java 6 JDk with ecklipse...an then u start the magic of coding...

i want you to learn to fuck off somewhere else with your broken english and come back when you can write a coherent paragraph

i need the best C guide

It's like when you need to perform some action and return a result but you don't want to write a function for it. Like I guess if you want to write a comparator like in std::sort. You can pass in a lambda that does like [](int a, int b){return a > b;}; and it will just use that function to return true if a is bigger than b, and you're not just writing a one time use function and passing in a function pointer. (the compiler is doing it for you!)

How do we escape Github?

K&R

gitlab

Don't make me poo on street.

>I've gone through like 10 videos
You'll never be a good coder. Give up now.

Imagine if you could write an inline function and define it with a function literal.
Then you could assign it to a variable and mix your code and data like some kind of computer scientist.

Anonymous functions: functions which you may use only once, where giving them a name (and hence memory space) is not useful.

You could do this
square n = n * n

map square [1, 2, 3, 4, 5]


But, if you aren't going to use a function again, use a lambda instead:
map (\n -> n * n) [1, 2, 3, 4, 5]


The parenthetical expression is a lambda in Haskell.

programmer*

why?
>inb4 "\Github"

for creating functions on the fly. for example, a mapping of a list applies a function to every member in the list. so you could do

mymap list = map f list
where f x = (x*2) + 1


or you could equally do

mymap list = map (\ x -> (x*2) + 1) list


lambdas can make more concise code when you're just using a throwaway function you don't intend to use anywhere else

programmer == coder == developer

pajeet detected

dont like the idea of relying on a service that can force you to change/remove your code because someone in the "community" feels offended by it

github is full of sjws

You can also use lambdas in GUI coding. Like say you want to wait to download data from a database but you don't want the gui to be unresponsive during that time. So you create a lambda that populates your table of items. Pass in the lambda into the getData function. This will allow the window to be drawn and the program to handle other input (like clicking other menu items) while your data downloads. When the download is done, it will populate the table using the lambda you passed in.

So i've been building up the basic parts of the haskell prelude in c#. This is, of course, impossible as c# lacks HKP. even still, you can get pretty far. you can even manage a bastard sort of Traversable that works for any given such functor; the problem is that the type-class only really works for that particular functor, since other functors want to use a slightly different Applicative.

Code monkeys like you can never offend a code guru like me. Go fix your bugs, filthy code monkey.

I made a web admin panel in C#.

It has the usual SQL, file management, sessions, e-mail communiques, SMS alerts, a page where check ins are updated/shown, another page where workers can make requests, preferences saved to cookies.

what else should i add?

Just because you write code doesnt mean that you are in any way a developer. You are just a stupid code monkey. A 'coder' is the guy who moves the bricks and mortar into place the developer writes the schematics and planning.

For a college assignment ,I need to detect bugs in C programs.

Can someone give me online repositories with C code so i can test the shit out of those programs?

thanks

Man, didn't knew it was happening something like that in github. After all, I only go there for my repos, not to make friends.

>C#
Stopped reading right there.

Github.

I don't think so, what's the type actually like?

does this help?
hackage.haskell.org/package/data-flags-0.0.3.2/docs/Data-Flags.html

You're cute user. Only complexed coders (ie. code monkeys) argue about the verbs to describe their activity.

You can call what I do programming, coding or developing. I do not care I do not have complex like you.

Code monkeys will always code monkey.

Code guru != coder

Please refer to the following shitpost

It's really whatever your corporate overlords decide to call you. In the end you're still writing code in an IDE. Whether you're a SDE, programmer, SE, etc you're still doing the same shit.

see

hasklel should be banned from this general

Yeah look up the code of conducts and the changing of words like "master and slave" to "leader and follower"

Thanks you. This is de type of the tree:
data MessageTree = Leaf
| Node MessageTree LogMessage MessageTree
deriving (Show, Eq)


and the LogMessage:
data MessageType = Info
| Warning
| Error Int
deriving (Show, Eq)

type TimeStamp = Int

data LogMessage = LogMessage MessageType TimeStamp String
| Unknown String
deriving (Show, Eq)

no shit sherlock

Fucking kek. This bullshit is why we're still a joke even though the world runs on the shit we build.

You could make LogMessages Ordered on t's. I don't know what you're doing with the Unknown nonsense but it feels like putting them in the tree insert function is the wrong place.

insert (Unknown _) tree = tree
insert m Leaf = Node Leaf m Leaf insert m (Node t1 mn t2)
| m

yes shit watson

I am simply stating objective fact. Not arguing

Enjoy your braindead job coderposter

>braindead job
It's OK I'm paid to do OCaml.

At the end of the day you are a corporate wageslave code monkey

Who is we?

Sure thing coder brainlet

>objective fact

I can't handle this level of shitposting.

>It's OK I'm paid to do OCaml.

pls describe what day looks like in your life as programmer

The task is to classify some logs, so there will be invalid entries. And while parsing them, I need to be sure they aren't introduced into the tree, so I need to check for `Unknown` types

>corporate wageslave
Joining the proletariat.

Shitpost in /dpt/ evidently

Communism doesn't work.

I'm paid to develop a C code generator for embedded in OCaml. I'm a code guru and was hire because of that.

Proud coder master race.

There is a spectre haunting the development industry

that's why murrica fear it right?

need a haskell magi to tell me what i'm doing wrong. ghci tells me
λ> :l rotateMatrix
[1 of 1] Compiling Main ( rotateMatrix.hs, interpreted )

rotateMatrix.hs:16:17:
Expecting one more argument to `Matrix'
In the type signature for `rotateMatrix':
rotateMatrix :: Matrix -> Matrix
Failed, modules loaded: none.
λ>

here's the file
import Data.Matrix

rotateMatrix :: Matrix -> Matrix

rotateMatrix m = fromLists (rotate (toLists m) 1)

rotate m c
| c

>""useful"" FP language
>its only use is generating code for an imperative language

Communism has never been implemented

You have been raised to think this. Rise up comrade.

rubbing shit in your eyes doesn't cure nearsightedness, and i think most americans would fear that belief gaining traction too

This was the expected reaction. thanks for the (You)!

It's feared because of the devastation it causes.

Matrix is a parametric type, like Vector in C++

what you want is this:

rotateMatrix :: Matrix a -> Matrix a

aka

rotateMatrix :: forall a. Matrix a -> Matrix a
rotateMatrix is a function, for any type "a", from a Matrix of "a" to a matrix of "a"

ah, i see. thanks

It is feared because it is an ideological enemy of the country you were raised in

shut
the
fuck
up
about
politics