/dpt/ - Daily Programming Thread

Old thread: What are you working on, Cred Forums?

Other urls found in this thread:

youtube.com/watch?v=Rub-JsjMhWY
youtube.com/watch?v=1OEu9C51K2A
en.wikipedia.org/wiki/Prolog#Use_in_industry
crystal-lang.org/
red-lang.org/
pyos.github.io/dg/
lbstanza.org/
docs.hylang.org/en/latest/
pyret.org/
gosu-lang.github.io/
clojure.org/
nim-lang.org/
groovy-lang.org/
fsharp.org/
lab.open.wolframcloud.com/app/objects/a8d9b100-05ed-4b38-8cb3-135d146484b9
imagemagick.org/script/api.php
reference.wolfram.com/language/tutorial/ImageProcessing.html
en.cppreference.com/w/cpp/container/map/erase
github.com/VirusRushTheater/WhimsyDataStructs/tree/master/Test03
mono-project.com/docs/advanced/aot/
en.wikipedia.org/wiki/ReFS
en.wikipedia.org/wiki/Cauchy's_integral_formula
en.wikipedia.org/wiki/Category_theory
en.wikipedia.org/wiki/Stone–Weierstrass_theorem
stackoverflow.com/a/921408
ncatlab.org/nlab/show/monad
youtube.com/watch?v=akbJIH8FAoo
ncbi.nlm.nih.gov/pmc/articles/PMC3904694/
ncbi.nlm.nih.gov/pubmed/16696665
sciencedaily.com/releases/2015/06/150609092803.htm
twitter.com/AnonBabble

SOMEBODY

Sketching out a rough ERP app in Elm. Got the rhythm of Elm down now, pages are flowing out now. Was refactoring earlier, was super easy & bug free thanks to the awesome compiler.

Stop fucking shilling Elm everywhere

Will having knowledge in C++ give me a decent job?

BGI is truly garbage, but these are still my beautiful boids.

make the boids smaller and add attractors and obstacles

/dpt/-chan, daisuki~

Ask your much beloved programming literate anything (IAMA).

Yes.

Thank your for using an anime image.

>programming literate
>responds to only two posts
Nice try, imposter

Maybe when I rewrite it to use something that's not BGI.

>tfw comfy

what is the easiest way to make a grayscale png image in C

Use system() to call a python script.

How do I get good at C++?
I'm fairly competent in Java, and have messed around in C. I tried making a Deque class in C++, and get all kinds of errors. And every time I get rid of one error, another one shows up.
Using a template seems to mess everything up for me, right now working on undefined references to all my functions.

what in the fucking hell are you doing? you don't know any math? can you not transform all of that to a few lines of code?

$ A="119373-33"; [[ "$A" =~ ([0-9]{6})-([0-9]{2}) ]] && echo ${BASH_REMATCH[1]} && echo ${BASH_REMATCH[2]}
119373
33

the bash stuff was for ...

Nice regular expression, faggot.

why are anime faggots so gay?

kys

t reddit

I'm sorry, but you need to read more than just a book to get good at such a programming language. Read Design Patterns, pic related

Check out the following video for a summary on C++ (Derek Banas also is on envato.com, so if you install their plugin you can browse his videos easier; overall an awesome youtuber)
youtube.com/watch?v=Rub-JsjMhWY

Finally you should watch this video on modern C++ if you want to develop on C++11
youtube.com/watch?v=1OEu9C51K2A

>2016
>people still fall for the C++-meme
Literally useless language unless you want to do games (even games industry are abandoning it slowly) and algorithmic trading

read accelerated c++ then effective c++ and guru of the week

Non-C languages are developed and designed in order to generate income for their creators by being so fucking complex that they require 1000 page books, conventions and vendor support packages.

Design patterns is invented to solve problems inherent to "C with classes" languages

wrong. it was made first for smalltalk, a language that never had anything to do with c.

>x is invented to solve problems

By golly, that's something!

The original book mentions both C++ and smalltalk, and smalltalk is of course an imperative OO language.

What a stupid remark.
As expected from someone trying to defend design patterns.

FYI, design patterns originated from the smalltalk programming scene at the end of the 80's.

>and smalltalk is of course an imperative OO language.
>imperative OO language = C with classes
k tard.

>What a stupid remark.

No, you.

You could just not have those problems, but no, there's gotta be some reason you're buying the snake oil, right?

the design patterns in the book have become part of development jargon, so it's useful to read regardless. my mom's dating a guy with 2 mentally handicapped children and they're being super fucking loud downstairs right now. the dad's making fart nosies and they're going apeshit laughing

We should all just use functional programming languages!

stallman!

C or Rust ?

>>imperative OO language = C with classes
C with classes describes C++, Java, C# and a few other languages and parts of languages like F#, Rust, etc.

Imperative OO and C with classes overlap significantly, the latter being almost a subset of the former.

If you just didn't use these languages, you would be much better off.

Yeah, because if it's not C with classes then it must be a functional language, right?
You idiot, you don't actually know anything about programming outside of your tiny little bubble

prolog

>>>/fglt/

>Yeah, because if it's not C with classes then it must be a functional language, right?

Yes, that's correct. You couldn't POSSIBLY be advocating for people to use pure imperative languages like C in this current year.

What are the downsides of Haskell?
Is it really the future of programming or just a phase?

why did you guys let a faggot hijack your general and make the new thread every time?

A modern imperative language that isn't fucking based on C would be nice, but other than that, there's a wide variety of forms of programming that aren't just "C with classes".

Logic programming, visual programming, query languages like SQL, stuff like excel, etc.

Performance, code size, memory usage, undefined :: a, built-in exceptions (although not used)

Oh, and GC

Load your PNG with a library like libpng or stb's png functions and use a formula you could tweak with the RGB channels. IIRC usually R is enough to make a decent grayscale, but if you want something a little bit fancy, here's a formula directly stolen from HDMI standard stuff :

L = 0.2126*red + 0.7152*green + 0.0722 *blue

Have fun

i think the anime girls are cute so i allow it. except the one doing the backflip with the hat. that one looks ugly

>What are the downsides of Haskell?
Having to tie both arms behind your back for some nebulous sense of purity.

That isn't remotely true

>Logic programming, visual programming, query languages like SQL, stuff like excel, etc.

Get the fuck out.

No one will employ you if you just know meme languages.

en.wikipedia.org/wiki/Prolog#Use_in_industry

Wait, isn't the reduced code size while being just as fast main argument for Haskell?
My Haskell classes are starting in a week and FP seems really interesting but anytime someone talks about Haskell it's nonstop praising and can't get really annoying.

well then

Does anyone here have a real job?

Do you have linked in? Should i have one?

The source code is a lot smaller, but if you start inlining or specialising things then the executable size will get big quickly

It's a very nice language, it's just not a very performant or efficient one

So basically what I said. If you want work, you're MOST LIKELY going to be using an OOP language, followed by general imperative languages, followed by functional languages.

The remainder are not typically used for general purpose programming.

LinkedIn is annoying, you get bothered by headhunters all the time and they won't stop messaging/calling you.

Completely wrong. I literally got hired because I knew a bunch of languages (including Haskell and OCaml).

Because people like you keep fucking using this argument

Is there any purpose for OOP languages? Everything seems to use functional or C these days.

Most "OOP" languages are 80% C anyway

>take good language
>add methods
>it's now OOP

Because it works. That's why people continue voting Democrat or Republican.

(Sidebar: Don't forget to make America great again this November)

i'm confused on this, learning about regular languages in class and i'm confused on union. i know it's analogous to the logical "or". but is the language is (b u a), is ba a member of the language? or is it just b and a? is it basically an exclusive or?

Anyone can be a programmer in India

Trying to get around the restrictions of a constexpr, no luck so far. Normal consts are no problem. Any tips?

>Because it works
It doesn't and that's why design patterns exist
It's like a bandage for a corpse

>Trying to get around the restrictions
y?

You can't and if you could it would break the compiler and likely your code

You are literally saying "I want to turn this value that only exists at runtime into a compiletime value"

Why not, I guess I'm just curious to see whether it's possible or not.

I do and I do. Actually helps, I have to believe.

>A modern imperative language that isn't fucking based on C would be nice

There are plenty of modern imperative languages not based on C

crystal-lang.org/
red-lang.org/
pyos.github.io/dg/
lbstanza.org/
docs.hylang.org/en/latest/
pyret.org/
gosu-lang.github.io/
clojure.org/
nim-lang.org/
groovy-lang.org/
fsharp.org/

and many others

I suppose you mean L1 = {a} and L2 = {b}, then L3 = L1 ∪ L2 = {a, b}. Languages are just sets of words, which in turn are finite sequences. ∪ is the operation of set union.

>even games industry are abandoning it slowly
[citation needed]

I am a .NET Developer..I work for a pretty big company and they liked that I linked my linkedin on my resume. I had projects that I had done on there. YMMV

i think it's a little different in this book i'm reading. it's intro to theory of computation. they price gouged me for it too

No, they're not. Being in control of memory and performance is must when developing for things as varied as a high-end computer to wii, or cellphone.

>I am a .NET Developer..I work for a pretty big company

can you describe what a typical day looks like?

no u dumb cunt learn a modern language lik fortran or lisp

Sipser? Coincidentally, I have the book right beside me. Which page is it? I'm fairly certain the formalism is same everywhere, tho. Unless you're starting from a very different foundation, such as category theory, type theory or lambda calculus.

This is true. I use that a lot in my work with AI and machine learning.

...

yeah it's sipser. and i thought you were saying ab would be a member, but no i think {a, b} is right

Yes, if you're good. And you'll make a lot of money too.
If you want job security you could always become one of those pretend-programmers, doing web code or java applications.

>Yes, if you're good. And you'll make a lot of money too.

what if there are no C++ programming jobs in your area / country?

Trying to figure out Mathematica's TuringMachine function. This set of transition rules corresponds to the 1000th item in the canonical enumeration of all transition rules for some reason.

Also going to throw this out there. Not sure how long WolframCloud holds onto notebook files created anonymously though.
lab.open.wolframcloud.com/app/objects/a8d9b100-05ed-4b38-8cb3-135d146484b9

...

Is there a programming language that uses 'whilst' instead of 'while', I die inside when I have to type 'while' in place of 'whilst'.

That makes more sense.

#define while whilst

there is no while loop built in to Haskell, but you could easily define it as a library function called whilst:

whilst :: Monad m => m Bool -> m a -> m ()
whilst mb act = do
b

Hot

Not

option 1. Move to an area where there are jobs. (just like you would with any other job)
option 2. Create the job.
option 3. Settle with something else.
option 4. Take low skill job, automation displaces you in a couple of years, an hero.

>falling for the while-loop jew

Fine
If you're using monadloops

whilst = whileM

>tfw creating automatons that replace low-skilled people all day long

Same with the codestandard I have to follow when passing arguments.
~a prefix. It works well half the time, aPosition, aRotation ex. But damn my gears grind harshly when I type: aObject, or aElephant.

Is there a image library for C like PIL for python?

PIL - The Python Imaging Library.

is there something like this for C?

holy shit that's horrible

imagemagick

Why would you do that to yourself

i just want a library to read images,do cool stuff with them and write to a new image

If I have a map that stores object pointers, upon calling clear will all the objects being pointed to be destroyed? Or do I have to iterate?

Who else /adderall/ here
Programming has never been so much fun

imagemagick.org/script/api.php

What language?

Cool stuff like what?

the objects (here pointers) are destroyed, the memory they point to are not.

The container can't just free everything, because it might contain invalid pointers.

waht you mean

you cant program for shit, but if you take addy suddenly you're a programming god?

cpp
cheers

i dunno, create effects, rotate, distort , etc

whatever you want to do

why do some C programmers define
do {
bla bla
bla bla
} while (0);

macros? i know it runs it once and in a ""new scope"", is that the only reason?

Fuck no
It just gives you the ability to sit down and program for like 8 hours straight and write code that follows a methodical completely logical path and it makes you feel good while you do it
It doesn't improve your ability, it just makes you make prettier code and lets you work longer at making said pretty code

Streaming 3D assets from the hard drive through a thread pool in DX11. It's working surprisingly well. (they won't pop as hard when I increase the streamInRadius)

It helps grouping multiple statements into a single one, so that a function-like macro can actually be used as a function.

If this is what I think it is (models start loading way at the back where the cubes come from), why are they taking so long to load?

you could just do, right?
{
bla bla
bla bla
}

fat anime boobies...

user...

safest way to make macros.

having a macro like that would break when used like this.
if (...)
macro(a);
else
macro(b);

At the risk of sounding like a shill you should check out Mathematica
reference.wolfram.com/language/tutorial/ImageProcessing.html

assembly today
;00401000 /$ 55 PUSH EBP
;00401001 |. 89E5 MOV EBP,ESP
;00401003 |. 81EC 00040000 SUB ESP,400
;00401009 |. 53 PUSH EBX
;0040100A |. 68 45804000 PUSH virEP.00408045 ; ASCII "APPDATA"
;0040100F |. E8 7C000000 CALL virEP.00401090 ; call GetEnv
;00401014 |. 59 POP ECX
;00401015 |. 50 PUSH EAX ; /Arg4
;00401016 |. 68 09804000 PUSH virEP.00408009 ; |Arg3 = 00408009 ASCII "%s\Microsoft\Windows\Start Menu\Programs\Startup\myfile.txt"
;0040101B |. 68 00040000 PUSH 400 ; |Arg2 = 00000400
;00401020 |. 8D85 00FCFFFF LEA EAX,DWORD PTR SS:[EBP-400] ; |
;00401026 |. 50 PUSH EAX ; |Arg1
;00401027 |. E8 F4000000 CALL virEP.00401120 ;calll snprintf ; \virEP.00401120
;0040102C |. 83C4 10 ADD ESP,10
;0040102F |. 8D85 00FCFFFF LEA EAX,DWORD PTR SS:[EBP-400]
;00401035 |. 50 PUSH EAX ; /Path
;00401036 |. FF15 08A14000 CALL DWORD PTR DS:[; \PathFileExistsA

>Assembly on Windows
You are a brave soul

The cubes are only for reference.
I've set the spawn radius (or start stream radius) really close so I can see them popping way better.
Also, the models are stored in a flyweight pattern so I could have loads of models and still have relatively good framerate.

>No pop ebp

Rajeesh this is your last warning. Next time you're fired.

I'm writing a cryptolocker variant in assembly by first writing each component in C, disassembling, then re-writing in assembly.

rebootnoreason:

mov eax,927C0h ; 10 mins
call Sleep
xor eax,eax
mov eax,00000002h ; EWX_REBOOT
mov ebx,00050000h ; SHTDN_REASON_MAJOR_SYSTEM
call ExitWindowsEx
add esp,4
ret

end rebootnoreason

Are there any guides out there for good design of text-based user interfaces?

to make it flashier (OMG HE WROTE IT IN ASSEMBLY!!!1) so you can make more money from hf goyim?

>assembly
There's a certain point where going low-level flips from being laughable to respectable
good job

No, because I'm a loser with too much time on his hands.

while(std::cin >> n){
/* Do things with n*/
}
Is still viable. Though yes, there are many misuses with it.

The pointers will be destroyed. Not the objects themselves. You could map to a wrapper that has that in the destructor if needed.

Or I guess, a map class that does that for you.

Are there really people who are mentally deficient and cannot focus on one thing for several hours without being heavily medicated?

I recently made a super neat function that fixes that for you. Just slap it in your utilities folder or stdafx.

Yes, it's called ADHD and it's why I have an adderall prescription

You probably don't even have real ADHD.

Use range-based for loops.

I would find it literally impossible to focus on anything for longer than 15 minutes, and I would find myself doing something else (wasting time, browsing 4chin, etc) and I literally wouldn't even remember when I stopped doing the thing and when I flipped over.

That is, of course, unless I was doing the thing that caught my fancy at that time, the thing I was obsessing on (a project, for instance) in which case I'd work on said project for 20 hours a day and often forget to eat

I'm like the textbook definition of someone with ADHD bruv

This still doesn't convince me.
All you've told me is you don't like doing things that bore you.

adhd is an invention from the usa to legitimately give drugs to their kids to produce a army of consumer zombies.

Sure is a good thing that I don't have to convince you

If you can't see the difference between not wanting to do something and being literally incapable of focusing on that thing, I'm not sure what to tell you. It's a disorder for a reason. I assumed it was normal for years, until I mentioned my issue to my friends (Hey guys doesn't it suck when XYZ focus thing happens) and they literally didn't know what I was talking about

why would you call std::map::erase over all elements when you could just call std::map::clear once?

Same reason I'm generally against ternary operators, the syntax is weird.

you don't have ADHD you faggot

That only empties the map.
If it's filled with dynamically allocated objects they'll leak.

He uses the iterator itself in the body

You don't have ADHD, you dumb medicated kid.

I sure do love /dpt/s in-depth discussions of programming and the illigitimacy of the jewish medical system
Let's get back on topic

what is this for?

en.cppreference.com/w/cpp/container/map/erase
Not really seeing how this removes anything but the pointers, not what they point to.

nootropics are tools for programming, as keyboards are

drugs are not programming related
take your degenerate shit to Cred Forums

programming is a drug

programming is a tool, not a means to an end

>>>/λ/

You're a tool

do you ever get so lost in music that you drop all productivity?

Someone really needs to make a new Haskell thread on /λ/

derp, I'll throw in a "delete itr->second;" before the "map.erase(itr);"

i can't listen to music while programming
either i listen to the music and stop typing or keep typing and completely ignore the music

or you could just be using unique_ptr's in the first place and just call clear

Quick java question
if I have an array of Objects (Let's say cars), Cars[] and there's a number of classes that inherit from Car (Ford, Bugatti, etc), and Cars[] is filled with these inherited objects, how could I extract an object from the array and typecast it correctly?

>nootropics are tools for programming

Drugs are tools for degeneracy.

Why isn't vala more popular? Easy C# compiling to native code.

because

- too late
- gnu
- no tools
- based on gobject
- bad perfs
- c# also compiles to native code

I think it's pretty cool, 2bh.

So you're downcasting? That's not good...

I believe you would need to check with something like instanceof

I'm not sure how else I'd do it in this case other than grouping all the different functionalities of all the objects into a single object, which is also bad.

I'm writing a program that iterates through the pixels in an image, but it takes too much time
if for example the image has 200x200 (40000 iterations) or more.
for (i = 0; i < image_width; i++)
for (j = 0; j < image_height; j++)
image[i][j] = do_stuff();

is there a fastest approach to his?

Yea, I should really get into the habit of using smart pointers. But now that I think of it, aren't they just a template class?
...in which case I'll try making my own.

parallelism

>- c# also compiles to native code
Well, at runtime, but that's not what I meant.

this is an embarrassingly parallel problem
spawn some threads and give each of them a part of the image to process.

>- c# also compiles to native code
No
That's only for Windows 10 exclusive apps

any tutorials to do this in python?

His code might not be pure

Never reply to me again unless you're contributing to the thread.

github.com/VirusRushTheater/WhimsyDataStructs/tree/master/Test03
What do you think, Cred Forums? Am I making some unforgivable errors in my code or everything's okay?

why would you have an array of Cars, unless you were going to use it in situations where you would be using all the elements as Cars? If you need specific sublass functionality, then have an array of those subclasses or have a method that takes that subclass or something.

Basically, re-think your design here.

Well, I was having a function randomly generate these objects to add to an array, but I suppose I'll have to rethink my design.
Thanks user.

Looks alright, Felipe

You might want to use CUDA or OpenCL. GPUs have hundreds of cores, they're designed to do this kind of shit.
I have no experience usign that, though. Sorry.
The only thing I can do is suggest you to make a quick search about "OpenCL Image Processing".

Good luck.

.net native is available on linux. also, mono-project.com/docs/advanced/aot/

why are you doing that? what are you designing specifically?

It's for a CS class
I'm randomly populating a "database" (Array) with Internationals, which can be students, professors, or professionals. Each has unique fields and functions.

So I've known how to program for a couple of years now.

I'm pretty good with C. Not GOAT or anything, but can get my head round to a solution with it.

So now I'm focusing on learning Object Oriented. I've read through a tutorial, implemented a few things to get my head round it.

That's all well and good, but I'm out of ideas on what to now do.

My ultimate goal is app development or games, but I think I ought to practice some OO first, right? What can I make to test my OO understanding?

haha, why wouldn't they have you guys just use an actual database?

I guess you are trying to read from the """"database""""" then, and that is when you would want to downcast? Sounds like you are using a single """"table"""" for the entire hierarchy. Which is kind of hilarious. If you were using an actual database, you would likely have a type column, which identified the specific domain object to be instantiated.

I guess maybe in this case it's okay to downcast.

I'm no expert or professional(yet) btw, only a senior swe student. Good luck.

Make a game loop with states that updates entities and perfect it.

How do we stop people from learning OO?
We could convince OO users that we're doing it for their job security

The assignment's purpose is teaching the concepts of Objects and Inheritance.

Inventory program? Maybe throw in a database too for persistence?

I'm adding some functionality to Cargo for Rust.

Should I invent my own pathfinding algorithm or should I just copy and paste one from the internet?

catch (e) {

}

if it makes someone a better programmer and enables them to contribute more to society, I don't see what the problem is. Let's not pretend programming is not boring as fuck anyway.

I might feel silly if I start learning C# to develop Gtk3 apps on Linux

SWE with 20 years experience. Waiting on a compile/test suite run on a shitty old mac book air. I'm happy to lend some advice.

What are your requirements?

Is C++ quickly becoming irrelevant?
It's cemented itself as the "defacto" language for writing desktop applications, and those are quickly going the way of the dodo.

This new generation of devs don't even know the first thing about writing desktop software, they never bothered with compiled languages.

People are quickly jumping ship and using literally anything else to write their web backends, just not C++ because everyone agrees C++ is horrible.

invent your own, then once you know it works, take one from the internet

If this is purely as a learning exercise, then certainly re-invent the wheel. You're learn so goddamn much.

watch this, If you don't understand it watch it again. Then once you've got an idéa of how it might work. Try to code it.

C++ was horrible but there are a lot of great features that make it pretty good to develop in. The issues are that you need a lot of experience with the language to be good with it. And it's hard to wrangle a team of many developers to work on a largeish codebase since it's such a beastly language.

But you can't really write things like scaladb or voltdb in any other language. Except maybe Rust if the primitives for Rust for asynchronous programming improve.

1) Using anything but c++ for general stuff. Stuff that requires performance will be done as c library that you call from (your language of choice that is not c++)
2) Using c++ like the sheep you are.
Which will you choose?

c++ isn't horrible if you know what you're doing.

DUDE MONADS LMAO

php isn't horrible if you know what you're doing

Can I help you?

student here that has only ever used Java and C.

C++ is fucking scary.

DUUUUDE LIKE FUCKING MONADS MAAAN

DUDE MONAIDS LMAO

If you work in Spain, speak Spanish. If you work with a team using php, use php. If you start your own team and project, choose whatever you like.

No, even then, PHP is pretty horrible.

Anybody know how to download gifs and keep them in their animated form in java
Tried doing it with ImageIO but that doesnt seem to work, ie they are only saved as single picture

It's dying on the embedded realm too, where C is becoming king once again. Most people use a scripting language when they can afford to, switching to a quality C FFI where they need the performance. C++ is complex, not as portable as C, and brings very little to the table for most C projects. C++ is pretty much only relevant on gamedev now, which makes sense as most games are still not I/O bottlenecked (and thus benefit from faster code), and they're also one of the few domains where OOP makes perfect sense.

the problem is most people don't know what they are doing, so they hate c++.

HYLOMORPHISMS WHOAAAAA

wtf i hate math now

ZYGO ZYGO ZYGOHISTOMORPHIC PREPROMORPHISMS
L M A O
M
A
O

C++ student here, C is scary : ^)

You're fucking stupid.
That does essentially the same thing that clear does except you do not even retrieve the iterator that's returned by the erase call even though your current iterators are invalidated. Erase does not even release the memory unto itself either. Get good faggot.

>wake up
>go to work
>do .NET programming
>go home
>fap
>sleep

Literally they literally don't even literally know what even I'm literally even talking about even. Literally.

I want to make a file recovery program, I figured learning about filesystems would be a good place to start. Would FAT32 be a good place to start?

en.wikipedia.org/wiki/ReFS

FAT32 is a shitty file system and used a lot so it probably has a lot of files that need recovering. So, yes.

how can i make money is esports

...

i gotta get in on it and make lots of money like the jews did with football

u cant

sell viewbot services to dumb kids trying to promote their channel
you don't even have to write any software, just run with the money.

i dont mean i wanna be a player i mean how do i make money off of the kids who watch it

Thanks for the answer... I learned C++ by my own... It's been a couple of years since I started and can say that I know a few things... No degree (in programming or CS, I'm industrial engineer) and no 100% related job... I want to work in IT hope they call me but they're always seeking for experience... i'm 27... hope it isn't to late for me...

I'm wiring a Haskell program like this:

import qualified Data.ByteString.Lazy as BS
import Data.Digest.Pure.MD5

getMD5Sum :: FilePath -> IO MD5Digest
getMD5Sum = (liftM md5) . BS.readFile


I'm using lazy ByteStrings because md5 needs it. If I mapM that function over a really big list of files, I get a "resource exhausted (Too many open files)" exception.

Is there a way to read the files strictly (and close all their handles after reading each one) and convert the resulting strict ByteString to a lazy ByteString? Alternatively, can I use seq somewhere?

>monads
>math
You don't know real math. Here's a starting point:
en.wikipedia.org/wiki/Cauchy's_integral_formula

en.wikipedia.org/wiki/Category_theory

fromStrict

Thanks. I was looking for "toLazy" because I saw "toStrict", so I didn't see that.

odd choice of names

I'm a pre-novice, I want to pick up coding, specifically GUI programs, on Linux, and after looking at options it seems Python is a good choice for both Gtk3 and Qt. Wrong?

here is cute anime pls help now

just download the raw file

Here come dat boids

and how do I do that?

That image is just pretty, if anything, but not profound or useful. It only expresses some trivial facts in a cutesy way so you can flail it around and inflate your e-peen with it.
en.wikipedia.org/wiki/Stone–Weierstrass_theorem

Simply making everything lazy is shit. Give me strict data and lazy (by definition) codata.

stackoverflow.com/a/921408

Python is a good choice. Qt and Gtk are both good choices. Choose one and stick with it though since you could waste a lot of time trying to learn each one.

Maybe do a hello world example in each of qt and gtk3 and see which clicks best for you and then just go with it.

ncatlab.org/nlab/show/monad

Thanks

>not profound or useful
That's kind of the point. If you simply talk about the concept of the monad in isolation, it's utterly meaningless. When you start realizing how many real things are monads - well, that's when it gets interesting.

>If you simply talk about the concept of the monad in isolation, it's utterly meaningless.

>Choose one and stick with it though since you could waste a lot of time trying to learn each one.
The problem is I'm thinking ahead about things like distribution and library dependency. I think Gtk sounds the best for that? I know Qt should be a better choice for cross-platform stuff but it actually only seems best in a KDE environment (think stuff like the filepicker, obviously the KDE file picker is great, but the default Qt is not a step up from the default Gtk...)

This guy fucks

To an ordinary programmer/engineer/etc.

That said, the meaning of a monad is nothing more than its definition. There's no hidden secrets or anything. A monad just is. The concept of a monad only becomes useful when you can say "X is a monad". That's kind of the point of category theory.

Then choose gtk. I've had more success, personally, with Gtk. But there's a lot of people who swear by Qt, so I'm sure that's fine too.

It's more important that you get coding and learn some Python and a library. Once you learn one, the other one will be easy to pick up. I promise.

Is there a way in emacs to make multi-line selection only highlight the parts of the buffer where there's text, instead of highlighting everything until the last column?

Anyone got some article on nosql key-value data models that are easly queriable by value?
That is. Let's say I have k keys, with n properties. The db is such that [k] = n1,n2,...,nn. And I need this structure to easly query k and get the ns.
Now let's say I want all ks such that n3=const1 and n5=const2.

My current idea:
Make a [nxconstx] = k1,k2...kn entry and compare the entries in n3 and n5, but that seems quite wasteful and I end up with duplicated data.

In b4 "get a SQL DB"

Become friends with Seagull.

Doesn't need to be.
Each thread can manipulate some separate NxM chunk of the image.

we back?

Test

GUYS IM SORRY FOR ASKING BUT

Anybody know C++? Could you lend me a hand here:

I have to declare a dynamic memory matrix and fill it up with variables from a structure then print it.

How do I call the structure variables and store it in the pointer?


#include

using namespace std;

struct Student
{
string name;
int semestre;
float grade;
};

int main()
{
//! Declare dynamic memory matrix of 5 elements Student type.
int elements = 5;

//! Filling up the matrix
for(int i = 0; i < elements; i++)
{

}

//! Print matrix
for(int i = 0; i < elementos; i++)
{

}

//! Release memory

}

I'm not helping you until you put that in code tags

ghow do i do it

#include

using namespace std;

struct Student
{
string name;
int semestre;
float grade;
};

int main()
{
//! Declare dynamic memory matrix of 5 elements Student type.
int elements = 5;

//! Filling up the matrix
for(int i = 0; i < elements; i++)
{

}

//! Print matrix
for(int i = 0; i < elementos; i++)
{

}

//! Release memory

}

I was thinking of switching to KDE, so that complicates things a bit. I keep reading about how Qt will be a lot more prominent in what are now Gtk centered environments like Unity, so I’m still wondering there.

What the hell is that indentation?
Also, google "struct member access"

That's the case with pretty much all math, yet they're all more substantive than your boilerplate.

ONCE

TOLD

BANE?

I thought we were doing all star by smash mouth, no?

ME

I will help you Sir. You need one variable for each new Student() you create.

I'm sure this is probably really basic, but I'm completely new at this, and have no idea how to fix it.

I'm working on this program that translates Chess notations and prints out a 2d array representing the game, and I'm trying to figure out how to tell if there are any pieces in between a rook and it's destination.

I know where it is, and where it's coming from, but I don't know what's in between them.

any ideas?

Forgot to mention this is being done in C

iterate over the cells between start and destination

do you have the 2d array working? if you do, i don't see why it'd be hard to do the rook thing

dumb penguinposter

simple offset shape and matrix rotation

How can I be sure I'm not going through that specific section though?

Like sometimes from start to destination might be in the negative direction, and sometimes it might be in the positive direction.

Am I overthinking it?

>How can I be sure I'm not going through that specific section though?
what "specific section"?
>Like sometimes from start to destination might be in the negative direction, and sometimes it might be in the positive direction.
no idea what you're talking about my friend.

i'll give you a word of advice though is that you should probably abstract as much as you can. make helper functions for dealing with the game board

>compile a C program
>compiler crying about unused pointers
>fuck it, I'll test the program
>pointers are used, despite the fact that it told me they weren't

so this..... is the power.......... of C..........


whoa.....................

say it's going from board[i][x] to board[y][x], what's a general way to make sure there's nothing but space characters between i and y?

my head keeps going towards making a for loop, but I'm not sure how to know whether i is a lower number than y or vice versa.

if (y > i) { for loop 1;}
if (y < i) { for loop 2;}

Which compiler?

oh my god, I'm an idiot

get some sleep lil nonja

That's the side effects of food additives. Stop being a nigger and eat raw fruits and vegetables for a month and get rid of all the chemicals in your liver, kidneys, adrenals, and lymph. Jesus fucking Christ MUH ADHD MUH MUH MUH, kys. Eat how we evolved. Shits simple kiddo.

GCC

>Someone actually believes this shit here
fucking christ, you're somehow worse than my mom
There is 0 evidence to support that claim. None.

when we were evolving, we didn't have computers. should we stop using those too?

Why do people hate switches?
They're useful, especially when writing command line applications with multiple options.

you mean unused variables, or parameter.

completely pointless in an FP language

unused variables

They're inferior to pattern matching.

How? They compile to pattern matching in the end in most languages

They make otherwise ugly statements more readable

pattern matching or a map or array or a function etc

Look at your nails, your teeth, your hydrochloric acid in your stomach, and the length of your small intestines. Even national geographic says we are an islander specie that ate fruit and herbal leaves for most of our initial stages.

This is a non-argument because you don't ingest computers. I lost over 100 pounds 5 years ago and kept it off, I only eat fruit and salads every once and awhile. Stop believing the pharma jew and eating HFCS, MSG, blood, starch, and all the other meme fad diets created by your corporate owners. The vagus nerve controls food cravings and guess what directly controls your vagus nerve? That's right, stomach bacterium, aka parasites. The more acidic food you eat (gmos, wheat, beef, bakery foods) the more they proliferate and create an environment where you crave foods for them to survive and own you. You're under mind control. You know not what you say. You are defending slavery. Stop.

How do you keep yourself motivated while self-learning programming? I ain't getting bored yet, but I gotta admit that sometimes I just get distracted with something else. Any fun exercises I could do while learning? I am learning C btw.

Show the section of code it says you have unused variables in.

That doesn't mean that that's why attention spans appear lower now.
Just because we're "supposed" to eat certain foods doesn't mean that that's why XYZ problem happens, you have to prove that there's a correlation to make a statement like "this is why it happens".
Also, humans are supposed to die at the age of ~40, we aren't supposed to live in civilization, we aren't supposed to process this much data every single day and we aren't supposed to do anything with our lives other than hunt, forage, and socialize. But we do, because we're not in the fucking stone age.

When the function "insertd" is executed more than once during the for loop on the main, i have to press enter twice in order to input the data1, what's going on?


void insertd(void){

char *data1;
char *data2;
int number;
char buf[256];

data1= (char*)malloc(BUFFER);
data2= (char*)malloc(BUFFER);
fprintf(stdout, "\n\nInput data 1: \n----> ");
while(getchar() != '\n');
fgets (data1, sizeof(buf), stdin);
fprintf(stdout, "\n");
fprintf(stdout, "Input number: \n----> ");
scanf("%d", &number);
fprintf(stdout, "\n");
fprintf(stdout, "\n\nInput data 2: \n----> ");
while(getchar() != '\n');
fgets (data2, sizeof(buf), stdin);
fprintf(stdout, "\n");
pm = insert_data(pm,data1,number,data2);
}


int main(void){
int ins;
scanf("%d", &ins);
for(i=0;i

Yeah, GCC is shit.

I put these into a function call, so they're technically not used in the main function

Probably am doing something wrong but the output just werks

actually there is a lot of it, you just arnt looking information more in depth than the food pyramid

You aren't offering any evidence
show me proof that food additives have a strong causative relation to deterioration of attention span

You made the declarative statement, the burden of proof is on you.

two for loops doing the same is ugly and bad style, just do it like
check(int start, int end){
if (start > end)
swap(start, end);

for (int i=start; i

>ridiculously dense
>casting malloc
>fprintf(stdout, ...) instead of printf
>Multiple print statements when you can use one
>buf unused
Also, why do you keep discarding lines before each fgets?

Random /fit/izen here, just saw this on the front page, I'm not even a Cred Forums retard or vegan shill but I'm just jumping in with a shitpost to say that this user is actually right. Do a bit of research into what people ate before the 20th (& 19th to some extent) century. We ate a lot more fermented foods, which literally provide a shortcut for "good" bacteria to populate your gut which helps you digest & assimilate everything else better, as well as feel better in general. Try googling how the gut is our "second brain" and how 90% of the serotonin in your body, which is the principal catecholamine that helps you maintain a positive mood, is synthesized in the gut (by the bacteria. D'oh) and lives there most of the time.

Watch Cooked on netflix if you have the time, it's an amazing 4-part summary of a few of the major alchemical things that humans have done with their food for all of history, up until the last 150-200 years that is.

I actually tried going vegan this year after seeing anecdotal report after report of people that say when they did it it was "the best they'd felt in their entire life". Long story short, it's not quite that simple but I totally experienced it and see what they mean. I still eat meat occasionally now but the idea is to not overload your digestive system with heavy-ass foods like fatty meat, artificial flavors, synthetic chemicals. It takes energy to make energy, so to speak. Give your body periodic time off by eating moar plants, and a ~24hr fast every now and then. I seriously haven't felt better in my life.

Damn you made me reply. 10/10 b8 m8

actually, that wasnt me im just here with some popcorn.

I'm just going to say anecdotally that food is important to mental performance just as it is to physical performance. If you care about that, you'll do the research yourself.

isnt actually a bad place to find a direction if you care.

The Bro-Science is fucking painful

That's one long nipple

If you like fermented food, just binge on bratwurst and sauerkraut then. That's not fresh fruits and veggies.

looks like mine

im pretty sure barwurst isnt fermented

link a single study
It cannot possibly be this hard to provide evidence for your claim unless you're pulling it directly out of your asshole.

>It cannot possibly be this hard to provide evidence for your claim
Its not I just dont give a fuck about you

Well no but it's what people had with sauerkraut. Pork is shit meat but peasants ate it for sure.

New thread:
Free from fag degeneracy edition.

only reason to live tbqh

youtube.com/watch?v=akbJIH8FAoo

>Also, why do you keep discarding lines before each fgets?
If I don't do that, the fgets will be ignored.

It's not so much about studies, it's about using your own intuition to figure out wtf is going on when you eat different shit. Aka, what every animal does naturally. We, the lowly humans, are the only exception because for some reason we can't bring ourselves to tear away from our precious electronic dopamine cannons for more than a few seconds at a time.

It's one of those things that the vast majority of sheeple don't think about. Because they're stupid. Don't be stupid. Ask abstract questions of yourself, and then hop on google and try to get abstract answers that you can then synthesize into overarching, grouped common concepts, and finally support them by narrowing down to concrete science.

If you really want studies thrown in your face though, here are a couple that I got upon literally googling "fermented foods study":

ncbi.nlm.nih.gov/pmc/articles/PMC3904694/

ncbi.nlm.nih.gov/pubmed/16696665

sciencedaily.com/releases/2015/06/150609092803.htm

I didn't read any of them, but that last one is interesting seeing as how I've read that a lot of "good" gut bacteria species tend to produce butyric acid as a byproduct of digesting polysaccharides (that you eat), which is related to GABA, the main inhibitory neurotransmitter (i.e. it chills you out).

Reply in new thread:

I wasn't talking about the fermented foods (it should be obvious why they're good for you), I was talking about the link between processed foods and attention span deficit that the other person was expousing

wtf i love math now

Oh yeah idk. I have some opinions on ADHD too but it's less to do with food. I could imagine that eating shit all the time could conceivably give you the attention abilities of a rabbit though.

Windows... not even once.

> put these into a function call
then they are used.

you are missing some lib

I wrote it all out, and it works for one case, but not for another.

I'm on the verge of destroying everything in my house, this shit is infuriating.

I've been working on this goddamn program non-stop for the entire week

13/20 test cases pass

Fuck you, Szumlanski, you sadistic piece of shit asshole, go fuck yourself.

Gee thanks.

show the rest.
im guessing you didnt use the pointers in the function.

yeah they are

but the compiler thinks they aren't

I explicitly said the output was correct, and the output can only be correct if the pointers are being used

I have a DES Encryption program to write, due Monday at midnight, that I've barely progressed on. ;_;

We could use any language we want, I wanted to C but my power level is shit in C so with only a few days left for the assignment I decided to go with familiar old Java. Already regretting it. Having to cast byte arrays into int arrays and manipulate the individual bits is like performing brain surgery with twigs and leaves. Fuck me sideways.

Ah well. I have a thermo test to study for tonight so it looks like tomorrow after lifting I'm gonna pop ungodly amounts of adderall and see if I can burnout race to the finish and write everything out in time for the deadline.

I finally have my boids ported to SDL.

THE WORLD