[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: 313
Thread images: 18

File: 1474569783540.gif (115KB, 500x357px) Image search: [Google]
1474569783540.gif
115KB, 500x357px
What are you working on, /g/?

Previous thread: >>61726344
>>
First for FORTRAN
>>
>multiple threads a day
>/dpt/ still can't agree on which language is best lang
>>
>>61732353
Second for OCaml.
>>
>>61732367
Literally doesn't even support native threads
>>
>>61732327
#include <stdio.h>

int main(){

int c = 5, d;
d = ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c;

printf("%d\n", d);

return 0;

}


How much is d?
>>
how bad is -Ofast?
>>
>>61732365
There is quite clearly no best lang. Different languages have different design goals and are aimed at different workflows.
>>
>>61732365
There is no objectively "best lang" for every task
>>
>>61732386
at least 1 CVE
>>
>>61732386
d > 5
>>
>>61732327

fully understanding arrays so there are no doubts about how to use them for me and also getting a grasp of object-oriented programming.

I want to start a new career as a programmer after years of suffering as a teacher.
>>
Noob question, but how do you handle file errors in C? Like if I do:
FILE *file_ptr;
file_ptr = fopen("i/dont/exist.meme", "r");
///what now


I am seriously unable to properly google for this for some reason
>>
>>61732415
good luck anon!
>>
>>61732429
if (file_ptr == NULL) // can't open file

Or
if (!file_ptr)
>>
>>61732327
Procrastinating about implementing forth. I'm a bit confused about what happens after I implement the forth interpreter in C. Do I have to bootstrap and implement forth in forth?
>>
>>61732445
Oooh ok, thanks
>>
>>61732429
man fopen
>>
>>61732322
>>61732331
when you guys praise perl you're talking about 5 since there's no reason to learn 6, right?
>>
>>61732461
Yes, we're talking about perl, not perl++.
>>
>>61732429
http://lmgtfy.com/?s=d&iie=1&q=fopen
>>
Would it be possible to remove a feature from a language while retaining compatibility with old programs?

Why don't C++ or Java do this?
>>
>>61732494
You can deprecate features.
auto_ptr was removed from C++17 after being deprecated in C++11 because it was a piece of shit.
>>
so what's
#pragma
for?
>>
>>61732577
compiler specific behavior
>>
>>61732577
compiler commands
>>
File: 000049-Twitch.png (21KB, 71x110px) Image search: [Google]
000049-Twitch.png
21KB, 71x110px
Hi g

My team hired a literal Patel. He starts Monday. How fucked are we?
>>
File: fu.jpg (45KB, 1280x720px) Image search: [Google]
fu.jpg
45KB, 1280x720px
>c++ is a horrible language
>>
>>61732432

Thanks. Arrays seem difficult but once you get the hang of them they're not so hard. Object-oriented programming seems simple at first but gets complicated very quickly.

Generally speaking, programming is wonderfully logical and after years of working in the humanities that's exactly what I need.
>>
>>61732585
>>61732586
ah, alrighty then
>>
>>61732597
It's the beginning of the end, my friend. Soon you'll be laid off and replaced with his brother Pakesh.
>>
>>61732606
but linus hates c++
>>
>>61732626
Excuse me, Sir?

That's very offensive, Sir..
>>
>>61732613
Object Oriented Programming is mainly about structuring large programs in a way other people can understand. You'll pick it up once you see how it's really used.
>>
>>61732597
start looking for a job. only a cuck you train their replacement.
>>
>>61732402
>>61732408
Incorrect. Try again.
>>
>>61732800
what's wrong with my answer?
>>61732402
>>
>>61732800
How is it not greater than 5
>>
>>61732597
Speaking from experience just don't let him commit directly to master and you will be fine.
>>
>>61732386
iirc this is undefined behavior
>>
>>61732386
undefined beehayvyor
>>
/algo/

Hey I need some algo advice.
I have a file with few points.
Each point has x, y, z values, x and y is long and lat and z is int value of point.

Points are not creating any specific shape like square or grid.

Now with values of those points I have to generate grid with of nxm size.

Is there a better way than this:
I could use bi linear interpolation to create values in specific point (it would create square or rectangle), then two for loops with bilinear interpolation to count rest of the grid.

but this method seems like not accurate + it would not allow me to use algorithms for any random point in future.


Is there group of algos or methods that would help me? Atm I am aware of interpolation and kriging
>>
>>61732386
1 1 1 GO!
>>
>>61733021
You can't use bilinear interpolation for that. Bilinear interpolation only works for grids.

You're going to have to convert the mesh into triangles and interpolate along the triangles, which is easy enough when you construct a parametric coordinate equation for each triangle.
>>
File: magic.png (156KB, 270x270px) Image search: [Google]
magic.png
156KB, 270x270px
In some intro curse on assembly, I've learned about Carry flag and how it indicates overflows on arithmetical operations.
Yet C does not have checked addition or multiplication, some reason for that?
>>
>>61733021
What's the surface (presumably) supposed to represent?

i.e. in what way the points in one grid cell affect its value

seems you should base your decision based on that
>>
>>61733190
Not portable.
>>
>>61733190
There's no good reason at all. Basically no languages except assembly let you see carry flags n shit.

Well technically you can use inline assembly to read it but then you're using inline assembly.
>>
>>61733238
then why does C have floating point types?
>>
File: pizza-botnet.png (1MB, 1280x720px) Image search: [Google]
pizza-botnet.png
1MB, 1280x720px
>want to finish the unix programming environment and assembly language step by step before the semester starts
>have to cram for the GRE and relearn a bunch of useless math and geometry instead
>>
>>61733277
>useless math and geometry
It's not useless if you're working outside of webdev.
>>
>>61733185
>You can't use bilinear interpolation for that. Bilinear interpolation only works for grids.

I was thinking about creating square like frame from point I know then just do bilinear inside, but that would be generate inaccurate values.

>>61733232
I have to to write program that will generate isolines on map.

From what I have read so far, I need to create grid first then use contour line to create isolines.
>>
>>61733307
Can you interpolate in R3 with great circles or something, normalize the points to a unit sphere then map them to R2?
>>
>>61733307
Bilinear interpolation is 100% accurate along with every other interpolation.

It's whether the interpolation has the properties you want.
>>
>>61732327
I’m currently running Anki on my version of linux (lubuntu) and while I can get the program itself to run, I can’t for the life of me get the audio to work alongside the flashcards. I’ve been trying to get Anki to run audio by getting it to utilise MPV for the audio side of things, but I’m not having much luck. I’ve installed the following addon calling “Anki MPV” : https://github.com/tsudoko/anki-mpv

For this to work you also need to install “pympv”: https://github.com/tsudoko/anki-mpv

The implementation of pympv is where I run into problems, if you look at the code in question it relies on a piece of code called “import mpv”, however, this code does not work. Running “import mpv” in python returns the value:

“Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named mpv”

If I run Anki through the terminal, it launches but I receive the following error messages:

First error, shown in a popup window in the Anki program itself:
“An error occurred in an add-on.
Please post on the add-on forum:
https://anki.tenderapp.com/discussions/add-ons
Traceback (most recent call last):
File "aqt/addons.py", line 41, in loadAddons
File "/home/aholmes/.local/share/Anki2/addons/mpvaddon.py", line 6, in <module>
import mpv
ImportError: No module named mpv”

Error two, shown in the terminal:

“aholmes@Harpsichor:~$ anki
Unable to load library icui18n "Cannot load library icui18n: (libicui18n.so.48: cannot open shared object file: No such file or directory)"
QGtkStyle was unable to detect the current GTK+ theme.
Traceback (most recent call last):
File "aqt/addons.py", line 41, in loadAddons
File "/home/aholmes/.local/share/Anki2/addons/mpvaddon.py", line 6, in <module>
import mpv
ImportError: No module named mpv”

Anyone know why the script can't import mpv?
>>
>>61733304
when i'm writing a compiler or a protocol i definitely need to know about finding arc lengths of circles. computer science = math is a meme and if you push that you're ill informed or a math double major
>>
File: 1500917814823.jpg (639KB, 1500x782px) Image search: [Google]
1500917814823.jpg
639KB, 1500x782px
>>61732327
How can I improve the code coverage of this test?
Since parse_opt is called internally by argp, how can I test it?

Unit Under Test:
https://pastebin.com/C5eaZpb7

Test code:
https://pastebin.com/ufZgdTDx
>>
>>61733416
Surely you don't think calculating arc lengths is difficult.
>>
>>61733437
I'm taking that anime girl for myself
>>
>>61733437
you were the one who was laughed at on stack overflow, right?

haha
>>
>>61733441
did i say that? reading harry potter books isn't difficult either and i don't want to waste my time doing that either
>>
>>61733416
Finding the arc lengths of circles or simple-to-integrate curves is trivial. If you're having trouble with that you're going to have trouble writing a good compiler or protocol.

I get that it's not directly useful, so maybe you're just finding it tedious as opposed to hard. But since you explicitly said "arc length of circle", there can't be any particularly complicated shit in there - surely it's just a refresher of your high school maths that should only take you a couple days, a week at the very most?
>>
>>61733482
Not that guy, but since when did something being easy mean it's worthwhile? Please get your head out of your ass.
>>
>>61733416
Math single major :^). And arc lengths of circles is your example? Honestly if you don't know about that your high school diploma should be revoked because that shit is taught in middle school.

I can agree that in general geometry and calculus are less useful for a good chunk of CS, but you definitely need a strong number theory and abstract algebra basis for any non-trivial CS.

And not knowing geometry is going to ensure you don't get a job in anything remotely touching computer graphics.
>>
>>61733482
i have a 3.92 GPA, so i'm probably more intelligent than you and am preparing more seriously than you would. thanks for your advice to just spend a week brushing up on some geometry as my preparation though i won't be taking it
>>
>>61733473
Hopefully you can calculate some integrals faster than you can read a harry potter book.
>>
>>61733559
If it's actually going to take you less than "a couple of days" why are you complaining so much then?
>>
>>61733545
>And not knowing geometry is going to ensure you don't get a job in anything remotely touching computer graphics.
Or just about any area where CS meets actual engineering...
>>
>>61733559
>needs to pull out numbers to demonstrate his superiority
pathetic
>>
File: 1494928087181.png (388KB, 677x677px) Image search: [Google]
1494928087181.png
388KB, 677x677px
>>61733416
t. brainlet
>>
>>61733559
People with sky high gpas tend to not succeed desu.
http://time.com/money/4779223/valedictorian-success-research-barking-up-wrong/

>>61733591
That too. I had compiler design on my mind and was thinking about the glsl compilers in graphics drivers.

Certainly no calculus means absolutely no computer engineering.
>>
Learning C++. Someone might say i'm crazy, but pretty sure C++ could come in handy and teach me how to shoot in own foot and solve problems.

I currently work as C# programmer (web) and know C.
>>
>>61733591
like what?
>>61733588
you sure are stupid aren't you?
>>61733598
i thought you loved numbers? guess only when you're memorizing a bunch of formulas
>>
>>61733639
Learning C++ or C or Java is hard. Learn an easier language (like Python) and save your time.
>>
>>61733639
> Someone might say i'm crazy
Nope, C++ is very useful. You should know it.
>>
>>61733639
>Someone might say i'm crazy
Only unemployed people on /g/ would say that.
With C#, some web and C++ you got a lot of fronts covered

I'm a C++ dev (haven't worked with -anything- else language-wise) learning C# and trying to get into Microsoft's tech stack
>>
>>61733342
I have to use R2
>>
>>61733623
i'm in college, brainlet
>>
>>61733652
>reading comprehension below noise floor
>>
>>61733679
por que
>>
>>61733689
maybe if you're speaking for yourself
>>
>>61733657
>Learning C++ or C or Java is hard

C is not hard and i hate Pajeet-Java, will never fully learn it. C++ Is hard but i want to know it at least for some degree.

It busts my ego and dick size among fellow web monkeys and more importantly, i'm really interested
>>
>>61732327
Programming is all I do now, sun-up to sundown.
>>
>>61733684
Yeah and? You're still going to not succeed. Your GPA proves that you're obedient and have narrow-minded motivations, which means you'll only ever be mediocre.
>>
File: 000046-Twitch.png (114KB, 136x404px) Image search: [Google]
000046-Twitch.png
114KB, 136x404px
>>61733710
>got em!
>>
What programming projects, if any, are you currently working on?
>>
>>61733652
>like what?

Anything that involves things moving around in the real world, or systems observing things moving around for starters.

Traffic, security cameras, scanners (material passing on conveyors/roller tables <-- even checking a slab of concrete for defects involves tons of math, I work with this fun topic), etc.
>>
>>61733717
Looks like you shitpost as well.
>>
File: 1492923105243.jpg (47KB, 645x968px) Image search: [Google]
1492923105243.jpg
47KB, 645x968px
>>61733721
the article you posted as evidence referred to a study investigating high school valedictorians. pic is of you
>>
>>61733721
>sour grapes
It's okay, sweetie. Brains aren't everything. :^( Now go earn me some bennies in the sheet metal factory while my grad school lover gives me the BBC (big-brained cock).
>>
>>61733725
I'm trying to learn C++ for a weird platform I happen to have lying around but all the tutorials are shit and do things that you shouldn't be doing.
>>
i like perl6
>>
>>61733730
but anon, all you need to do is throwing lots of hardware at an AI :^)
>>
File: wat.png (3KB, 249x203px) Image search: [Google]
wat.png
3KB, 249x203px
>Browse /g/
>Go to /dpt/
>Read that JVM is faster than CLR
>Read that JVM is a good VM
>Not sure if irony or serious
>>
>>61733452
>>61733456
ok thanc u guys
>>
>>61733730
what would stop me from google searching a formula when i need it if i get a job doing that and not working as a programmer to meet requirements that have already been designed (which is the "real world")?
>inb4 'you can just google search about unix!'
yes, that's what i'd like to be doing
>>
>>61733774
>Calcium Lime Rust, more commonly known as CLR, is a household cleaning product used for dissolving stains, such as calcium, lime, and iron oxide deposits.
blazing speeds my friend
>>
>>61733730
>even checking a slab of concrete for defects involves tons of math, I work with this fun topic
>engineering concrete
That sounds brainlet as fuck, no wonder you're bitter. Well, I guess there's a chance you'll be smarter in your next life!
>>
>>61733725
>What programming projects, if any, are you currently working on?
I'm trying to investigate the data flow in YOLO object detection framework. More specifically, I'm interested in disk IO patterns, as I have created a userspace NVME driver that allows individual CUDA kernel threads to initiate disk read/writes into GPU memory.

But extending YOLO with this functionality only makes sense if disk IO can be highly pipelined.
>>
>>61733725
none. i'm studying for the gre.
>>
>>61733815
No you're not, you're shitposting in /dpt/.
>>
>>61733829
have my book in front of me right now
>>
>>61733804
Knowing the formula exists and knowing the search terms to find said formula, Also knowing when said formula does or does not apply and to what extent.
>>
>>61733834
Then close this thread and read it
>>
>>61733736
But of course :]
>>
>>61733842
am literally performing math in my head as i type this post
>>
is lisp a meme or is it the true hacker* language?

*https://stallman.org/articles/on-hacking.html
>>
>>61733277
gre?
>>
>>61733808
Actually it sounds pretty neat desu. And quality assurance pays well. 100k out of college:
http://www1.salary.com/Six-Sigma-Black-Belt-salary.html
>>
>>61733774
kek, never attribute to malice that which is adequately explained by stupidity.
>>
>>61733857
Got something for you to "perform" on, you little twink bitch. Now put your skirt on.
>>
>>61732327
Currently I'm learning the JPA, Hibernate (it's quite alright, but I don't really see the point yet. Writing SQL directly isn't exactly painful, and gives you more control of what happens, but I can see the point here. I still have a lot of the APIs to learn though.

I also wrote a very simple wrapper thing for Spark/Freemarker to make it easier to render webpages using it. I wonder if it's easier than the older MAV way.
>>
>>61733928

Hi there, Pajeet.
>>
>>61732494
You mean, make older programs no longer compile?

I guess you could. But then you'd have people who still build a bunch of old shitty source and run that. They'd have to make a proper build environment and we all know they don't have that, so they'd be butthurt. Personally, I'm cautiously optimistic that something like that will happen.
>>
File: 1427389185728.png (230KB, 499x699px) Image search: [Google]
1427389185728.png
230KB, 499x699px
redpill me on SMT solvers and formal analysis

is it a meme or will mathematics research be automated one day?
>>
>>61733965
whats a smt solver
>>
>>61733804
not him but I could easily see problems you'd struggle with:

>factory changes part of the conveyor to be roller table instead to inspect from below
>added vibrations from the rollers
>material also now raises then dips, adding different wavelength vibrations throughout the material

how do you find the needed parameters to compensate for this?

note: super easy problem for an engineer, not so for math babby CS
>>
>>61733994
https://leodemoura.github.io/files/oregon08.pdf
>>
redpill me on strcat_s as opposed to strcat
>>
>>61733965
The proofs are in some ways not nearly as interesting as the rest of math.

With some exceptions, the hardest part about math is wondering what to prove, not how to prove.

For example fundamental theorem of arithmetic descends from invention of factorization. Fundamental theorem of calculus descends from invention of differentiation and integration. Chinese remainder theorem is the consequence of invention of modular arithmetic.
>>
>>61734010
awww cmon dont make me read
>>
>>61733774
welcome to 2017 friend, JVM is part of the big boys now
>>
>>61734029
That makes sense, but machine learning research is producing unbelievable results year after year, and I can't help but think the "separate interesting ideas to prove from the uninteresting ones" will be solved eventually.
>>
>>61734017
Not portable and useless. C is about speed not sfaety.
>>
>>61734017
use strncat or strlcat instead I forget which one glibc doesn't have
>>
File: 1473420811037.png (12KB, 246x200px) Image search: [Google]
1473420811037.png
12KB, 246x200px
>tfw you spot the simple logic error that kept you stuck for days

needed to do 0<->1, 1<->2, ... n-2<->n-1 and forgot to do n-1<->n mod n
>>
#include<crypt.h>
int main(int argc, char* argv[]) {
printf("%d\n", (int)strlen(crypt(argv[1], $6$stuff$)));
}

This seems to always return 92. How safe is the assumption that this will always hold, assuming I don't change the encryption scheme specified in the salt? Documentation for crypt() is really poor in this regard.
>>
>no dumb questions thread
i'll ask here instead
i want to look at the standard library implementation of a function in c++. how do i do that?
>>
>>61734029
>The proofs are in some ways not nearly as interesting as the rest of math.
A lot of mathematicians will disagree I'm sure. Results are interesting, but you won't see people circle jerking over them like you'll see them do over a neat proof. Proof can be beautiful, results, not as much.
>>
>>61734193
there are different implementations. the most popular ones:

https://github.com/gcc-mirror/gcc/tree/master/libstdc%2B%2B-v3
https://github.com/llvm-mirror/libcxx
>>
>>61734176
And on further testing this seems to depend on the salt length, so I'm stupid.

However, change it to:
#DEFINE SALT=$6$kfjdsgfjds$
printf("%d\n", (int)strlen(crypt(argv[1], SALT)) - (int)strlen(SALT));
and it always returns 86. NOW how safe is my assumption?
>>
File: push_back.png (34KB, 1062x338px) Image search: [Google]
push_back.png
34KB, 1062x338px
>>61734193
Easiest way: use a decent IDE that knows where to find the files.


e.g. on Windows the easiest way to view these is to just right-click and "Go to definition" in Visual Studio. Pic related. They're all in the "VCxx" directories installed under Program Files.
>>
>>61734243
thanks. but i couldn't find it/figure out how to find it. mind posting the code for uniform_real_distribution?
>>
I found it useful to make a target for "clean all" in my makefile (so it runs make clean, then make all, in case this was confusing). Is there a standard/conventional name for this kind of dummy target? I named it "fresh" but I've never seen that anywhere before.
>>
>>61734099
It's not separation. It's thinking of the problems in the first place.

Although I will say being alive in the 21st century is depressing desu. We're quickly approaching the point where a single person is totally meaningless.

Science and math feel tapped out. We haven't had a scientific innovation in 100 years, and we haven't had a mathematical one in 150 years. CS is also getting tapped out at a really fast rate too.

You can see the degeneracy with research on stupid, pointless, and meaningless shit like string theory, metamathematics, and monads.
>>
>>61734338
>and we haven't had a mathematical one in 150 years
kek fuck off. math made staggering progress during the 20th century
>>
>>61734308
Go to the repo and search for it. It is located in random, like the page you linked say.


The implementation does nothing more but normalize it over the interval a,b. Also like the page you linked said...
>>
>>61732386
Multiple sequence points.
I'm a Java programmer and I know this. (Because the Java documentation on sequence points talks about it, but still.)

Do you really expect the actual C programmers to not know their relatively small language inside and out?
>>
>>61732675
This.
A lot of the stuff that seems weird or over the top in the beginning makes a lot more sense when you have larger programs.
>>
>>61733260
bcoz not portable
>>
>>61734231
It's not results. You misunderstood me. It's hard to explain.

I think to clarify what i mean by "asking the right questions" is why people get all hot and bothered over map, filter, and fold. Those functions are trivial to write but they open the path to writing so many other functions trivially.

A pretty proof is circlejerked over because of mathematical elegance which can be found outside of proofs. You can find mathematical elegance in source code too.
>>
>>61732854
The compiler is free to do whatever it wants when it gets to undefined behaviour. Including summoning daemons out of your nasal cavities.
>>
>>61734378
Analysis and computer science made staggering process in the 20th century you mean. The rest of math didn't.
>>
>>61734486
The 20th century was literally the time of algebraical development.
>>
How much discrete Maths did you guys learn? I'm a final year Chem student trying to work out how much time to invest in the maths side of programming.
>>
>>61733260
Because floating point is implemented on chip on every arch that C cares about, and any arch that doesn't have them on die gets them implemented manually by the compiler. Meanwhile, CARRY FLAGS aren't on every arch C cares about, so it's not a thing yet.

Languages with automatic type promotion like Python and Common Lisp is going to use this to improve performance and safety though. (At least I think that Python is going to do it. The Python compiler (which compiles Common Lisp, not Python), definitively does it, since it squeeze disgusting amount of performance out of a strongly dynamically typed language.
>>
>>61733416
when you writing a compiler you must to know at least abstract algebra, so:
var a = 3, b = 4, x = a * b;
bool r = (x == b * a);
wont fubar.

when you are writing a protocol you fucking need to count memes per second passing on the network. if, for instance, you are writing fucking VOIP, you need to count at least fucking jitter, you dumbass
>>
>>61733416
It's not that programming and math are the same thing, but you need to be strong in similar mental skills.
>>
>>61733814
>YOLO
Kill yourself
>>
>>61734520
20 years ago I'd have been more surprised to see an FPU than a carry flag.
>>
>>61734520
I can't think of a single CPU that doesn't have a carry flag.

I can think of several without multiplication, division, and definitely without FPUs.
>>
>>61733862
Once you know Lisp, you'll understand what languages truly lack.

Not even joking. Everytime you hear of some language fanboy saying that language X has $FEATURE, you will forever think to yourself that well, what's so great about that? It's a five line macro.

And you'll be forever sad because other people won't learn lisp because it isn't a cool language.

It's also retardedly fast, has mature build tools, good development envirenments, etc. At least if you use SBCL on Linux.
>>
>>61733416
what is a math double major?

you do math 2 times?
>>
>>61733956
I don't see why learning JPA makes me a Pajeet. It's in fact good money in being a non-Pajeet Java programmer. (JPA doesn't mean Java-Pajeet API, you know.)

Also, aren't most the Pajeets in the C# camp, shitting all over everything there too? And soon they'll all be writing Node.JS code.
>>
>>61733862

I only know elisp, but I thoroughly enjoy using scheme at every opportunity.
>>
>>61733260
>>61734583
>>61734620
floating point is much more crucial to have. what are you intending to do with the carry flag anyway?
>>
>>61734655
scheme is a lisp baka. common lisp is called that because it's an amalgamation of a billion lisps.
>>
>>61734668
Write an add function for arbitrarily sized numbers.
>>
File: cell-lisp.png (325KB, 640x480px) Image search: [Google]
cell-lisp.png
325KB, 640x480px
>>61734681
Yes, it really should be called Cell Lisp to illustrate how it consumed the other lisps to gain their power.
>>
>>61734681

I will probably look into full lisp when I have the time. SICP, although people call it a meme on here was thoroughly enjoyable.

>tfw never be an academic pissing around with scheme for a living.
>>
>>61734705
It failed to consume scheme though. Scheme was simply too powerful to be consumed. It couldn't digest a unified namespace, re-entrant continuations, and syntax-rules.
>>
>>61734696
well there are compiler extensions and you can also do inline assembly

https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html
>>
saw this code yesterday here

seriously what the hell is this?
template<typename T, std::size_t N>
class multi_array
{
friend class multi_array < T, N + 1 >;

using value_type = multi_array < T, N - 1 >;
using contents_type = std::unique_ptr<value_type[]>;

template<typename... A>
static value_type alloc_sub(A &&... a)
{
return value_type(std::forward<A>(a)...);
}

template<typename A0, typename... A>
static contents_type alloc(A0 &&a0, A &&... a)
{
auto ret = std::make_unique<value_type[]>(std::forward<A0>(a0));
std::for_each(
ret.get(), ret.get() + a0,
[&a...](value_type & lhs) {
auto rhs = alloc_sub(std::forward<A>(a)...);
std::swap(lhs.contents, rhs.contents);
}
);
return ret;
}

contents_type contents;

public:
multi_array(void){}

template <
typename A0,
typename... A,
typename = std::enable_if_t < sizeof...(A) + 1 == N >
>
explicit multi_array(A0 && a0, A && ... a)
: contents(alloc(std::forward<A0>(a0), std::forward<A>(a)...))
{
}

value_type &operator[](std::size_t idx)
{
return contents[idx];
}

const value_type &operator[](std::size_t idx) const
{
return const_cast<multi_array *>(this)->operator[](idx);
}
};

template<typename T>
class multi_array<T, 1>
{
friend class multi_array<T, 2>;

using value_type = T;
using contents_type = std::unique_ptr<value_type[]>;

contents_type contents;

public:
multi_array(void){}

template<typename A>
multi_array(A &&a) :
contents(std::make_unique<value_type[]>(std::forward<A>(a))) {}

value_type &operator[](std::size_t idx) {
return contents[idx];
}

const value_type &operator[](std::size_t idx) const {
return const_cast<multi_array *>(this)->operator[](idx);
}
};
>>
Whatever it is, it needs more MIDI
>>
>>61734769
somebody making things more complicated than it needs to be, as always
>>
>>61734722
It didn't bother to consume it, as it didn't have the powerlevels to give it any nourishment.

It had to go Super Scheman R6RS just to be a threat. Will Scheme Goku save the day?
>>
how can I get a segfault in a program that doesn't even dereference a pointer?
>>
>>61734769
c++ meta tinkering is patrician mental masturbation
>>
>>61734731
I pointed that out but I think it's a non-portable solution. I also don't like gcc's solution. What gcc is doing is converting the inputs to bignums then adding them and seeing if there's overflow.

This should be possible:
#include "cpuflags.h"
int add_arbitrary(int * out, int * a, int * b, int len) {
carry_clear();
for(int i = 0; i < len; i++)
out[i] = adc(a, b);
}
}

Where adc is either an add with carry operation or implemented in several instructions by reading the carry flag and acting appropriately. No excuses.
>>
Is char the smallest type in C? I literally only need one flag. Do I have to waste 7 bits?
>>
Why do people say that gcc is a shite?
>>
>>61734807
>Super Scheman R6RS
R6RS is dogshit desu. No one adopted it. R5RS is where it's at. R7RS is shaping up to be pretty good though.
>>
>>61734865
>Is char the smallest type in C?
Yes.
>I literally only need one flag. Do I have to waste 7 bits?
7 bits is nothing to get worked up over.
>>
>>61734881

> The Joke
> Your Head
>>
>>61734844
I guess you could reference something on the stack after it's been freed and you had more than one memory page of stack.
>>
>>61734888
It's 7 whole bits you nigger

C was supposed to be efficient
>>
>>61734865
Yes. Look up CPU alignment to see why. But if it's any consolation there's a possibility that the char won't increase the size of your struct due to alignment rules.

You can use a bitfield if you happen to need more than one char in a struct.

But don't worry about chars too much.

Also use bools or unsigned chars not chars.
>>
How do you do error handling in C, /dpt/? What do you use when you don't have try/catch structures? What do you do when you have functions everywhere and if they fail you want to log it, clean up, then abort the program?

What do you think about:
void finish(int errcode) {
log_place(errcode);
clean_up();
exit(0);
}

void alright(int errcode) {
log_place(errcode);
}

int *exp = getExp();
exp == NULL ? finish(-1) : alright(-1);
>>
>>61734912
Typical CPUs are byte addressed.
Get over it.
>>
>>61734769
Wew this looks a whole lot like my multi_array stuff I was doing a few weeks ago. I guess the person must have also wanted to do weird template shit like I did.
>>
>>61734906
Yeah well I never watched dbz though. All I know is yellow glowy mode is a powerup and r6rs is def not a powerup.
>>
>>61734865
It's what you need to put up with. An option would be to use a bit from something else and add the overhead of altering that thing to still work as intended in all computations its used in.
>>61734912
You absolutely can save them. But it's relatively a lot of work. Which you should be happy to do if you actually care.
>>
>>61734913
>tfw stdbool.h
What's the advantage of that over just a char?
Also why an unsigned char?
>>
>>61734865
put it in a bit field
>>
>>61734912
Speed efficient, not memory efficient. It's much slower to try and squeeze some use out of those seven bits than to just fucking waste them.
>>
>>61734968
always use unsigned types for bit fiddling. signed types have sign extension and UB on overflow
>>
>>61734878
they're clang shills
>>
>>61734994
Yeah but like I said it's one flag. All I'm doing is more or less
char my_flag = 0;
if (my_flag) {
puts("gay");
}
my_flag = 1;
if (my_flag) {
puts("meme");
}

No manual bit fiddling here.

Is there a better way to do it? Does stdbool offer any real benefit?
>>
>>61732327
In my early teens I used to play with Visual Basic and Delphi. Are there any modern RAD environments available for linux?
>>
struct nu_voidptr
{
void *data;

template <typename T>
operator T*() { return (T*) data; };
};

#define malloc(x) nu_voidptr{malloc(x)}
>>
>>61735022
no.
>>
>>61735031
Yeah. JavaFX and SceneBuilder, QtCreator, wxGlade (Python), and proably a few others.
>>
>>61735056
Thanks
>>
>>61735022
Well, it does make your intent for the variable clearer. How important that is in that case is up to you to decide.
>>
File: IMG_20170804_233944996.jpg (2MB, 4160x2340px) Image search: [Google]
IMG_20170804_233944996.jpg
2MB, 4160x2340px
Adding events and control surface synchronization to the DMX controller
>>
If fgets() returns a null pointer on error and on EOF, how can I tell if I've reached the end of input or if something went wrong?
Sorry if this is a stupid question.
>>
you can do literally anything with c and lisp
>>
>>61734633
>>61734681
so when people say learn lisp, they mean common lisp?
>>
>>61735212
Check status of feof() and ferror()
>>
>>61735240
no. they could mean any dialect of lisp
>>
>>61735240
They can mean any dialect of lisp, but Common Lisp and Scheme are the two most common ones.
>>
>>61734918
Yeah that's the way to do it. Here's a try catch if you wanna recover from errors.
#include <signal.h>
#include <setjmp.h>
#include <stdio.h>
jmp_buf try_buf;
//This doesn't work for nested try-catches
//You'll have to rewrite try_buf to be a stack of
jmp_bufs
void recover_sigsegv(int sig) {
longjmp(try_buf, 1);
//jump back inside try but setjmp now returns 1
//instead of 0
}

void init() {
signal(SIGSEGV, recover_sigsegv);
}
int try() {
return setjmp(try_buf);
}

int main() {
if(!try()) //try returns 0 unless an exception happened
goto catch;
int * a = NULL;
*a;
goto finally;
catch:
printf("Recovered from a segfault!\n");
finally:
printf("Made it past the try-catch\n");
}

You can even raise your own signals to use as errors too if you really wanna emulate Java.

>>61734968
Doing certain things to "chars" is undefined behavior because char can either be signed or unsigned depending on implementation. Because of that, its standard practice to label everything that isn't a literal character as signed char or unsigned char.
>>
>>61735185
Wow, with something like this, you don't even need to know how to play an instrument! You can call yourself a musician and all you need to do is buy some consumer electronics.
>>
>>61735240
No, both Schemes and Common Lisps will work.
Personally I'm a fan of Common Lisp. It is a bit more baroque but it also has a lot of human-friendly stuff built in.

Others prefer Scheme. Emacs Lisp is essentially a useful language to extend Emacs, but won't make you a great programmer.
>>
>>61735272
>>61735283
so all of them are equally mindblowing and enlightening?

i only have very basic bash and perl experience so I want to actually learn something for real
>>
>>61735334
Scheme is used in SICP, so I'd start with that if I were you. But that's just my opinion, plenty of people like Common Lisp too.
>>
>>61735253
Oh ok.

Is it possible that fgets() returns null, feof() returns 0, and ferror() returns 0?
>>
>>61735290
>Jumping out og a signal handler
That's asking for all kinds of UB.
>>
>>61735334
>I want to actually learn something for real
Learn Javascript. It's used everywhere now, and you can do pretty much anything with it.
>>
>>61735351
fgets() returns NULL if and only if either EOF or an error has occurred.
>>
>>61735380
>>61735351
That being said, if you call clearerr(), then yes, that's possible.
>>
>>61735334
Once you GET IT, you'll have a strong opinion on which of them are more enlightening.

However, until then, the answer is yes. But it's important that you find the answer yourself. We can show you the path, but you must walk it.

>>61735345 makes a good case for Scheme. I like Common Lisp more, because of its builtin support for larger scale, more enterprisey programming, where I feel more at home.

But it's important to know that neither of us are wrong, no matter which we prefer. Maybe I'll later convert to Scheme?
Lisp is a very strange language, and truly understanding it makes you a better programmer. But you'll forever wish you had Common Lisp.
>>
>>61735380
>>61735395
Alright, thanks!
>>
>>61735403
Different anon, what are the fundamental differences between them?

My understanding of lisp is basically
(function argument argument [...])
ad nauseaum
>>
>>61735426
https://softwareengineering.stackexchange.com/questions/41045/scheme-vs-common-lisp-which-characteristics-made-a-difference-in-your-project
>>
Every fucking job requires some rails, what the fuck.

What's a stupid rails project I can do to throw on my resume and github?
>>
>>61735315
Why are you so mad?
I got these devices as lighting controllers. I'm currently building a renderer that works similar to MA Lighting desks which start around 2000 EUR. This only cost about one tenth and by programming my own I can do the same things.
I don't "produce EDM" with it, I hate it as much as anyone who knows just a little bit about music.
I do play piano/organ/synths and sing in a band though, but that has nothing to do with this project
>>
>>61735185
install gentoo
>>
It's half past eleven and I have a cat on my leg
>>
Does C++ have array slicing?
>>
>>61735376
I don't think it's a good idea. My code is just an intellectual curiosity. Longjmp is such a pain in the dick it's not worth it in real code. In general try/catch is bad though. That code actually doesn't work desu because I forgot about how longjmp only works jumping backwards. Correct code:
#include <signal.h>
#include <setjmp.h>
#include <stdio.h>
jmp_buf try_buf;
//This doesn't work for nested try-catches
//You'll have to rewrite try_buf to be a stack of jmp_bufs
void recover_sigsegv(int sig) {
printf("Recovering from a segfault!\n");
longjmp(try_buf, 1);
//jump back inside try but setjmp now returns 1
//instead of 0
}

void init() {
signal(SIGSEGV, recover_sigsegv);
}

int main() {
init();
if(setjmp(try_buf)) //try returns 0 unless an exception happened
goto catch;
printf("Segfaulting!\n");
int * a = NULL;
printf("%i\n",*a);
goto finally;
catch:
printf("Recovered from a segfault!\n");
finally:
printf("Made it past the try-catch\n");
}


>>61735426
Biggest fundamental difference is that scheme has a unified namespace for functions and variables.
(defun fubar (list) (list list))
(fubar 0)

Works in common lisp and evaluates to '(0)
(define (fubar list) (list list))
(fubar 0)

Crashes in Scheme.
>>
>>61735426
The first difference you'll notice is that Scheme wants to remain clean. Common Lisp will mudwrestle your mom for your entertainment without much complaint. No, wait, that's the second thing you'll notice.

Scheme has a singular namespace. It's referred to as a lisp-1 because of this. (I think Emacs Lisp is a lisp-1 too.)
Common Lisp has seven namespaces. Hence it's known as a Lisp-2.

Then once you grow in your understanding, you'll start writing your own macros. This basically tells the compiler how to do its job. They differ in opinion there too.

Common Lisp comes with a great OOP system, a great build-system, a great dependency-resolution mechanism, unit testing, etc. Batteries included.

With Scheme you have to pick your libraries for these sorts of things. They *do* exist though. I'm NOT saying that Scheme doesn't have them, but Scheme's core try to remain small. Common Lisp... doesn't.

There's more, but you don't feel those until you program in those languages.

If you go with Scheme, SICP is a classic.
For Common Lisp, I'd suggest Practical Common Lisp. It's available free online too, and teaches you how to write practical programs in CL, in a reasonable way. It's done in the form of projects that you hack on.
>>
>>61735561
With std::array and std::vector, yes.

With regular arrays, no, but you can use pointer arithmetic and manually copy.
>>
>>61735588
geez
>>
>>61735570
>Longjmp is such a pain in the dick it's not worth it in real code. In general try/catch is bad though.

What is good then?
>>
>>61734176
>The returned value points to the encrypted password, a
series of 13 printable ASCII characters (the first two characters
represent the salt itself). The return value points to static data
whose content is overwritten by each call.
>>
File: PCI IRQ handling.png (43KB, 1729x178px) Image search: [Google]
PCI IRQ handling.png
43KB, 1729x178px
How can people be this incompetent and fuck up so badly like this?
I guess I'll stick with the good ol' PIC. I'm seeing absolutely no upsides to the over engineered modern piece of crap brain-damages like (((APIC))), (((HPET))), (((ACPI))), etc.
>>
>>61735985
Except, you know, PCI devices don't use dedicated interrupt lines anymore in PCIe.
>>
>>61735747
Using a language with better continuation support. Longjmp has so many pitfalls is all.

And you should handle errors immediately rather than wrapping things up in a try-catch block. I.e. check if opening that file was successful before doing operations on it rather than opening the file, doing operations on it, and making the exception handler jump your execution to the catch block.
>>
>>61736017
>PCIe
Who cares.
>>
>>61736025
PCIe is the dominant IO bus technology, so literally everyone. Even mobile platforms implement PCIe.
>>
>>61736037
PCIe is required to be backwards compatible with PCI.
I can just ignore it.
>>
>>61736025
Even PCI uses MSI over dedicated interrupt lines desu senpai.
>>
>>61735747
>>61734918
1. Write functions which can be called with an "error state" and just simply return if they are, allowing you to propagate errors safely though functions.
For example, allow NULL pointers and simply return.
int *fn1(int *a)
{
if (!a)
return NULL;
// ...
}

int *fn2(int *a)
{
if (!a)
return NULL;
// ...
}

int *fn3(int *a)
{
if (!a)
return NULL;
// ...
}

int main()
{
int *ptr = malloc(sizeof *ptr);
ptr = fn1(ptr);
ptr = fn2(ptr);
ptr = fn3(ptr);
free(ptr);
}

int *fn1(int *a);
int *fn2(int *a);
int *fn3(int *a);

int main()
{
int *ptr = malloc(sizeof *ptr);
if (!ptr)
return 1;

ptr = fn1(ptr);
if (!ptr) {
return 1;
}

ptr = fn2(ptr);
if (!ptr) {
return 1;
}

ptr = fn2(ptr);
if (!ptr) {
return 1;
}

free(ptr);
}

It allows for cleaner error handling at the place functions are called, and probably more robust functions.
This example is a bit contrived, and how often can't do this when working with some libraries, but try when you can.

2. Log errors as high up the call chain as you can, right where the errors happen. This compliments the technique above and allows for cleaner error handling.

3. Use goto to allow for a "stack-like" cleanup and have common error handling/cleanup code in one place.
bool fn(void)
{
bool ret = false;

if (!init1)
return false;
if (!init2)
goto error1;
if (!init3)
goto error2;

dothing();
ret = true;

cleanup3();
error2:
cleanup2();
error1:
cleanup1();

return ret;
}
>>
>>61736043
See >>61736046
>>
>>61736017
>PCI devices don't use dedicated interrupt lines anymore in PCIe
Source? because this isn't mentioned anywhere on osdev.
>>
>>61734518

Anyone?
>>
File: 1492533395519.jpg (145KB, 838x638px) Image search: [Google]
1492533395519.jpg
145KB, 838x638px
Employed Haskell programmer reporting in :)
>>
>>61736069
>Source? because this isn't mentioned anywhere on osdev.

>Later revisions of the PCI specification add support for message-signaled interrupts. In this system, a device signals its need for service by performing a memory write, rather than by asserting a dedicated line.

https://en.wikipedia.org/wiki/Conventional_PCI#Interrupts
>>
>>61736078
How do you even service an MSI? where does it come in from? do I have to poll something?
>>
>>61736095
It's basically just a memory write to a "magic" address which is interpreted by the chipset and invokes the appropriate interrupt routine.

You need to set up a proper interrupt vector. Take a look on how it's done in the Linux kernel.
>>
please give me something to do /g/

i kinda want to work in elm but it might be neat to do a haskell or scala backend. It's a shame AWS lambda doesn't support running haskell
>>
>>61736118
Do I need to interact with ACPI at all for this?
>>
>>61732393
>he doesn't know about lisp
kek
>>
>>61736132
Yes, and you also need to set the proper registers on your PCI device's config space in order to allow it to do interrupts (you need to do this anyway if you want it to do DMA, so this is the least of your problems).
>>
>>61736157
>>61736132
>ACPI
Sorry, I read that as APIC. I assume that was what you meant?
>>
>Wake up
>Start doing C++
>It's another episode of C++ being unintuitive
Guess why it doesn't compile
#include <algorithm>
#include <array>
#include <iostream>

using namespace std;

void
print_array(const auto& range)
{
cout << endl;
for (auto& element : range)
cout << element << ' ';
cout << endl;
}

void
sort(auto& range)
{
for (int i = 0; i < range.size() - 1; i++) {
swap(range[i], min_element(range[i + 1], range[range.size()]));
}
}

int
main()
{
auto arr = { 1, 4, 2, 0, 9, 11 };

print_array(arr);
sort(arr);
print_array(arr);

return 0;
}
>>
>>61736118
>memory write to a "magic" address
Isn't that how IO works at the lowest level in general? I remember doing that shit when i was playing around with NES homebrew.
>>
>>61736167
No, I actually meant ACPI, because I don't want to go near it.
So using the APIC is required for MSI? does using the APIC require me to go near ACPI?
>>
>>61736171
>Isn't that how IO works at the lowest level in general?
In PCI Express, yes.
>>
Reminder to stay hydrated.
>>
>>61736168
Because you're retarded and you don't know C++?
I can tell you're retarded because of your function signature style.

>auto arr = { 1, 4, 2, 0, 9, 11 };
You should know the problem with this.
>>
>>61736212
>function signature style.
What's wrong with it?
>>
>>61736185
>No, I actually meant ACPI, because I don't want to go near it.
I don't think(!!) you need to handle ACPI stuf, that should(!) be handled for you. But I usually don't work on this level.

>So using the APIC is required for MSI?
Well, you need to set up interrupt vectors, so yes.

>does using the APIC require me to go near ACPI?
I don't think so.
>>
>>61736168
cuz you can't have auto type deduction in function header
>>
>>61736228
C++17
>>
>>61736168
Because initializer list member that holds the data is const.
>>
>>61736168
auto is just used to guess the type of something based on the initialiser. trying to use it for parameters makes absolutely no sense. I think you're looking for templates.
>>
>>61736218
>Well, you need to set up interrupt vectors, so yes.
But the PIC can also setup interrupt vectors. Are MSI interrupt handlers somehow different to "normal" IRQ handlers that only the APIC supports it?
>>
>>61736260
He can use rvalue reference.
>>
>>61736260
>I think you're looking for templates.
It actually is a sugar over templates
>>
>>61736240
ah that seems neat and dumb
my clang doesn't have c++17 i guess
>>
>>61736228
>>61736260
Fucking retards. Learn C++ before you embarrass yourself.
>>
>>61736270
>But the PIC can also setup interrupt vectors
There is no "PIC" anymore, but it appears to be there for legacy reasons.

>Are MSI interrupt handlers somehow different to "normal" IRQ handlers that only the APIC supports it?
Yes, and to make matters worse, there's even MSI-X, which allow for up to 2048 separate interrupts per device.
>>
>>61732429
FILE* file_ptr;

if ((file_ptr = fopen("abcd", "r")) == NULL)
{
// see man perror, man strerror, man errno
// AND FUCKING man fopen
perror("my_program");
return -1;
}
>>
>>61736240
C++ could do auto type deduction in function headers before C++17.
>>
>>61736302
Return type inference, yes. Parameters is new for 17, IIRC.
>>
>>61736302
Yeah, I was thinking that's a C++14 feature
>>
>>61736168
Rust wouldn't have this problem
Although it doesn't have JS tier type inference(!) that C++ is offering these days
>>
>>61736315
Nope, pretty sure I've done parameter auto type deduction before C++17 came out.
>>
>>61736338
Okay, then I remember incorrectly.
>>
>>61736338
it was gcc extention prior to c++17
>>
File: 3258790151.png (3KB, 629x175px) Image search: [Google]
3258790151.png
3KB, 629x175px
>>61732327
Hey NERDS

Is this question even possible?

I made a script to go through all possible outcomes and it doesn't seem so:

blue = 0
red = 3
green = 2
purple = 6
brown = 1
colorList = [blue, red, green, purple, brown]

valueList = []
for x in colorList:
for y in colorList:
for z in colorList:
valueList.append(x + blue + y * z - brown)

valueList = sorted(valueList)



colorListstr = ['blue', 'red', 'green', 'purple', 'brown']
counter = 0

for x in colorListstr:
for y in colorListstr:
for z in colorListstr:
print(x + ' + blue + ' + y + ' * ' + z + ' - brown', str(valueList[counter]))
counter += 1
>>
>>61736168
it's 1000x more intuitive than mathematica. all you have to do is RTFM
>>
>>61736292
Ok, I'm still wondering about that image I posted though.
I only have to search ACPI tables if I'm using those interrupt pins, right? So if I force devices to use MSI (can that be done?), then I don't have to mess with ACPI at all.
>>
>>61736437
I'm not confident enough to answer that, my only experience with this is using the kernel API to set up interrupts. Look at the request_irq() implementation maybe?
>>
decided to compare compiled and uncompiled guile scheme:
compiling as part of the process:
myName@myName-VirtualBox Fri Aug 04:16:34:05 ~ $ time guile -l fib.scm -c "(fib 1000000)" 
;;; note: source file /home/myName/fib.scm
;;; newer than compiled /home/myName/.cache/guile/ccache/2.2-LE-8-3.A/home/myName/fib.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /home/myName/fib.scm
;;; compiled /home/myName/.cache/guile/ccache/2.2-LE-8-3.A/home/myName/fib.scm.go

real 0m20.453s
user 0m34.228s
sys 0m3.512s

compiling by itself:
myName@myName-VirtualBox Fri Aug 04:16:47:35 ~ $ time guile -l fib.scm -c "(display 3)"
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /home/myName/fib.scm
;;; compiled /home/myName/.cache/guile/ccache/2.2-LE-8-3.A/home/myName/fib.scm.go
3
real 0m0.085s
user 0m0.068s
sys 0m0.016s

precompiled
myName@myName-VirtualBox Fri Aug 04:16:47:53 ~ $ time guile -l fib.scm -c "(fib 1000000)"

real 0m23.569s
user 0m30.648s
sys 0m5.912s

uncompiled:
myName@myName-VirtualBox Fri Aug 04:16:35:22 ~ $ rm .cache/guile/ccache/2.2-LE-8-3.A/home/myName/fib.scm.go 
myName@myName-VirtualBox Fri Aug 04:16:35:57 ~ $ time guile --no-auto-compile -l fib.scm -c "(fib 1000000)"

real 0m23.226s
user 0m33.672s
sys 0m4.568s


amazingly it doesn't seem to make a difference. might just be that calculating a Fibonacci sequence isn't very complex.
anyone know how to execute Chicken scheme's interpreter from the command line? csi's man page doesn't seem to mention anything equivalent to guile's -c flag
also running gcc on the .c file generated by chicken's Scheme -> C compiler complains about a lack of a chicken.h file, even though I have libchicken-dev and libchicken7 installed. any ideas?
>>
>>61736518
csi -b foo.scm
If you don't wanna see the garbage printed
csi -b foo.scm -q


Does it complain when you do csc -o foo foo.scm or are you doing csc -c foo.scm? If you're dong the second part and manually running gcc, that's probably why. Just let csc run gcc for you.

What OS you using? I'm using debian and installed through apt.
>>
>>61736518
csc -c is intended for deploying chicken applications to C. chicken.h is a standalone header file intended for distributing with c source code. You have to copy chicken.h into your source folder.
>>
Jesus fuck why does stackoverflow's C++ community get triggered so easily?
>>
>>61736969
It's not only stackoverflow
>>
>>61736426
Just tried it in Haskell, and, yeah, it does not seem to be right.

You do not need to consider brown or blue.

[(x,y,z) | x <-[2,3,6], y <-[2,3,6], z <-[2,3,6], x+y*z== 30]
--> []
>>
>>61736426
Just did a very rough version in Python -- no it's not possible.
blue = 0
red = 3
green = 2
purple = 6
brown = 1
colorList = [blue, red, green, purple, brown]
##X + 0 + Y * Z - 1 = 29

multipliedList=[]
addedList=[]


for x in range(0, 5):
answer1= colorList[x] * colorList[0]
answer2= colorList[x] * colorList[1]
answer3= colorList[x] * colorList[2]
answer4= colorList[x] * colorList[3]
answer5= colorList[x] * colorList[4]
answerList = [answer1, answer2, answer3, answer4, answer5]
for item in answerList:
if item > 0:
multipliedList.append(item)
for item in multipliedList:
answer1 = item + 0
answer2 = item + 1
answer3 = item + 2
answer4 = item + 3
answer5 = item + 6
answerList = [answer1, answer2, answer3, answer4, answer5]
for item in answerList:
if item > 0:
addedList.append(item)
for item in addedList:
if item == 29:
print(item)
>>
>>61736969
Thats most C++ users.
>WELL YOU CAN DO THAT IN C++ WITH 200 LINES AND 60 BOOST IMPORTS SEE LOOK
>C++ IS THE ONLY LANGUAGE YOU NEED
>STOP HATING C++ ITS INDUSTRY STANDARD
>>
>>61736426
impossible

you have x + blue + y * z - brown

blue is 0 and brown is 1 so you have

x + y * z - 1
blue = 0
red = 3
green = 2
purple = 6
brown = 1
colorList = [blue, red, green, purple, brown]

for x in [0,3,2,6,1]:
for y in [0,3,2,6,1]:
for z in [0,3,2,6,1]:
if x+y*z-1 == 29:
print (x,y,z)
>>
>>61737003
I just want to be sure before I chew out my teachers for fucking up this early.

The issue is that it is essentially
30 - x = y * z

The lowest the left can go is 24 yet the highest y * z = is either 18 or 36. There's no way it works.
>>
>>61736426
Just tried it in scheme. Not possible at all.
(let ((x (amb 0 1 2 3 6))
(y (amb 0 1 2 3 6))
(z (amb 0 1 2 3 6)))
(required (= 30 (+ x (* y z)))))
;=> error: (amb) expression tree exhausted
>>
>>61736969


>The operands are std::initializer_list and int, not an array and int Try look it up – Passer By 26 mins ago


>As a side-note you can't use the auto specifier in parameter declaration like that. Start by reading one of these C++ books. – Ron 25 mins ago


>Possible duplicate of Is there a way to pass auto as an argument in C++? – user4581301 24 mins ago


> I updated the question – [me] 12 mins ago


>It is not "getting triggered" when someone sees a post that fails to Google something before asking here. If you do not believe you should do any research before asking a question, you are not suited for SO – Passer By 2 mins ago


>What's the point of SO if Google can answer practically all the questions ever asked here? – [me] just now edit
>>
>>61737114
>= 30
>>
>>61737120
Prefix notation is objectively superior.
>>
>>61736969
Stackoverflow in general gets fucking triggered easily. 99% of all the interesting historic questions before stackoverflow went full autistic have been locked.
>>
>>61737161
people there compete for points and badges, no?
>>
>>61737161
I see that. Good and legit questions get deemed as "not constructive" or "opinion based"
Practical problems get answers like "lol google it first xd"

If I were to google it first and got the answer what point remains to go to stack overflow? Make questions that are "opinion based"?

What the fuck is wrong with these people? I remember why I always stick to IRC channels.
>>
>>61737197
>I remember why I always stick to IRC channels.
so why are you here?
>>
>>61737199
/dpt/ is a programming blog
>>
>>61737197
Thats why communities with profiles are flawed, even IRC.
>>
PC platform is a joke.
>>
>>61736426
It's possible if you ignore the order of operations.

array = [0,3,2,6,1]

for x in array:
for y in array:
for z in array:
if (x + y) * z - 1 == 29:
print(x, y, z)
## Outputs:
## 3 2 6
## 2 3 6
>>
>>61736338
What's the source of it?
>>
>>61737119
>No answer
Why am I not surprised?
>>
>>61732386
139, apparently
>>
>>61737138
Yeah but shouldn't that be =29?
>>
>>61737425
No because I added 1 to both sides of the equation.
>>
>>61737447
Oh alright.
>>
>>61732597
Stop being racist.
>>
Why can't Android manufacturers update older devices? I'm working on my first app, and supporting KitKat is a PITA. I can't wait for another year or two when I can drop support
>>
>>61737890
>Why can't Android manufacturers update older devices?
to make people buy new devices duh
>>
>>61732205
It's gone forever
>>
>>61737951
RIP
>>
>>61737890
Just drop it already. Software developers gotta put pressure on hardware manufacturers too, you know.
>>
>>61737890
You can drop kitkat support pretty easily, noone is running it in the 1st world anymore. Installation numbers are massively inflated by pajeets.
>>
New thread:
>>61738037
>>61738037
>>61738037
>>
>>61734918
By not being an idiot and making errors.

What people mostly use as try-catch are usually just sanity checks through if-else in C. Try-catch is much more expensive than if-else, especially in compiled language.

Also in most cases if you have the knowledge to catch an error, you could just avoid it by testing for it. For error printing usually you add an additional condition for when something weird happens to go to the error resolving function and decide what to do, or you can recover from it in that function in particular.

Python users love to replace if else with try except. I find that disgusting because it shows that they have no understanding of their errors or their language.
Thread posts: 313
Thread images: 18


[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.