/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

wxc.sourceforge.net/
youtube.com/channel/UCcrSMnEYhIPX_p127jI23qw
en.wikipedia.org/wiki/Total_functional_programming
dlang.org/phobos/std_algorithm_comparison.html#.predSwitch
github.com/davidfstr/idris-insertion-sort/blob/master/InsertionSort.idr
gist.github.com/timjb/9043255
rosettacode.org/wiki/Proof#Idris
twitter.com/SFWRedditGifs

OpenGL Game/Game Engine in C

...

How do I integrate a wxwidgets GUI into my c program?
Wxwidgets is a c++ library

This is actually true.
t. idris-fag

...

wxc.sourceforge.net/

`template` and `void *` should be switched tho.

No.

>girls can't progr-

I'm writing content for a basic introduction to Idris series on youtube

youtube.com/channel/UCcrSMnEYhIPX_p127jI23qw

Also just sitting in a coffee and doing some Python scripting for fun. Here's something for replacing strings:

import os

DEFAULT_SPEC = dict(dir_path=os.path.dirname(__file__)
, extension='.py'
, replace=True
, keys=[("in001", "out001")
, ("in002", "out002")
]
)

# Test zone:
# in001
# in002

def replace_content(spec=DEFAULT_SPEC):
"""
In spec['dir_path'] and its sub-folders,
in files with extension spec['extension'],
replace strings according to the list spec['keys']
If spec['replace']==False, merely search and don't replace
"""
for root, dirs, files in os.walk(spec['dir_path']):
print("\n..." + root[-25:])
os.chdir(root)
for filename in files:
if filename.endswith(spec['extension']):
for old, new in spec['keys']:
with open(filename) as infile:
content = infile.read()
if old in content:
print(4*" " + "* " + filename)
msg = 8*" " + '"{old}"'
if spec['replace']:
with open(filename, 'w') as outfile:
outfile.write(content.replace(old, new))
msg = msg + ' ---> "{new}"'
print(msg.format(**locals()))


if __name__ == "__main__":
replace_content()

I'm thinking if I should write a minimal qt guy with input/browse fields and a button that can run scripts like that. Any takers?

PS: I'm running Python 2.7 on this laptop, did I miss anything that doesn't convert to Python 3 in the above script.

What the fuck is that thing??

So the men kicked all the women out of tech now the men want to BE the women. Fucking $currentYear

Is the core of Haskell total?

Studying monads currently and was wondering if I got it right, that is, that the purpose of monads is to provide an extra layer for partial functions, so that the core of the language may be total and extra static analysis may be performed?

Tried Googling but couldn't find anything, please respond

I wish I were a cute loli with cute nails

...

Dress up like a cute loli then cut off your penis so you bleed out and die. You're 110% guaranteed to be reincarnated as a cute girl in the anime of your choice.

...

heh, /dpt/ shit doesn't need multiple modules

monads are what they are

a monad enforces linear ordering of dynamic effects - you can think of this either in terms of >>= or join

they allow you to combine data and effects so that you can have monadic or effectful values, e.g. IO Int or (Writer Text) Double

the dynamic bit means that you can have a computation that takes one effect, and chooses another effect depending on that result, while static effects (applicatives) cannot depend on the results

Thats my point.

F5 builds and runs your file. If you need inputs you can define them too.

It does lack an integrated terminal like VS Code

do the whites and chinese make computers hard to use on purpose so people in the community can't get good jobs?

However, Coedit has better completion/suggestion than that of VScode

>sitting in a coffee

inb4 gatekeeper >reddit spacing

>reddit spacing
I don't want your reddit stink nearby.

t. gatekeeper

ctrl-alt-n then my compile and run bind is faster that making a new file and running dub/rdmd on it
VS code has trash defaults, but has much better customization overall.

>Reddit spacing
>Overall lack of capitalisation and punctuation
Fuck off.

Thanks guys, I think I get it now

oops, lol, thanks for the 3h in paint

Idris () has a totality checker btw., it's one of the features the creator heavily emphasizes

en.wikipedia.org/wiki/Total_functional_programming

Do a fizzbuzz in functional programming, using no loops and if/else

fizzBuzz x =
case (x `mod` 3, x `mod` 5) of
(0, 0) -> "FizzBuzz"
(0, _) -> "Fizz"
(_, 0) -> "Buzz"
(_, _) -> show x

main = mapM_ (putStrLn . fizzBuzz) [1..100]

>pattern matching
isn't that basically a switch?
Can't you just use map, filter etc?

Any R users here?
Can I do some type of try/catch or try/except mechanisms in R?
I want to try and do something like this:
try (my_function())
if successful, continue
if not successful, do something else

Sorry for the shitty pseudocode, I'm obviously not big on these things.

Switch is a limited pattern match or WOULD BE if you understood that switch is designed to compile to jumps and that not all generalisations of that can be.
Similarly for If.

This is perfectly functional. Maybe I should be asking you why you would use a switch or an if/else rather than label and goto?

Reposting my masterpiece.

I'm just exploring the functional paradigm of D today but I don't know how to filter 3 types of ranges

For example I can filter out the 15's products. Now I need to acquire the rest of the numbers and the range is 3 and 5's products. Any tips?
import std.stdio;

void main()
{
import std.algorithm, std.range, std.format;
each!writeln(iota(1,101).filter!(a => a%15==0).map!(x => format("Fizzbuzz")));
}

>partial main

enterprise quality code m'lord.

range of*

...

>meme

getArgs isn't total, my friend.
It's not a filler tho, this is a formal proof my implementation is correct.

>predSwitch
Based Andrei

Thank you very much, user

>Is the core of Haskell total?
No.

stop using int main you mongoloid.

>getArgs isn't total
Which means it shouldn't be used.

>dlang.org/phobos/std_algorithm_comparison.html#.predSwitch
Fuck this shit is autistic

this. use nat main.

>passing code in strings
What is this, tcl?

>idris-fag
>is-fag

mixins are love

No, they're fucking stupid.

Who's Idr?

>let's emulate pattern matching with shitty hacks
Wew, Andrei.

youre fucking stupid, theres nothing wrong with them.

I see nothing wrong with this
int factorial(int n)
{
return n.predSwitch!"a

met a business grad at a party last night learning R

That's hideous

>>/trash/

you make your c program a dynamic lib and provide a wrapper header

then you write gui program and call your shit from there

>Code inside strings
>Exceptions
>No syntactic relation between predicates and their values; they're just separated as function arguments
>Non-tail call recursion

It's a useless hack and it's impossible to read, m8, even when it's heavy commented, mostly because verything is comma-separated and code is being passed as a string. Compare to equivalent
fn fact(n : isize) -> Result {
match n {
_ if n < 0 => Err(()),
0 | 1 => Ok(1),
n => Ok(n * fact(n-1)?),
}
}

or even
fn ufact(n : usize) -> usize {
match n {
0 | 1 => 1,
n => n * ufact(n-1),
}
}

since you don't actually need error handling here.

>factorial
>int
What did she mean by this?

We've been found out. Burn the evidence.

It's a factorial function
These are valid points
Well comments were there to explain the operations

Factorial isn't defined on all integers.

this is why there was an exception

>this is your brain on D

Why not just use a more appropriate type instead of doing retarded things?

you mean uint? yeah that's a better way I suppose, if you pass negative integer the program will still throw exception

Are they called functions or methods? Are the names interchangeable?

>Are the names interchangeable?
No in most cases. Structs and classes have methods, functions are more generalized

>Switch is a limited pattern match or WOULD BE if you understood that switch is designed to compile to jumps
wrong

Reminder that dependent types are a meme.
github.com/davidfstr/idris-insertion-sort/blob/master/InsertionSort.idr

t. hasklet

>(x:e) -> (y:e) -> Type
ffs

Finishing up on my Business Rule Generator for a school project.

Fuck Oracle's APEX for being what it is (especially its lack of documentation) and fuck Salesforce's Apex for fucking up my searches when I want info about Oracle's APEX

The Java backend is OK though.

I'm thinking of rewriting the backend in Kotlin this summer as a side-project. Any thoughts on Kotlin?

Seems ok, though the stuff that has been added on the youtube channel so far feels really trivial and mostly covers the really basic syntax. I might check up on it later though, I am interested in learning a dependently typed language at some point.

Im using VS with c forms and have a dictionary list of custom class objects thats saved on one form and i need them loaded on another. Trying to use application settings class to do this. No problem with generic data types, just that dictionary list.

I tried serializing them with JSON, but the objects need to be fed right into a combobox and aint working

The login screen

Creating a business rule

also, wat do Sup Forums?

Any Microsoft fags here? I am trying to build a Plugin for Visual Studio 2015 that "links" the Editor Classifier with a Command Window and I have no idea what I'm doing

>meme

More spicy memes for you.
gist.github.com/timjb/9043255

>memes

>le >meme meme

>le
>meme

More m3m3s for you, my dear friend.
rosettacode.org/wiki/Proof#Idris

>doesnt calculate for the entire domain of x!

>m3m3s

anyone has a good msbuild cheat sheet?

> >>>

I will disappear if you keep bullying me!
Be careful.

>Sup Forums in $currentYear
>this place used to contain an actual content

really completes the picture, desu

That's why we have to bring back /prog/.