[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/: Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 321
Thread images: 26

File: me_irl.jpg (114KB, 481x700px) Image search: [Google]
me_irl.jpg
114KB, 481x700px
Previous Thread: >>56559084

A thread by /int/elligents for /int/elligents.
>>
File: Calculus of Maki Constructions.png (312KB, 452x355px) Image search: [Google]
Calculus of Maki Constructions.png
312KB, 452x355px
>/int/
Fuck off
------------------------------------------------
/dpt/ - Daily Programming Thread
What are you working on, /g/?
Maki edition

Previous Thread: >>56559084
>>
File: austrailishits.png (89KB, 926x333px) Image search: [Google]
austrailishits.png
89KB, 926x333px
>>56569255
Probably an ausfag poster.
>>
>>56569268
>2 posters
>le shitty aus meme
Fuck off OP
>>
>got a perfect score on the structure of programming languages quiz everyone else got F's on
feel free to ask me any csci questions, brainlets. i may deign to respond
>>
File: blank_europe_map.gif (283KB, 1280x1024px) Image search: [Google]
blank_europe_map.gif
283KB, 1280x1024px
r8 my Europe, /int/. :-)
>>
Reposting important question.
How the fuck do I improve my productivity? Reading some tech book, pretty easy, but 1-2 hours tops, then my brain feels like a goo. Is it normal? How do wizards do wizardry then?
What do you do to get more work done?
>>
>>56569307
Learn Haskell

>>56569279
What features should a type system have?

>>56569293
I told you to fuck off OP, we're going to derail your fucking off topic derail thread into a proper on-topic dpt thread
>>
File: anal beads.png (36KB, 673x851px) Image search: [Google]
anal beads.png
36KB, 673x851px
I don't know how to feel right now. My brain hurts.

>>56569255
>What are you working on, /g/?
Converting my ETL package into a service with various schedules depending on the required frequency of a data refresh.
>>
>>56569310
I started this thread because old thread is dead and I actually want to build an app today.

I'm building a GUI calculator. If I need help, I'll ask you pussies.

I usually only post on /int/ and /his/, but I'll be here today.
>>
File: dr-phil-fat.png (239KB, 600x750px) Image search: [Google]
dr-phil-fat.png
239KB, 600x750px
>>56569310
>>
File: 1470269867365.jpg (17KB, 264x277px) Image search: [Google]
1470269867365.jpg
17KB, 264x277px
>>56569334
>I'm building a GUI calculator
>If I need help, I'll ask you pussies

>GUI calculator
>need help
>>
>>56569334
That's some basic bitch shit, nigga.
>>
>>56569360
I might not, but if I do, I know where to go to ask and be condescended to.
>>56569368
You're fucking basic, nigga. I bet you didn't even go to the gym today.
>>
>>56569380
>be condescended to
You mean "be condescended"?
>>
>>56569310
>What features should a type system have?
how the fuck should i know
>>
>>56569435
... How did you pass your test?
>>
>>56569442
idk it was pretty easy lol
>>
>>56569334
>I'm building a GUI calculator
No you aren't. Fuck off, manlet.
>>
Implementing bidirectional realization in bicoloured Calculus of Constructions in Haskell.
>>
>>56569468
Why?
>>
>>56569477
I'm tired of writing out all arguments explicitly.
>>
>>56569370
>>56569396

sounds like homework, but here's a little tip

(1 << 1) == 2
(1 << 2) == 4
(1 << 3) == 8

now think of a way to test every bit in order
>>
Been playing with rust this afternoon and im not liking it so far. Documentation is poor beyond basic syntax. Syntax is on level with c++ templates and fucking compiler is annoying. I have C,C++ background and rust is pain in the ass. One evening of playing with it and im tired of fucking unwrap. So much code duplication.... and since rust is special you have to do it all tust way... Haskell is joy to uze in comparison
/rant
>>
>>56569843
Rust is not ready to be used in production.
>>
>>56569843
>waah, this technology forces me think in new ways
>>
>>56569880
I figured as much. Im moving to haskell as hobby language...
>>
>>56569901
>haskell as hobby language
jesus christ, how horrifying
>>
>>56569899
No it doesnt, concepts are simple enough. Fucking syntax is problem
>>
>>56569913
Ive been using every main stream language for too long, need a change for home projects. Rust seemed interesting in theory but alas syntax and compiler are too annoying
>>
>>56569901
>>56569913
I don't know. Haskel is not a language I'd like to work with, but seems a nice pick to fuck around. It gives off Pearl's write-only language wibe.
>>
>>56569937
That's even more embarrassing.
>>
File: 1454688257841.jpg (23KB, 232x271px) Image search: [Google]
1454688257841.jpg
23KB, 232x271px
I'm kind of new to C++, and currently testing out Magick++ and was wondering, how can I create a window displaying an image?
>>
>>56569957
What are you working on?
>>
fp people, do you prefer haskell, ocaml or f#?
why?
>>
Reminder that Vim 8.0, the first major update in a decade, has just been released.

https://groups.google.com/forum/#!topic/vim_dev/CmiGxtJ7fn4
>>
>>56569812
if:
(1 << 1) == 2
if:
(1 << 2) == 4
if:
(1 << 3) == 8
if:
(1 << 4) == 16
if:
(1 << 5) == 32
if:
(1 << 6) == 64
if:
(1 << 7) == 128
>>
>>56570012
vim's too hard to learn
>>
>>56570001
Haskell or OCaml, because they're the most mature among the bunch. I don't hate on any others tho, F* especially looks really intriguing.
>>
>>56570025
now a way that doesn't include a giant list of ifs for every bit position
>>
>>56569982
Come on show me rust code withou 50000 unwraps or match statements.
>>
>>56570028
why f*?
>>
>>56570069
Dependent types, multi-monadic effects and handlers, familiar syntax, it also attempts to fill the gap between theorem proves like Coq and general-purpose languages like Idris.
>>
>>56570052
function switchit(bit_position)
{
switch(bit_position)
{
case 1:
return (1 << bit_position) == 2;
break;
case 2:
return (1 << bit_position) == 4;
break;
case 3:
return (1 << bit_position) == 8;
break;
case 4:
return (1 << bit_position) == 16;
break;
case 5:
return (1 << bit_position) == 32;
break;
case 6:
return (1 << bit_position) == 64;
break;
case 7:
return (1 << bit_position) == 128;
break;
}
}
>>
>>56569230
If I have a very simple python module designed to solve complex math expressions given as a python string, how should I handle invalid input to the module's solve() function? Should I just return math.nan (Not a number), or should I create custom exceptions that users of the module will have to catch?
>>
>>56570125
What have a function when you could just make the entire function ambiguous to 1 line:
((1 << bit_position) == pow(2, bit_position));
>>
File: 1472778831070.png (323KB, 356x960px) Image search: [Google]
1472778831070.png
323KB, 356x960px
>>56570125
>>
>>56569333
What is that ugly language? Holy shit, so many obj.do().then().do().this().run().after().this()
>>
>>56570163
whats pow
>>
>>56570026
It's not that difficult. What do you use?
>>
>>56570177
power, exponent, 2^bit_position
Even if u still want to use a function, delete the switch and add my line.
>>
>>56570198
but thats cheating
>>
>>56569979
>It gives off Perl's write-only language vibe
There's a lot of really cryptic Haskell online, but people don't post their Java-like imperative style Haskell.
>>
>>56570146
Throw an exception. Fail fast is better than magic sentinel values.
>>
>>56570163
anon, this is C where people know what << is especially when used in a function for printing binary

>>56570205
agreed, no C user should cheat on the << operator! the << operator has feelings too you know!
>>
http://pastebin.com/yBEnQ8Bq
somebody from finland helb
how can i make the black circle change colors between red and blue if the number is odd or even
>>
>>56570146
Custom exception, reserve NaN for undefined solutions to valid expressions.
>>
>>56570261
Finland mentioned :-DDDDD
>>
>>56570261
God damn it anon, program in English. Even the japs program in English.
>>
>>56570288
no fucking help really its my friends homework i dont know shit about javascript
>>
>>56570001
Haskell, it's a lot more powerful and practical type-wise
The code's a lot nicer too
>>
>>56569396
That's fucking disgusting.
>>
Rate my binary converter!

>>56570025
>>56570125
of and fuck you guys sideways
#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char **argv)
{
if (argc < 2){
printf("Usage %s <number>\n", argv[0]);
return EXIT_SUCCESS;
}

long num = atol(argv[1]);
char temp[64] = {0};
char *c = &temp[63];

*c = '\0';

while (num != 0)
{
--c;
*c = (num & 1) + '0';
num = num >> 1;
}

puts(c);
}
>>
>>56570261
i wrote you a simple function
function evenorodd(x)
{
var i = x;
while(i >= 0)
{
i = i-2;
}
if(i == 0)
laskuri.style.color = "green";
else
laskuri.style.color = "red";
}
>>
>>56570180
gedit. feels bad man, but i went through a vim tutorial and then today i'm in class trying to use it to take notes and none of it stuck so i had to go back to gedit
>>
I'm familiar with several languages already, what's a good python resource?
>>
>>56570384
>>56570261
if you can have negative numbers...

function evenorodd(x)
{
var i = abs(x);
while(i >= 0)
{
i = i-2;
}
if(i == 0)
laskuri.style.color = "green";
else
laskuri.style.color = "red";
}
>>
>>56570361
do temp[65] and remove the *c = '\0'
a lot better than the one from the other thread though
>>
>>56570430
If you want to learn Python then you probably aren't very familiar with other languages
>>
>>56570450
x%2 ???
>>
>>56570460
if you're shitposting on 4chan then you're probably very familiar with 4chan
>>
>>56570477
what if x isn't 2 percent though
>>
>>56570484
% gets the remainder of x / 2
https://en.wikipedia.org/wiki/Modulo_operation
ak
>>
>>56570460
I need to learn it so I can work with the existing codebase at my job
>>
>>56570512
its for his homework

you dont want it to look like he copied the answer from the internet
>>
>>56570537
or maybe we do
>>
Muh preflight requests. What a pain in the ass.
>>
>>56570456
Damn, didn't notice that. ty
>>
In Python, is there a more succinct way to get a list of filepaths of files with a certain extension?
fdir = 'prawns'
impaths = [os.path.join(fdir, fname) for fname in os.listdir(fdir) if fname.endswith('.png')]
>>
>>56569988
depends on the platform and what libraries you're using.
>>
>>56570569
also &temp[64] since you decrement c before the first use
>>
>>56570180
i use joe's own editor because text editors are supposed to be fucking simple and wysiwyg, not this weird ass extensible bullshit. i don't want my text editor to also be my file manager, terminal, and irc client.
>>
>>56570615
Using XCode on a Macbook
>>
>>56570668
try cocoa lol
>>
>>56570593
glob.glob
>>
>>56570642
>i don't want my text editor to also be my file manager, terminal, and irc client.
What? I think you're confusing vim with emacs.
>>
>>56570709
they're both highly extensible text editors, what's your point?
>>
>>56570684
Cocoa for the Graphics windows, you mean?
>>
>>56570745
yes, you fucking idiot.
>>
>>56570168
C# of course
>>
File: 2016-09-12-162632_210x194_scrot.png (25KB, 210x194px) Image search: [Google]
2016-09-12-162632_210x194_scrot.png
25KB, 210x194px
>>56570001
God Emperor Racket
>>
>>56570705
Yeah I considered
glob.glob(os.path.join(fdir, '*.png'))

This is more succinct if I only want .png files, but becomes more complex if I want to match more than one file extension.
>>
>>56570726
Vim is >simple and wysiwyg
Nobody forces you to use the extensions.
>>
>>56570750
Thanks!
>>
>>56570403
gedit is shit, try kate.
>>
>>56570807
Then you probably won't get around to writing a function.

- os.listdir
- os.path.join
- os.path.splitext
- os.path.abspath/os.path.realpath

might all be useful to you.
>>
>>56570403
Use it for coding instead of taking notes, so that you can learn at your leisure.
>>
>>56570867
I don't think you saw my first post
>>56570593
>>
>>56569334
>Building a GUI Calculator
>Needing help

How's baby's first program coming along? I'm going to guess that you've just finished all you can with Scratch and want to learn the big bad Python.
>>
>>56570817
no it fucking isn't. i have to press i to type, and instead of a simple ctrl-c exit command, you have to type q! it's fucking ridiculous.
>>
>>56570963
>It's different from what I'm used to
and
>It's difficult
aren't the same thing. You get that, right?
>>
>>56570929
lol my first program was a CLI calculator with 50 something functions in C++. i even messed with the colors of the terminal to make it look prettier. i did this when i was like 10.
>>
>>56570915
I saw it, but there's probably no more succinct way.


import os

SUFFIXES = '.png', '.jpg', '.gif'

def f(path):
return [os.path.join(path, f) for f in os.listdir(path) if any(os.path.splitext(f)[1].lower() == s for s in SUFFIXES)]



Or alternatively


import re

SUFFIX_REGEX = re.compile('\.(png|jpg|gif)', re.IGNORECASE)


def f(path):
return [os.path.join(path, f) for f in os.listdir(path) if SUFFIX_REGEX.match(f)]

>>
>>56571000
it's more difficult than a normal text editor :^)
>>
>hey, let's make an api to collect input!
>hey, let's allow many kinds of inputs AND outputs!
>hey, let's allow any combination of the above!
>hey, let's assigning specific usage categories of our API!
>hey, let's NOT define a standard so any input can be anything and any output can be anything and there's 24165120 different permutations!
>hey, let them COMBINE each possible input axis so why not!
>hey, let's deprecate the api and offer a vastly inferior api for just one device!
>hey, let's ignore the fact that 100% of devices sold which aren't product_new_api_was_made_for clones support the old api!

Fucking HELL Microsoft what the FUCK is this
>>
>>56571006
You mean:
import os

suffixes = '.png', '.jpg', '.gif'
def f(path):
return [os.path.join(path, f) for f in os.listdir(path) if f.endswith(suffixes)]


?

But yeah, this seems the most succinct way.
>>
>>56571100

No, I didn't mean that. First off this won't detect suffixes that are in uppercase, secondly I like to use the library functions provided for the things I want to do. Splitext seems to be the right thing, but I suppose in this case it doesn't really matter, you are right.
>>
>>56571100
Also this code won't ever work, because you are trying to use f.endswith with the suffixes tuple -- there was a reason that I used any and a generator expression inside it in my original reply.
>>
>>56571100
Actually this is better

import os

SUFFIXES = '.png', '.jpg', '.gif'

def f(path):
return [os.path.join(path, f) for f in os.listdir(path) if os.path.splitext(f)[1].lower() in SUFFXIES]
>>
>>56570537
So it has to look sufficiently retarded?
>>
>>56571241
even worse than that
>>
File: 1436246743811.gif (2MB, 320x240px) Image search: [Google]
1436246743811.gif
2MB, 320x240px
>>56570804
>mfw drinking the tears of butthurt CS freshman that learned java in highschool and have to learn racket and can't understand prefix notation and ((parenthesis))
>>
>>56571109
>this won't detect suffixes that are in uppercase
True, but that's as simple as using .lower(), as you did, i.e.
... if f.lower().endswith(suffixes)]

But I like os.splitext, I think the best solution would be yours but with `in list` instead of the `any([ ... ])` form
import os

suffixes = '.png', '.jpg', '.gif'

def f(path):
return [os.path.join(path, f) for f in os.listdir(path) if os.path.splitext(f)[1].lower() in suffixes]
>>
>>56571018
Once the muscle memory sinks in you'll never want to go back. Believe me, I used to think vim was too difficult. Now I don't even use sublime
>>
>>56571118
>you are trying to use f.endswith with the suffixes tuple
That's the point, endswith does work with a tuple to match anything in it. Try it.

>>56571184
shuggs
>>
>>56570817
>>56571000
>>56571303

I play dwarf fortress and vim has even worse usability than that

just use codeblocks nigga
>>
>>56571262
It's just the comfiest language out there.
>>
>>56571297
One liners are ugly and overrated.
def thing (base):
for f in os.listdir(base):
name,ext = os.path.slitext(f)
if ext.lower() in suffixes:
yield os.path.join(base, f)
>>
How do I shot OOP? also I want to learn fortran and cobol, how best do I go about this? Mostly asking for authors/books, no memes
>>
If rust were as fast/faster than c in all meaningful benchmarks would c-fags use it?
>>
>>56571418
>also I want to learn fortran and cobol
why
>>
>>56571439
>not wanting to be a wizard

They're all going to die soon anyway right? and I want to maintain that stuff they built. So, I want to learn fortran and cobol, how do?
>>
>>56571418
>OOP
don't do this
>>
>>56571424
memory stuff is easy in c and posix and linux functions are already declared in a header somewhere so i don't need todeclare imports and stuff in rust plus rust code wouldn't be faster by a large enough margin to make it worth it
>>
>>56571393
I find list/dict comprehensions/ generator expressions easier to understand, because they generally match a n expected pattern, one that might be more convoluted when expressed as a for loop.
Also you can always put them on multiple lines and comment to taste
>>
>>56571424
Rust has no stable ABI
>>
Confirming that c fags literally use the language to say they use the language
>>
>>56571418
C#
>>
>>56571683
"no"
>>
File: nep nep error.jpg (47KB, 363x398px) Image search: [Google]
nep nep error.jpg
47KB, 363x398px
Valgrind tells me that my program is reading strings 10-15 bytes out of bounds (to the left) when calling realloc and increasing the length of a string.

But this bug only shows up when compiling with -O2.

The weirdest part is that the expected behavior still happens either way.
I don't even know where to begin debugging this shit.
>>
>>56571560
It's true.
Ask them why they don't use C++ and they'll just provide linus quotes, shitty pre-c++11 code examples, or vague "it's to complex" bullshit which really just translates to "I don't know how to use effective modern C++, which is safer, more abstract, modular, and exactly as performant as C, so I'm just going to sit on my pedestal because I know how to dereference a pointer and Java fags don't!"
>>
>>56571821
C or C++?

>anime
keep up the good work
>>
>>56571821
You probably have shit that went wrong (e.g. use after free?) but are getting lucky. Does your program run for a long time or just once and exits quickly?
>>
>>56571424
No. Rust isn't just orders of magnitude slower. It's far less expressive because of safety limitations. It's even worse than Go in terms of depending on the maintainers to implement abstractions for you, and without any of the useful concurrency features baked into the language.
>>
>>56571418
Fortran is pretty basic if you're familiar with a more low-level programming language (or features of them). Don't bother with 77 and just skip ahead to something from this century, here's a website: https://math.hawaii.edu/wordpress/fortran-lessons/

If you're set on a book, check out Chapman's "For Scientists and Engineers" for your particular version.

The hard part of Fortran is not the language but the domains it has been applied to. You're not going to read a book and become an expert in astrophysics or whatever niche you're planning to apply Fortran to.
>>
>>56571839
C

>>56571844
It runs and exits quickly.
Also, I haven't run a single free() up to this point, so it can't be that.
>>
>>56571874
>Also, I haven't run a single free() up to this point, so it can't be that.
Are you correctly reassigning realloc()'d pointers?
e.g.
char* string1 = malloc(100);
// ...
char* string2 = realloc(string1, 200);
// ...
strcpy(string1, "BAD BAD BAD");
>>
>>56571824
I don't want to write the whole program in C or C++.
Interfacing C with any language is really easy but trying to use c++ library is sometimes impossible.
>>
>>56571824
you're assuming many things
if you're not going to use classes, the STL, templates or C++ libs then why bother with C++
>>
>>56571560
Come to ##c and say that, pissant.
>>
>>56571860
>No. Rust isn't just orders of magnitude slower.
Except that it's competitive for non simd tasks, and even for simd tasks it's not an order of magnitude. If you're going to outright lie keep it believable
>>
>>56571824
C++ is fucking horrible
>>
>>56571949
Why does Rust perform worse on SIMD tasks?
>>
>>56571933
>then why bother with C++
templates
argument overloading
operator overloading
shared_ptr, unique_ptr (write your own if you refuse to use STL; why wouldn't you want unique_ptr's?)
>>
>>56571949
Most computation relies on SIMD to be performant you inbred.
>>
Any c fag who thinks c would be a better lower level choice than a version of rust with faster binaries doesn't care about the reasons they use the espouse c.
>>
>>56571979
>Rust
nice meme
>>
>>56571976
What world are you living in
>>
>>56571979
>Any car fag who thinks cars would be a better transportation choice than a version of a helicopter that runs on unicorn farts instead of gas doesn't care about the reasons they use the espouse [sic] cars.
Nice try but Rust simply cannot ever catch up with the supreme performance of C.
>>
>>56571821
Just exploiting undefined behavoir. Don't know how. Read realloc's source.
>>
What do I start with and how?
>>
>>56572020
Haskell
https://wiki.haskell.org/Learning_Haskell
>>
>>56572007
I'm sure that sounded very clever in your head but what you just said is literally nonsense and didn't address anything about anything/
>>
>>56571934
rizon?
>>
>>56571903
>
strcpy(string1, "BAD BAD BAD");

It's correct if string2 == NULL.
>>
>>56571972
I haven't written anything lately that would benefit from argument or operator overloading

templates are pretty much in the same boat

shared_ptr and unique_ptr do win some nice points though
>>
>>56571903
I have something similar to this in several places and valgrind complains about all of them, but only when compiled in -O2.
str = (char *) realloc(str, strlen(str) + offset_a + 1);


Something even weirder, it seems to complain about these out of order.
eg.
>invalid read of size 4 at line 254
>Address 0x5b2d484 is 148 bytes inside a block of size 151 alloc'd
line 247
>>
>>56572097
compile with -g and go step by step in gdb
>>
define functor in layman's terms
>>
>>56572069
It's general incorrect in all reasonable cases worth mentioning. Besides, in a modern OS it's nearly impossible to get malloc() to return NULL

>>56572083
For a C++ project I'm writing, I wrote a ptr/length wrapper for arrays that allow things like for-each loops, automatically scaling size with the + operator (e.g. <array [1,2,3]> + 2 = <array [3]>), and toggle-able bounds checking. With checking disabled it produces the exact same instructions as equivalent C. Maybe if you don't care, then none of that matters to you, but I have no reason to use C other than interfacing with libraries.

>>56572097
>I have something similar to this in several places
Then fix them.

>valgrind complains about all of them, but only when compiled in -O2.
A lot of things about your program change in -O2. It's still undefined behavior and should be fixed. I've had code that works in gcc and not clang, but that was because of my own errors that the two compilers were optimizing differently.
>>
>>56572159
>Besides, in a modern OS it's nearly impossible to get malloc() to return NULL
This is absolutely false. Please stop spreading falsehood.
>>
File: 1453357429094.png (1MB, 1280x720px) Image search: [Google]
1453357429094.png
1MB, 1280x720px
>>56572097
Pic

Also, consider using the gcc sanitisers.
>>
>>56572159
As a side note about using C, this anon >>56571821 would literally be having zero problems right now if they weren't using C.
But instead, they're throw into the wild west of external debugging tools, absurd compiler optimizations and fucked up undefined behavior from using low level memory management techniques in an application that absolutely doesn't need the performance.
>>
>>56570125

Why did you make a function that just returns true in all of its cases?
>>
>>56572264
in Haskell this is just
const True
>>
>>56572241
>this anon >>56571821 would literally be having zero problems right now if they weren't using C.
Can't you do anything other than spreading bullshit please? Most if not all of the problems that occur in C and more exist in most languages.
>>
File: 1473148526957.png (178KB, 614x800px) Image search: [Google]
1473148526957.png
178KB, 614x800px
>>56570125
You
>>
>>56572321
>Most if not all of the problems that occur in C and more exist in most languages.
And you accuse others of bullshit.
>>
>>56572347
Is there anything wrong with that statement?
>>
>>56572362
>Is there anything wrong with that statement?
For one thing most languages don't even grant access to the instructions that cause those problems. But ya, I'm sure java is riddled with problems from it's rampant realloc() use
>>
When will Java collect itself?
>>
>>56572392
The C standard does not say anything about what instructions the implementation may use. If your problem is the output or your specific implementation then please do not blame C for it.
>>
>>56572405
It won't. C# already collected it
>>
>>56572405
When it gets a proper GC.
>>
>>56572392

>the instructions that cause those problems
You seem to be under the strange belief that memory allocation requires special CPU instructions. It's mostly just loads and stores, and a syscall if you run out of heap memory.
>>
>>56572416
Dude, do you even know what you're trying to say?

Part of the problem with c, is that it's use has become a religion. Any attempt at competition is laughed out the door. Since rust has been mentioned I'll use that as an example. Rust is 6 years old, is as faster to faster is about half of benchmarks and considerably slower in half. It's done this while having 38 years less optimization and high levels of abstraction and memory safety. But to C users that's a failure and could never compare to their glorious c, while anyone who believed the reasons the c-shills give would probably be helping the rust community instead of being bitter and trying to prevent innovation
>>
>>56572052
FREENODE
R
E
E
N
O
D
E
>>
>>56572480
Everything you just said is nonsense.

Also, C is not to blame for the mistakes made by mortals.
>>
>>56572502
>Also, C is not to blame for the mistakes made by mortals.
I bet if someone said that about java you'd disagree with them.
>>
>>56572517
But anon, Java is garbage.
>>
>>56572480
>Dude, do you even know what you're trying to say?
Yes, have you ever read the standard?

>and memory safety
And this is false, see
fn main() {
let v = [0,1,2,3];
println!("{}", v[4]);
}

It does not have higher levels of memory safety than C.

Just as >>56572502 said, everything you said is nonsense, it's like you speak out of your butt.
>>
>>56572502
>Everything you just said is nonsense.
Give one example

>>56572528
So is C though
>>
>try to write a simple GPIO program for my Beaglebone Black
>set edge to both
>read from value in a loop
>doesn't block
Fucking god damn it. Time to ditch Gentoo and use whatever AIDS they have on the image I guess.
>>
>>56572530
>rust
>doesn't use 1-based indexing
FUCKING DROPPED
>>
>>56572530
Do you not actually know what memory safety is?
>>
>>56572530
Your example proves literally nothing
>>
>>56572554

The problem probably isn't your choice of OS. What's your code look like?
>>
>>56572599
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(){
int fd = open("/sys/class/gpio/gpio67/value", O_RDONLY);
char buffer[1];
for(;;){
lseek(fd, 0, SEEK_SET);
read(fd, buffer, 1);
printf("%c\n", buffer[0]);
sleep(1);
}
}

It's supposed to block on read until the value changes.
>>
>>56572595
It proves Rust is snake oil. None of its claims are based in reality.
>>
>>56572556

Any system that doesn't use 0-based indexing is shit.
>>
>>56572620
what's the return value of read (and potentially errno)?
>>
>>56572627
You literally just gave code of trying to access an array out of bounds. What is that supposed to proof
>>
>>56572642
No error, it just gives the value of the GPIO.
bbb tmp # ./a.out
1
1
1
1
1
^C
bbb tmp #
>>
>>56572664
Rust is literally no "safer" than C.
>>
>>56572595
It does, that it's not much safer than C. The so called "memory safety" that rust offers is mostly due to avoiding double-free. As for detecting out of bounds access at runtime there are multiple C implementations that do this, in fact even the sanitisers from the two most popular C compilers (gcc and clang) protect against these. There are also a few C compilers that guarantee that the resulting programs will never cause UB.

>>56572590
Yes, you?
It might protect from bugs such as double-free, however it does not protect against most bugs that concern memory access, thus it is not memory safe. The standard implementation does detect such errors at the runtime, however this is a really poor practice and since just the fact that it compiles exists I would consider it as unsafe.
Truly superior languages are the ones with dependent types, where such a program would not compile.
>>
>>56572675
That causes an error is every single 0-based language. Are you being serious?

Providing "more" memory safety is not providing absolute safety. You c fags will literally do anything to live in denial
>>
>>56572335
how did you know i have a comp sci degree
>>
>>56572710
Ah, you've resorted to ad hominem attacks. You've now lost the debate. Better luck next time.
>>
>>56572710
>That causes an error is every single 0-based language
The base of the arrays has nothing to do with the problem. The same would be with
fn main() {
let v = [0,1,2,3];
println!("{}", v[99]);
}

You are missing the point.
>>
>>56572620

What's the return value of read? Is it EAGAIN? Or is it perhaps some other status condition?

http://www.tutorialspoint.com/unix_system_calls/read.htm
>>
>>56572724
No, you lost the argument when instead of making points you just said
> everything you said is nonsense
And used an example that doesnt prove any point or even address the point it was responding to (as has been addressed, more != total)
>>
>>56572730
bbb tmp # nano c.c ; cc -Wall c.c ; ./a.out
r: 1
read: Success
1
r: 1
read: Success
1
r: 1
read: Success
1
r: 1
read: Success
1
^C
bbb tmp #

No error.
bbb tmp # nano c.c ; cc -Wall c.c ; ./a.out
r: 1
read: Success
1
r: 1
read: Success


r: 0
read: Success


r: 0
read: Success


r: 0
read: Success


^C
bbb tmp #

No error even when I take the seek out, it just prints newlines after that.
>>
>>56572726
Name any language where this code works.
>>
>going from C# to Java
I now finally understand why you guys hate OOP
>>
>>56569230
>cl/int/izens on /g/
DELET THIS
>>
>>56572768
Rust

>>56572753
I think that you are confusing me with him. I was the one who said "everything you said is nonsense". This is because your post back then did not contain any arguments at all other than whining about the C community, or claiming that I do not know what I am trying to say without providing any arguments as a response to me saying that the standard does not dictate what instructions an implementation may or may not use, which is correct.

>when instead of making points
I did make a point by example in that post. Also I made multiple points in the rest of the posts.
>>
>>56572753
(continued)
>doesnt prove any point or even address the point it was responding to
The topic was about C not being less memory safe than other languages. I did address any points related to that. I only did not respond to any other point that is irrelevant to memory safety as it is offtopic.
Moreover it does prove one thing: Rust is not memory safe, unlike what you might advertise, I explained that before as well.
>>
fn main() {
let v = [0, 1, 2, 3];
println!("{}", unsafe { v.get_unchecked(99) });
}


OH MY GOD, RUST IS UNSAFE!
>>
how do I make my c program sleep an x amount of miliseconds?
>>
>>56570001
Haskell/Ocaml have a decent type system, while F# has a rather crippled type system. If you are just looking for a hobby language that will teach you new ways of solving problems, pick Haskell. If you want something Haskell-like that is easier to optimize, pick OCaml (Haskell code can be just as fast as OCaml code, but getting that last level of optimization from Haskell code is a black art).

F# on the other hand has the advantage of not having utterly shit-tier level GUI bindings. It also has an arguably cleaner syntax than Haskell and is slightly easier to optimize. But the type system lacks HKT's, and as a result Haskell can be a lot more expressive.
>>
>>56572936
im in linux btw
>>
>>56572758

If the problem were that your GPIO pin was not blocking because it was reading it in non-blocking mode, it would return EAGAIN, which would be some sort of negative number. As it stands, if it returns 0, that means it has reached EOF... for whatever EOF even means for a GPIO pin. If it returns 1, that means 1 byte has been read from the GPIO pin.
>>
>>56572897
I see nothing about "unsafe" and "unchecked" at >>56572530. You only make yourself look like a retard.
>>
>>56572936
nanosleep(2)
>>
File: lsil.png (396KB, 752x676px) Image search: [Google]
lsil.png
396KB, 752x676px
Made a program to show pretty colors.
>>
>>56572852
>Moreover it does prove one thing: Rust is not memory safe
"Memory safe" does not mean "your program will never throw exceptions." Your code panics when it tries to access v[4], because it detects the out-of-bounds access at runtime. The equivalent in C will happily print garbage, just like >>56572897.
>>
Visual Studio extensions are awkward as fuck. Does anyone know what type of project I would need to be able to make an API call and paste the returned text at the current cursor position in the editor?
>>
>>56572936
Check out C11 7.26.5.7 - The thrd_sleep function

>#include <threads.h>
>int thrd_sleep(const struct timespec *duration, struct timespec *remaining);
>Description
>2 The thrd_sleep function suspends execution of the calling thread until either the interval specified by duration has elapsed or a signal which is not being ignored is received. If interrupted by a signal and the remaining argument is not null, the amount of time remaining (the requested interval minus the time actually slept) is stored in the interval it points to. The duration and remaining arguments may point to the same object.
>3 The suspension time may be longer than requested because the interval is rounded up to an integer multiple of the sleep resolution or because of the scheduling of other activity by the system. But, except for the case of being interrupted by a signal, the suspension time shall not be less than that specified, as measured by the system clock TIME_UTC.
>Returns
>4 The thrd_sleep function returns zero if the requested time has elapsed, -1 if it has been interrupted by a signal, or a negative value if it fails.
Remember however that it is optional and thus exists only if __STDC_NO_THREADS__ is not defined.

Your other solution is nanosleep and clock_nanosleep from POSIX.
>>
>>56573030
it looks like a flower. i like it
>>
>>56573051
Please see >>56572695

>The equivalent in C will happily print garbage
This is wrong, also answered on the post I linked you. There are multiple C implementations that guarantee that this will never happen.
>>
>>56572936
im curious, why do you want to do this?
>>
>>56573051
>The equivalent in C will happily print garbage
No, it will segfault (if you're using a poor compiler.) Rust does the same, it simply catches the signal from the OS and prints an error message.
>>
>>56573089
my ncurses app displays too fast, I need it to wait
I discovered halfdelay, but it doesn't even work
>>
File: 1473020099083.gif (2MB, 500x529px) Image search: [Google]
1473020099083.gif
2MB, 500x529px
For some reason bragging one the internet to random strangers about the meaningless things I am doing makes me feel better about it.

So, right now I am going to try to make my first angular 2 component. Wew lad.
>>
>>56573081
>There are multiple C implementations that guarantee that this will never happen.
Your argument for C is now "c is intentionally vague, it's a feature that your code acts unpredictably between implementations"
>>
>>56573064
I should also mention pthread_cond_timedwait.
>>
>>56573156
No, he's saying that throwing out your language fixes nothing. Improving your tooling is the real solution.
>>
File: lsil.png (965KB, 888x896px) Image search: [Google]
lsil.png
965KB, 888x896px
>>56573067
>>
What if instead of inventing more and more higher-level languages and abstractions, everything was just a C library? Instead of JavaScript, you'd have the C web scripting library. Instead of SQL, you'd have the C relational database library.

Or say you're trying to write some complicated GUI, windowing system, multi-threaded program, or networking software... you could just paste in the template of a basic program (instead of reinventing the wheel, just copy and paste the wheel) and then fill in the blanks like mad libs with the parts that you need to change.

That way everything is still in C, just 1 layer of abstraction above Assembly language for speed, and the whole world just speaks one programming language. If you need to perform some low-level memory tweaks for performance, you have the power to do that, instead of having Python/Java/Ruby force [almost] everything to be an object even if it doesn't need to be.
>>
can someone help me? neither myself nor anyone on my project team knows what we're doing and we have to make an app that gets information from google calendar from 2+ people to see what time both of you are free. sounds simple right? but none of us know where to begin. we've never made apps before and we're starting to get in the habit of just skirting around the issue and having a whole lot of talk without actually doing anything. please give me guidance
>>
>>56573156
If you intentionally avoid safe implementations then it's only your fault when shit happens.
Unsafe implementations still have their place, for software where speed is important. However if you are interested in debugging, or just do not fully trust the quality of the programs that you compile, then using a safe implementation is a must.
>>
>>56573188
C is fundementally broken. Every time someone new comes along you c fags bring out the 4 decade old arguments and go back to hacking att gcc to limit the damage. Every other field in the industry experiments and innovates, for better or worse, while c fags hide in their safe space.
>>
I'm working on a shitty voip protocol with a reference server in python, and client in c++, has anyone used the rsa module in python?
>>
>>56573030
>>56573200
lovely
>>
>>56573201
>C
Sounds like hell, Scheme or a Scheme-like language would be better.
>>
>>56573201
because C's inferior to lisp, and i will only support a single standard language if it is lisp. yes, web design in lisp as well
>>
>>56573214
You call it "innovation." People with experience call it destructive competition. It's better if we're all on the same page.
>>
>>56573236
>>56573238
lispmind
>>
>>56573252
>It's better if we're all on the same page.
no it's not, it's better if we keep improving rather than being stagnant
>>
>>56573236
>>56573238
Functional programmers are the hipsters of the programming world. You guys really are special snowflakes.
>>
>>56573276
Lisp is multi-paradigm.
>>
>>56573276
Ignore them, they're lisp faggots.
They aren't real functional programmers.
>>
>>56573064
bummer, I tried to include threads.h, but looks like I don't have c11
wtf, its 2016, everything should have c11
>>
is it normal to barley know anything on ur 2nd week of computer science? i can debug the fuck outta code but when it comes to writing it i just blank up.
Kinda scary thought, we went from week 1 Print("hello world")
to fucking finding the binary value of numbers, fibonacci, number games.

Feels like a whole diffrent course than week one like theres no inbetween?
>>
>>56573276
see >>56573284

most people who dislike lisp don't understand it. if you understand lisp, you'll understand why people fanboy it so hard
>>
>>56573252
>People with experience call it destructive competition
Ah yes, people like Bjarne Strousoup and Ken Thompson call it that regularly.
> It's better if we're all on the same page.
> It's better if the field never advances

Newtonian physics is more than good enough and super comfy. People with experience call quantum physics "destructive competition". It's better if we're all on the same page.
>>
File: girl code intense math.png (761KB, 1205x1643px) Image search: [Google]
girl code intense math.png
761KB, 1205x1643px
>>56573298
are you doing an online course / meme course like pic related, or at an actual university? if you're at an actual university (or even community college i guess) then just stick with it. it sounds weird, but you have to learn how to think is the best way i can put it. it just takes time

if you're doing codeacademy bullshit then end yourself immediately
>>
>>56573252
You literally just proved my point you know.
>>
>>56573295
GCC, Clang, musl and glibc have supported c11 for quite a while (via the --std=c11 flag) however glibc has not yet included support for C11 threads, you would need to either use another libc like musl or use a c11 to pthreads/w32 threads wrapper such as https://github.com/jtsiomb/c11threads, https://github.com/npmccallum/libc11threads or https://tinycthread.github.io/
>>
>>56573331
>entry level sorting algorithms
>Just Say No

she's right, but for the wrong reasons.
>>
>>56573331
Can you tell me waht the fuck that shit is in the picture? is this multiple choice programing?
>>
>>56573364
she's got a rocking body though
>>56573372
she's doing a codeacademy/equivalent course and posting screenshots on twitter
>>
>>56573360
i see, so one has to declare that they want c11
>>
>>56573387

She's got disgusting tattoos.
>>
>>56573389
This was the case until recently actually. The few last versions of gcc and clang default on c11 if I am not mistaken. However not all systems have updated their compilers.
>>
>>56573201

>Instead of SQL, you'd have the C relational database library.

SQLite is a C library, and it's already insanely fast.
>>
File: 2016-09-12-194100_323x56_scrot.png (2KB, 323x56px) Image search: [Google]
2016-09-12-194100_323x56_scrot.png
2KB, 323x56px
>>56573405
>>
>>56573387
yeah but
>predict the following output of the code
leads me to belive theres an A B C or D choice answer.
>>
>>56573298
>>56573331
https://blog.codinghorror.com/separating-programming-sheep-from-non-programming-goats/

>It is as if there are two populations: those who can [program], and those who cannot [program], each with its own independent bell curve. [...] We have a test which picks out the population that can program, before the course begins.

[...]

>The authors of the paper posit that the primary hurdles in computer science are..

>1. assignment and sequence
>2. recursion / iteration
>3. concurrency*

>.. in that order. Thus, we start by testing the very first hurdle novice programmers will encounter: assignment. The test results divided the students cleanly into three groups:

>• 44% of students formed a consistent mental model of how assignment works (even if incorrect!)
>• 39% students never formed a consistent model of how assignment works.
>• 8% of students didn't give a damn and left the answers blank.

>The test was administered twice; once at the beginning, before any instruction at all, and again after three weeks of class. The striking thing is that there was virtually no movement at all between the groups from the first to second test. Either you had a consistent model in your mind immediately upon first exposure to assignment, the first hurdle in programming – or else you never developed one!

[...]

>To write a computer program you have to come to terms with this, to accept that whatever you might want the program to mean, the machine will blindly follow its meaningless rules and come to some meaningless conclusion. In the test the consistent group showed a pre-acceptance of this fact: they are capable of seeing mathematical calculation problems in terms of rules, and can follow those rules wheresoever they may lead. The inconsistent group, on the other hand, looks for meaning where it is not. The blank group knows that it is looking at meaninglessness, and refuses to deal with it.
>>
>>56573448
>however glibc has not yet included support for C11 threads, you would need to either use another libc like musl or use a c11 to pthreads/w32 threads wrapper such as https://github.com/jtsiomb/c11threads, https://github.com/npmccallum/libc11threads or https://tinycthread.github.io/
Also, threads.h is optional even under C11, and thus exists only if __STDC_NO_THREADS__ is not defined.
>>
>>56573464
>1. assignment and sequence
Filthy imperatives
>>
>>56573411

Man, SQLite is so good. If there's even been one C library that 'jest werks', that's it.
>>
What programs should I study to learn fortran?
>>
>>56573464
>The inconsistent group, on the other hand, looks for meaning where it is not.
Ummm a monad is a burrito spacesuit filled with nuclear apples.
>>
File: 1473423209978.jpg (112KB, 690x690px) Image search: [Google]
1473423209978.jpg
112KB, 690x690px
>>56573147

25 minutes later, I am figuring out javascript import statement syntax instead of writing components. Shit. I guess this helps keep track of time wasted.
>>
>>56573479

SQLite has 787 times as much test code as actual library code. There's a reason it just fucking works.
>>
>>56573538

It's really the only thing written in C that actually works, at all.

Truly amazing.
>>
>>56570804
Mah nigga
>>
>>56573591
You would not have a computer if it weren't for C.
>>
>>56573591

What about zlib and libpng?
>>
File: daoko.jpg (200KB, 1024x728px) Image search: [Google]
daoko.jpg
200KB, 1024x728px
>>56569230
How do a set up a CLI (Windows) command, so whenever I need to compile a C# file I use the "csc" command. for example:
csc /t:exe /out:Program.exe Program.cs

But currently I need to specify all the path where is the csc.exe program, so it's a pain.
>>
>>56573610

I prefer operating systems written in FORTRAN.
>>
File: image.jpg (235KB, 1153x865px) Image search: [Google]
image.jpg
235KB, 1153x865px
So I learned how public-key cryptography works.

How do we know the NSA doesn't just ask every company for their private keys and they go "Well, here you go."
>>
About to start the C module at uni. What should I expect?
>>
>>56573656
>How do we know the NSA doesn't
they do
>>
For how long did you guys program before you grew out of programming?

12 years here.
>>
>>56573662
lots of copy and pasting from stackoverflow
>>
>>56573662
you have 15 minutes to complete a 5 hour assignment.
>>
File: o.webm (501KB, 1920x1080px) Image search: [Google]
o.webm
501KB, 1920x1080px
>>
>>56573662

Pointer to pointer to pointer to pointer to pointer to pointer to pointer to pointer to pointer to int.
>>
>>56573743
is that really typical in a c program?
>>
>>56573662
Segfaults.
>>
>>56573224
https://github.com/agrecascino/WAMPVoipServer
https://github.com/agrecascino/WAMPVOIPClientCPP
Here are the links to the projects, if anyone's interested.
>>
>>56573662
http://c-faq.com/decl/spiral.anderson.html
>>
>>56573760
no, never
the most you'll use in a C course is 2, rarely ever 3 but maybe
>>
>>56573760
Yes.
Of course >>56573743 exaggerated but char*** is possible.
>>
>>56573800
thanks I don't really understand any of this right now but I can see it being useful in the future. Favourited
>>
>>56573803
im talking in a real life program like the linux kernel, or mayb quake 3
not the baby course programs
>>
>>56573841
oh
at most 3, rarely 4, never 5, sometimes 6
>>
>>56573841
a
int******
doesn't show up probably ever
what will probably show up is something like
 void (*f)(int*,void**)[/cpde]
>>
>>56573913
poor anon you divided by cpde
>>
>>56573913
can you explain that last one?
im new to pointers btw
and I heard one can have pointers to functions?
>>
>>56573960
it's a pointer to a function that returns void and takes as arguments a pointer to int and a pointer to pointer to void.

Pointers to functions are possible because the program is stored in the same memory as data; they are useful because one can put them in an array or hashmap or something and use it like a jump table.
>>
>>56573803
>>56573841

I have had to use a three star pointer only once. In a class on Unix software development, I had to make a minimalist Bash-like shell. One of my functions had to split up arguments at white space, and return an integer based on something I can't remember. Anyways, since I more or less needed an array of strings (char**), and I needed to return something else, I took a char*** as argument and did something like this:

char **args;
int result = parse_args(str, &args);
>>
>>56573982
neat
>>
i got a code challenge to implement device fingerprinting across browsers using only the server side is this even possiblee
>>
>>56573960
A function is just a location in memory where a set of instructions exist, so you can point to it.

Everything in C is pass-by-value, but we simulate pass-by-reference by passing the "address of" the thing we want to modify.

A naked function identifier without brackets is just the address of the function. Likewise, a naked array without brackets is just the address of the beginning of the array.

#include <stdio.h>

int add(int a, int b) {
return a + b;
}

int subtract(int a, int b) {
return a - b;
}

int multiply(int a, int b) {
return a * b;
}

int divide(int a, int b) {
return a / b;
}

int main()
{
// declare f as an array of pointers to functions that take two ints and return an int
int (*fp[])(int, int) = {add, subtract, multiply, divide};

int x = 5, y = 2;

int i;
for(i = 0; i < sizeof(fp)/sizeof(fp[0]); ++i) {
printf("%i\n", fp[i](x, y));
}

// 7
// 3
// 10
// 2

return 0;
}
>>
>>56574206
Further reading:

https://stackoverflow.com/questions/6893285/why-do-function-pointer-definitions-work-with-any-number-of-ampersands-or-as
>>
I've been learning C# on my own for the past 9 or so months (very lazily I might add, maybe only a few hours a week). I've been doing pretty great at it I think but I want to test myself and then gitgud where I'm lacking.

Where does one begin with gitting gud?
>>
>>56574206
it hard to remember the notation though
not even fot his but also for stuff like
char *p[4] vs char (*p)[4]
>>
>>56574367
Well, where are you lacking? Also, stop talking like a /v/tard.
>>
>>56574367
>Where does one begin with gitting gud?
When you start writing projects, seriously it's only about repetition and practice.
>very lazily I might add, maybe only a few hours a week
That's too little, I do the same everyday, like 4 or 5 horurs of study/programming.
>>56574408
I felt the same way a few years ago, learn about precedency and associativity. I don't use C or Sepples anymore, but I was capable of reading things like >>56573800 image without using a table with operator's precedency.
>>
Why are Indians so attractive, and superior to all other races?
>>
>>56574021
>people will defend this as being a feature
>>
>>56574472
I have garbage motivation, and honestly a few hours a week has been more than enough, I'm comfortable with the language as a whole now and I've got no problems with architecture / design and solving problems that crop up.

Problem is I don't know how to test myself in a way that will point out my failings, working on projects is all well and good but I roll the dice on whether or not I'll ever come up on something I haven't encountered before (my ideas may even just lead me down that road anyway).

There has to be some kind of decent way to test your knowledge of a language in a very broad strokes kinda way, stuff like codewars / hackerrank seem far too interested in algorithms with 0 interest in getting you to use obscure language features or quirks.
>>
>>56574541

What's wrong with it? Multiple indirection IS a feature.
>>
>>56574596
>he did it, the absolute mad man
>>
>>56574549
>I have garbage motivation
I guess that's because you don't have a goal?
>There has to be some kind of decent way to test your knowledge of a language in a very broad strokes kinda way
Some anon recommended this to test knowledge about langs https://leetcode.com/
I haven't tried it.
I guess you're just trying to have a deep understanding of C#?
>>
>>56574666
Indeed I am, looking to make sure there are no huge holes in my knowledge before I move onto trying to be productive.

Leetcode looks good, thanks anon.
>>
>>56574541
Why shouldn't it be?
>>
File: effects.png (20KB, 742x329px) Image search: [Google]
effects.png
20KB, 742x329px
Wrote an effect system but I couldn't get a limited-effects interpreter to typecheck (I ended up with a bunch of hacky stuff because I didn't have sets), then I switched to sets but Haskell doesn't properly support inductive recursion

At the bare minimum, it did annotate effects properly, have sub-effecting, allow you to run all effects in IO, use do notation, etc.
>>
I'm making a vibrator (sex toy) with an arduino, it's going to have a button you push to cycle through preset vibration patterns. Can anyone give me some quick keywords or concepts I can google to get started? c++
>>
>>56574725
Do you use ST? It looks nice, but I just want to get that look in term... do you happen to know the font? Thanks

Also how long have you been using Haskell? I re-started learning maybe two weeks ago and it's going swimmingly
>>
>>56574767
Font is FiraCode, theme is OneDark, editor is Atom.
Do you understand GADTs?

What do you mean ST? State thread monad? State monad?
>>
>>56574747
You'll just want something to change the pin states. Conceptually it's the same tutorial as turning on an LED, just with a vibrator. You'll want to be careful about power requirements though to make sure you don't fry your arduino or the vibrator circuit.

Godspeed, you techno-perv.
>>
someone make a new thread (no anime op please)
>>
>>56574793
Sublime Text, my bad. Thanks though.
And I haven't heard of them yet but looked it up and I think I get it some.
>>
anyone know of a way in prolog to make it so in a recursive call you only evaluate a statement once in the first recursive call?
>>
>>56574961
GADTs work like regular ADTs, but you can also specify the constructor signatures - and you can make them specific, e.g.

data Expr a where
Literal :: a -> Expr a
If :: Expr Bool -> Expr a -> Expr a -> Expr a
Add :: Expr Double -> Expr Double -> Expr Double
GTE :: Expr Double -> Expr Double -> Expr Bool

b :: Expr Bool
b = Literal True

partial = If b
-- typechecks

i :: Expr Integer
i = Literal 3
partial = If i
-- does not typecheck
>>
>>56575051
And you could have something like
Read :: Expr String

Then the evaluator could interpret this as meaning "read a value from the console", and it would still be well typed (the evaluator would have type Expr a -> a)
>>
new
>>56575187
Thread posts: 321
Thread images: 26


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.