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

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: 326
Thread images: 13

Old /dpt/ at >>57352823

What are you working on?
>>
>>57357273
How much do you hate yourself OP?
>>
var blockQuotes = document.getElementsByTagName('blockquote');
var blockQuotesArray = Array.from(blockQuotes);

var words = (function() {
var _wordArray = [];

function add(words) {
_wordArray = _wordArray.concat(words.split(' '));
}

function get() {
return _wordArray;
}

return {
add: add,
get: get
}
})();

blockQuotesArray.forEach(function(elem, index) {
words.add(elem.innerText);
});

console.log(words.get());


Ok, lads. I've done my bit. You need to add to it now.
>>
>>57357273
The acronym in the title helps people with sane auto-watch filters.

kthx
>>
File: 1473827539441.gif (2MB, 320x240px) Image search: [Google]
1473827539441.gif
2MB, 320x240px
>i hate anime, where should i go?
>oh i know, 4chan

t. op
>>
>>57357339
>The compiler for that platform, written within the language, provides the assumptions
How?
>>
Bigotry is a reason for WHY america sucks. Don't perpetuate the problem, op.
>>
>>57357345
What do you mean how?

I don't get how you're not getting this

the virtual machine and shit
the compiler
etc

then you get back machine code
>>
>>57357378
But how do you get a proof that addition of machine integers is commutative?
>>
>>57357399
the compiler for that platform provides it
or effectively the virtual machine description asserts it
and if it has an emulator then it's proven to work for the emulator
>>
>>57357416
>the compiler for that platform provides it
Is it proven or assumed?
>>
>>57357423
yes

it's a description of the machine
>>
>>57357434
That wasn't a yes or no question.
>>
>>57357360
america sucks because of people like you using the word "bigotry" for everything
>>
>>57357443
America sucks because of you
>>
>>57357438
ffs
it is a description of the machine
how can you be this misunderstanding

x = 2
is x 2? is that proven or assumed?!
>>
>>57357463
That would be an axiom, not a proof.
>>
char string1[1024];
char string2[1024];
printf("Foo\n");
freopen("/dev/null", "a", stdout);
setbuf(stdout, string1);
printf("Bar\n");
freopen("/dev/null", "a", stdout);
setbuf(stdout, string2);

Is string2 "Bar\n" or "Foo\nBar\n"?
>>
What programming language should I learn? or know well?
>>
>>57357472
>That would be an axiom
Is that reply proven or assumed?
>>
>>57357463
>it is a description of the machine
But how do you know it's correct? You either have to prove it, test it or assume it. And in the latter two cases there is some trust involved.

Since you seem to be eager to "correct" me on how dependent types work I'm surprised you don't seem to understand the concept of proof.
>>
>>57357474
Python
>>
>>57357472
>>57357480
and since when can proofs not use axioms?

>>57357490
>But how do you know it's correct?
IT GIVES YOU FUCKING BINARY MACHINE CODE FOR FUCKS SAKE
THAT'S JUST A GLORIFIED INTEGER
THEY COULD USE THAT OUTPUT AS A FUCKING PHONE NUMBER AND CALL IT FOR ALL YOU KNOW
>>
>>57357517
What's the machine code for commutativity of machine integer addition?
>>
>>57357517
>
[smug-anime-girl.webp]
>>
>>57357443
Spoken like a true bigot.
>>
Teach me LINQ /dpt/
>>
>>57357525
>b-but how do I know the description matches the machine

I fucking hate you
Fuck you
You dumbass


You know it works on MACHINES THAT FIT THE FUCKING DESCRIPTION

What the fuck is next?
Are you gonna ask me how it knows that the variable names are correct too?
How it fucking knows that some idiot is not gonna take the machine code, print it off and eat it? Someone like you?
>>
>>57357312
var blockQuotes = document.getElementsByTagName('blockquote');
var blockQuotesArray = Array.from(blockQuotes);

var words = (function() {
var _wordArray = [];
var _wordObj = {}

function add(words) {
_wordArray = _wordArray.concat(words.split(' '));
}

function log() {
var word;
var count;

while(_wordArray.length !== 0) {
word = _wordArray[0];
count = _wordArray.reduce(function(n, val) {
return n + (val === word);
}, 0);
_wordArray = _wordArray.filter(function(elem) {
return elem !== word;
});
console.log(word + ': ' + count);
}
}

return {
add: add,
log: log
}
})();

blockQuotesArray.forEach(function(elem, index) {
words.add(elem.innerText);
});

words.log();


Getting somewhere, but it's a bit unaesthetic, sorry.
>>
>>57357525
>>57357584

or since you probably still won't understand

>HOW DO I REMOVE ALL THE AXIOMS FROM THIS PROOF?
>>
>>57357584
But what the proof it fit the description though?
>>
>>57357606
I'm fucking done
>>
>>57357584
>You know it works on MACHINES THAT FIT THE FUCKING DESCRIPTION
How? How do you know the machine fits the specification?

You getting angry is not going to make me stop replying to you.

>>57357601
All I'm saying is that any axioms made by the programmer (typically in FFI) should be visible and explicit.
>>
>>57357622
>How do you know the machine fits the specification?
FOR FUCKS SAKES
>>
>>57357273
>https://archive.rebeccablacktech.com/g/thread/S57357273
wtf. Seems like a normal post. Thought it was nsfw 2bh
>>
>>57357606
>>57357622

ok, here is the super retardo dumbass example

what the fuck stops someone from taking that machine code output and eating it?
their stomach doesn't assert the commutativity of integer addition
>>
>>57357685
>food analogies
>>
>>57357692
>food analogy
what the fuck are you talking about?
i'm saying what stops someone literally eating the output

where was your proof then?
>>
>>57357684
Maybe OP deleted it because he was embarrassed he posted a thumbnail.
>>
>>57357692
you basically want your language to be God and know everything since it can apparently prove arbitrary statements about the real world
>>
>>57357685
I get eat now
>>
>>57357701
What?

>>57357722
No?
>>
>>57357722
Hello Pajeet, are you lost?
>>
>>57357722
>>57357735
Also, that's what YOU said.
>the compiler for that platform provides it
>>
>>57357735
yes

your language can determine whether or not a machine fits an abstract specification, remember?

so why can't it do other things like determine whether or not a particular tree has fallen over
>>
>>57357763
When did I say that?
>>
>>57357754
>Also, that's what YOU said.
>>the compiler for that platform provides it
No you muppet
The compiler provides abstract descriptions of the platforms for which it compiles
The platforms for which it compiles ARE those abstract descriptions
whether or not they correspond to the real world isn't something the language can fucking know, any more than it can know whether or not they correspond to platforms that might be made a million years in the future
>>
>>57357778
>whether or not they correspond to the real world isn't something the language can fucking know
Yes.
>>
>>57357778
and as an example, the machine code produced by said compiler might be put on a completely different fucking machine that it wasn't compiled for

what then?

>>57357784
your language isn't God
>>
>>57357794
By "yes" I mean I agree.
>>
Doing some regex on this chunk of text
aria-describedby="description-id-970548" dir="ltr">Friendly Baby Fox!</a><span class="accessible-description"


When I use
(?:"description-id-[0-9]*" dir="ltr">)(.*)(?:<\/a>)

It doesn't stop properly at </a>, and will continue waaaay down to a second </a> including awhole bunch of shit I don't want.
If I change it slightly to
(?:"description-id-[0-9]*" dir="ltr">)(.*)(?:<\/a><)

Then it magically hooks onto the first </a>

I'm not sure what I'm doing wrong.
>>
>>57357798
ok

so whats the problem

you know your code fits that abstract description, and it can be a requirement in many different ways
>>
>>57357824
There was never a problem.
>>
>>57357806
nevermind, i needed a lazy operator on the capture group
>>
>>57357834
then what were you complaining about?
>>
>>57357843
I was never complaining.
>>
>>57357854
whatever

at least you're over your silly idea of building something completely redundant into the language
>>
>>57357864
Which was?
>>
>>57357874
stupid, it was stupid

>>57356560

axioms are already handled perfectly well by function types
>>
>>57357908
Are you saying that e.g. the main function should have parameters for the axioms it postulates, and pass the arguments around everywhere as proofs?

All I was saying was to have a feature like Agda's postulates but, upon building the project, the axioms are identified so they can be tested or simply trusted.
>>
File: 1475572773555.jpg (29KB, 398x356px) Image search: [Google]
1475572773555.jpg
29KB, 398x356px
>tfw ncurses uses more memory that the base program
All that element packing for nothing
>>
>>57357957
>premature optimization
>>
>>57357942
why would that be in the main?

the compiler for that language and all are inside the language
the output is just machine code

you know that the machine code describes a program you envisioned for a particular abstract machine
>>
>>57357998
That's completely fucking irrelevant.
>>
>>57357988
literally the same thing. may be different if you said coders/programmers from computer scientists
>>
File: hfrisfjgtyr.png (110KB, 790x236px) Image search: [Google]
hfrisfjgtyr.png
110KB, 790x236px
Why is this wrong? We're using MASM
>>
>>57357942
>>57357998
>>57358008

you don't even need main
>>
>>57358018
Literally the same thing. Maybe different if you said corders/programmers/computer scientists from mathematicians
>>
>>57358023
Then how do you propose to introduce axioms with function types only?
>>
File: 1288506793456.jpg (7KB, 195x195px) Image search: [Google]
1288506793456.jpg
7KB, 195x195px
>>57357957
>writing in c
>using libraries
>>
>>57358021
You mixed up low/high.
>>
>>57358025
a coder and a programmer is the same thing because the words mean the same thing, i.e. a person who writes code. a computer scientist is someone who works with the theory of computer science, which is as distinct from programming as geometry is from using a protractor
>>
>>57358026
what the fuck are you even trying to say?

you have an abstract description and dependency and abstract code in a million fucking different possible ways, one method of dependency being a function type

what is the damn problem

you got your results out, which could be done in any of a variety of ways

you take the machine code and you put it in a file or some shit, or maybe your IDE does it automatically
>>
>>57358028
Not c faggot
>>
>>57358078
There's no fucking problem. You're the one saying I'm wrong without actually articulating why, and providing a non-alternative.
>>
>>57358064
I see how he switched them, but I don't get how is mine wrong if I said explicitly where I'm storing each character

it switches like this
abcd
acbd
bcad
bcda
>>
Just started to lean programming at school. It's all in Java.

>I can read it and understand it decently
>Tfw struggle to finish labs and create my own program.
>>
>>57358109
Function types can give you dependency
Alternatively you can be working from an abstract description
How you don't understand that I don't get
>>
>>57358176
What abstract description?

Originally I was talking about postulates (well I used the word assumptions) and you said they were unnecessary because of dependent function types.
>>
>As we learned above, poor performances in technical interviewing happen to most people, even people who are generally very strong. However, when we looked at our data, we discovered that after a poor performance, women are 7 times more likely to stop practicing than men
>>
>>57358150
read sicp
>>
>>57357957
which language?
>>
>>57358201
women are fragile, they shouldn't be asked technical questions because it excludes women from jobs in tech
>>
>>57357988
yeah, sure

>>57358053
sub isodd($) {
my $odd = 0;
for my $i (1 .. shift) {
$odd = !$odd;
}
return $odd;
}

sub odd($) {
my $n = shift;
return 1 if $n == 0;
return &even($n-1);
}

sub even($) {
my $n = shift;
return 0 if $n == 0;
return odd $n-1;
}
>>
>>57358202
I assuming you mean structure and interpretation of computer programs.
>>
>language has no decent tui library
why even live
>>
I'm trying to write a program that gives out two random numbers to multiply and the user has to guess the right answer. Once the right answer is given, a new set of two numbers are given until the user force quits. I can't seem to get a new set of new numbers and the same two numbers repeat.

srand((unsigned)time(0));
while (true) {
cout << "Multiplication Time. Type (-1) to quit at any time ";

int quit = -1;
int R1 = 1 + rand() % (10 - 1 + 1);
int R2 = 1 + rand() % (10 - 1 + 1);
int sum = R1 * R2;
int userAnswer;
do {
cout << "How much is " << R1 << " times " << R2 << endl;
cin >> Answer;
if ((Answer == sum) && (Answer != quit)) {
cout << "Very good!" << endl;
}
else if ((Answer != sum) && (Answer != quit)) {
while (Answer != sum) {
cout << "No. Please try again: ";
cin >> Answer;
if (Answer == quit) { break; }
else if (Answer == sum) {
cout << "Very good!" << endl;
}
}
}
} while (Answer == sum);
}
>>
>>57358203
Ada/C
>>
>>57358200
like a datatype that expresses programs on that platform

e.g.
data thing : Type where
one : thing
add : thing -> thing -> thing
com : (x:thing) -> (y:thing) -> (add x y = add y x)


in this case i cant remember what = things are called but the point is it asserts the equality of those two things

alternatively you could have a function in the library you're using

commute :: (x:a) -> (y:a) -> (x + y) -> (y + x)


any number of different ways
>>
>>57358265
rand it again papi
with gettimeoftheday()
>>
>>57358303
whoops, just (x + y) -> (y + x)
or
commute :: (x + y) = (y + x)
>>
>>57358303
That is all well and good but you're missing the point of all this which is proving vs. postulating that the machine integers are commutative under addition in the first place.

It just sounds like you heard something about proofs and thought you would spout all your dependent type knowledge at me to seem smart.
>>
>>57358341
>That is all well and good but you're missing the point of all this which is proving vs. postulating that the machine integers are commutative under addition in the first place.
Not having this fucking conversation again
either the "real thing" meets the description or fucking not
either way, your language can't fucking know that, or what it's run on
all you know is that it works on things that meet the specification
jesus christ
>>
>>57357312
what language? C#?
>>
>>57358282
what are the freatures of ada?
>>
>>57358454
cuteness
>>
>>57358454
Safety
>>
>>57358385
>either the "real thing" meets the description or fucking not
>either way, your language can't fucking know that, or what it's run on
>all you know is that it works on things that meet the specification
And I'm talking about the process of determining whether the specification is met.
>>
>>57358486
>safety
hahahhaha
might as well use rust and a type system
>>
>>57358498
Not a part of the language
>>
>programs must be written for people to read, and only incidentally for machines to execute

Typical fucking academics.
>>
>>57358531
I know, all I said was that postulates made in the project should be identified when the project is built.
>>
>>57358537
the most simple solution is the best one
ocam's razor
>>
>>57358543
they are, in the types, and the building happens within the language, thus you get outputs for those platforms, and if you use a platform that doesn't support it then it fails to compile
>>
>>57358511
Rust is a meme, it is a worse C++, no safer, less powerful, and slow
>>
>>57358454
A good type system, mainly
>>
>>57358591
Rust is way fucking safer than C++, slightly less powerful if only because templates admit HKTs, and only slightly slower. And it is also not a hodgepodge of "backwards-compatible" features that step all over each other.
>>
>>57358567
Translation is a complicated and messy process. Write it for machines, people can learn how to read it.
>>
>>57358589
>they are, in the types
No they're not.

>and the building happens within the language, thus you get outputs for those platforms
Irrelevant.

>and if you use a platform that doesn't support it then it fails to compile
How is this determined?
>>
>>57358511
>No enumerations
>>
>>57358567
Please stop quoting ideals. That's a hindsight approach to "nature". It makes you look lazy.
>>
>>57358537
The real fallacy here is that programs can't accomplish both.
>>
>>57358643
>No they're not.
Yes they are

>Irrelevant
Completely relevant

>How is this determined?
Because it will be a type error
>>
>>57358683
Do you know what I mean by postulate? You assert that a type is inhabited (which might be consistent by some external reasoning), but you don't prove it internally.

ALL I AM SAYING: Postulates should be explicit and highlighted when building. This contrasts e.g. Rust where an unsafe block could be anywhere and you have to hunt down and possibly analyze the context yourself.
>>
>>57358567
1. Abstractions make things simple.
2. Abstractions often have performance costs.
1 & 2: When computer performance matters more than production time, simple code is often not the best code.
>>
>>57358732
>you assert that a type is inhabited but you don't prove it internally


f :: (t : Type) -> t -> String
f _ _ = "Done"
>>
>>57358744
What did he mean by this?
>>
>>57358732
>ALL I AM SAYING: Postulates should be explicit and highlighted when building. This contrasts e.g. Rust where an unsafe block could be anywhere and you have to hunt down and possibly analyze the context yourself.
Add a
grep 'unsafe' *.rs
in your build script.
>>
>>57358764
But how do you know the context of the unsafe boundary? Postulates cover the first part with the type (proposition) that you are assuming.
>The unsafe keyword has two uses: to declare the existence of contracts the compiler can't check, and to declare that the adherence of some code to those contracts has been checked by the programmer.
>>
>>57358761

Get a string out of f, without using an inhabited type.
>>
>>57358543
They ARE! They are called register flags. Conversely, in a higher than wire programming language they are called the standard library and then some. Some platforms, as anon has taken to calling them, provide you with functionality that is relevant to the machine. Linux machines will allow you access to the screen. Windows machines won't. You wouldn't be able to call the linux screen calls from a windows machine. Conversely, you also wouldn't be able to make calls to the registry in linux because there is no such thing. The differences aren't mathematical. They are conceptual.
>>
Using regex in perl to strip the bits I want from a webpage, and I'm getting two things I'm not sure how to fix:

Quotations and apostrophe marks are coming back as unicode values, &#39; and so forth.
The other is I keep getting
Wide character in print at script.pl line 28

Which is just
print "$vT[0] $vL[0]\n";


Cursory searches show that means I'm bumping into UTF8 characters? I've got use utf8 set, anything else I need to do?
This is all printing to console.
>>
>>57358793
The type you choose for t has to be inhabited to call the function, even though you don't use the value.
>>
>>57358817
exactly
>>
>>57358792
>But how do you know the context of the unsafe boundary? Postulates cover the first part with the type (proposition) that you are assuming.
You never can in any language.
If an unsafe block for example calls out to the operating system the entire program's state cannot ever be trusted anymore since the OS could theoretically have rewritten all the machine code of the process (since the OS owns and controls all of memory).
>>
>>57358265
>>57358318

Nevermind. I figured it out. I just had to do this:

  
int userAnswer;
do {
int R1 = 1 + rand() % (10 - 1 + 1);
int R2 = 1 + rand() % (10 - 1 + 1);
int sum = R1 * R2;

>>
>>57358511
>Slower than Ada
>Immature
>Toxic community
>Hideous
Wewlad
>>
>>57358626
fn main() {
println!("{}", [1, 2, 3, 4][5]);
}
>>
Problem:
I have to unrelated remote git repos that both utilize the small personal utility library i'm writing for my self as i go along.
How do i solve this? Just stick copies of the lib in both repos?
>>
>>57358827
What's your point?

>>57358831
It can be trusted assuming you trust the OS.

>>57358843
What's unsafe about that? Safety in Rust is defined as no memory errors, that's all.
>>
https://code.visualstudio.com/updates/v1_7
>>
>>57358856
That is a memory error you dildo.
>>
>>57358793
But that's simply an invocation of an inhabited type. You yourself didn't create a new kind of string called "wordified". You used a string based on the postulation for character strings to have a cohabitance of factor in this system.
>>
>>57358852
have two*
>>
>>57358868
Is it? It panics but it's not a memory error.
>>
>>57358856
>It can be trusted assuming you trust the OS.
The point is that the context for any unsafe block is the entire program's state (same with any ffi call btw).
If you step outside of the abstract language machine even once you have invalidated ALL assumptions (both before and after the block)
>>
>>57358856
>Safety in Rust is defined as no memory errors, that's all.
>https://doc.rust-lang.org/reference.html#behavior-not-considered-unsafe
>Leaks of memory and other resources
>>
>>57358871
What about it?

>>57358856
here's another:


f :: (t : Type) -> t -> (t -> t) -> t
f _ z s = s (s z)
>>
>>57358899
The fact is, in a safe language that wouldn't even compile.
>>
can someone post sample ada code?
>>
>>57358931
To be more clear, he wouldn't have ground to base any of his own assumptions on as there would be delineating the proper thought process through an expression. He'd sit there wondering, "how do I get this thing to know I wanted to write 'done'?".
>>
>>57358910
>abstract language machine
?

>>57358915
Well Rust is safe in that aspect as well.

>>57358923
I still have no fucking idea what you are trying to show here.

>>57358931
If you want "safe" to include that then sure. But Rust doesn't agree (I don't particularly agree with Rust myself).
>>
>>57358983
you can express arbitrary axioms in type signatures
>>
>>57358936
>>57355436
>>
>>57358999
But you can't actually call that function without postulating some evidence for those assumptions.
>>
>>57358975
there would be no delineating*

Adding to that. The delineation would simply be a copy of something that doesn't necessarily follow the thought process one places in their programming.

It would be like using the sound "iie/ye" pheonetically but forgetting the it is used in two languages and that they are spelled differently. With entirely different character sets.
>>
>>57358983
>>abstract language machine
>?
Usually all the semantics defined in a spec or standard (or lacking that, the de facto implementation)
>>
>>57359014
Oh fuck off, I've done this so many times I fucking give up
>>
>>57358999
>>57359014
Going off the original example of machine integer addition being commutative, that is.
>>
>>57359014
The laws of induction draw near.
>>
>>57358127
bump
>>
>>57359024
Well, yes. All I'm saying is that you set up the types to reflect that specification and postulate the properties the specification guarantees to the system. You could even test them but of course that is no substitute for an actual proof.
>>
see, take anon's post
>>57359077
add dependent types and ACTUAL proofs, and make THAT language's spec (e.g. the x86 instruction set) some kind of term in your proof/program


>b-but how do you know the x86 spec corresponds to how x86 processors work?????
>>
>>57359108
You don't 100%, you have to trust that the processor follows the specification.
>>
>>57359131
Yes, and you have to trust that the machine code that the program prints out is actually put into a file and ran on one of those processors, rather than being printed out onto paper and eaten
>>
>>57359108
>>57359131
It's also documentation that the program assumes the processor does follow a certain specification. So don't try running it on a processor that doesn't even claim to.

>>57359140
You can verify that.
http://compcert.inria.fr/
>>
>>57359131
>>57359140
And it's not a fucking x86 processor if it doesn't meet the x86 spec

You have literally been bitching tautology for hours, complaining about "how do you know apples correspond to apples????"
>>
>>57359077
>All I'm saying is that you set up the types to reflect that specification and postulate the properties the specification guarantees to the system.
The implementation has already done that.
(it's what all those tests and 3-stage compilation process is for when compiling a compiler).
Everything the spec guarantees are your axioms - if there's ever something wrong with them there's nothing you can do anyway, you have to file a bug report with your compiler vendor.
>>
>>57359168
Absolutely. I'm just talking about how you actually tell that to the language so you can use these axioms in proofs.
>>
>>57359157
>It's also documentation that the program assumes the processor does follow a certain specification. So don't try running it on a processor that doesn't even claim to.
THE COMPILER GIVES BACK MACHINE CODE, YOU DON'T KNOW HOW IT IS USED

IT DOESN'T TYPECHECK IF YOU ASK FOR IT TO COMPILE ON A BAD PLATFORM

HOW MANY FUCKING TIMES

STOP POSTING AND DELETE YOUR ACCOUNT
>>
>>57359167
No, it's not. But the compiler doesn't know that, you have to tell it.
See >>57359182.
>>
File: coeur.png (21KB, 336x317px) Image search: [Google]
coeur.png
21KB, 336x317px
was bored and did this shit.
Rate
put that code in .html file & open it with firefox
http://pastebin.com/0UZRpccK
>>
>>57358740
abstraction does not imply simplicity
you're confusing easiness with simplicity
and even then, not all abstractions make things easier
>>
>>57359213
WHAT
>>
>>57359252
Postulates are necessary to internalize the specification of e.g. the processor without baking it into the language itself.
>>
>>57359183
here is an even more childish C++ example
hopefully this gets through your fucking head

template <typename T>
myFun (T a, T b) {
return T::commute(a + b);
}

struct X {
... implementation ...
static T commute(T);
}

struct Y {
... implementation ..
//static T commute(T); -- no implementation
}

auto x = myFun<X>(3,4); // GOOD, compiles fine
auto y = myFun<Y>(3,4); // BAD, fails to compile


myFun doesn't need to know about a specific T
but it could if you fucking wanted, it could import it from some library that provided a specification

>>57359213
>But the compiler doesn't know that
Oh fuck off you daft twat
>>
File: 2016-11-02_19-56-39-1.webm (330KB, 800x480px) Image search: [Google]
2016-11-02_19-56-39-1.webm
330KB, 800x480px
it goes crazy when i hit record on sharex
>>
>>57359279
"Implement" (i.e. prove) commutativity for addition of machine integers. I'll wait.
>>
>>57359182
What would be the point of that?
>>
>>57359304
You LITERALLY want the fucking language to prove arbitrary properties about the real world
>>
autism
>>
A solution to the "count number of occurances of each word in a thread" problem in Ruby:

#!/usr/bin/env ruby

require 'json'
require 'net/http'
require 'nokogiri'

res = Net::HTTP.get URI("http://a.4cdn.org/#{ARGV[0]}/thread/#{ARGV[1]}.json")
json = JSON.parse res
words = Hash.new 0

json["posts"].each do |post|
html = post["com"]
text = Nokogiri::HTML(html.gsub('<br>', ' ')).text
text.split(/\W/).each do |word|
words[word.downcase] += 1 unless word.empty?
end
end

words.sort_by { |k,v| v }.reverse_each do |k,v|
puts "#{k} #{v}"
end
>>
>>57359233
If you can't ignore easily, anyway. An abstraction implies a greater focus on some part of something. Technically, it's a lot easier on the physical body. Allegorically, it implies that it isn't as it's rote.
>>
>>57359307
For instance, in proving that some arithmetic doesn't overflow or that some array bounds are respected.

>>57359309
No, I don't. That's the point of postulating that those properties hold.
>>
>>57359344
>No, I don't. That's the point of postulating that those properties hold.
Yes you fucking do.
>>
>>57359276
Understood, but how does that apply to a language inferring the postulates to a separate processor when it was written for the one? Stop making shit up.
>>
>>57359358
If you haven't caught on by now, >>57359304 was a rhetorical question and it was every time I asked something similar.

>>57359369
It doesn't?
>>
>>57359373
>>57359304

>it was a rhetorical question
and yet I answered it before you even fucking asked

>>57358303

that has commutativity, in the type.
>>
>>57359396
How does that data type relate to the machine integers?
>>
>>57359405
How do machine integers relate to machine integers? How does your post relate to your post? How does how does relate to how does?
>>
>>57359337
there are concretions that are more intuitive than abstractions and abstractions that are more intuitive than concretions.
depends on the kind of abstraction.
namely, abstractions that abstract code for the sake of reducing duplication are often unintuitive, while abstractions that abstract the concretions of an intutive concept (e.g. sorting) are intuitive.
>>
>>57359334
Ruby. Shut. Up!

Also, hi Ruby!
>>
>>57359344
>For instance, in proving that some arithmetic doesn't overflow or that some array bounds are respected.
A FiniteNumber type would work for those.
>>
>>57359373
>It doesn't?

You just said you have to tell the language that!

Imma stop, this guy is a botnet. I didn't want to call it a tautology as I told myself I'd stop doing that but, man.
>>
>>57359488
And the speed gains attained by eliminating the runtime checks are only going to be relevant if a machine integer underlies that and that e.g. the array lookup is done with pointer arithmetic.
>>
>>57359416
At the point of return, stupid!
>>
>>57359502
>how does that apply to a language inferring the postulates to a separate processor when it was written for the one?
Where did I say anything about this?
>>
>>57359216
Just for you.
http://heart.pai.ontopcorp.com/
>>
>>57359419
I'm not arguing for women's rights here. I'm arguing for a smooth processing of the data without any arbitrations that could very easily be well constructed opinions.
>>
>>57359432

You want to say hi to me, but you don't want me to post to, for instance, say hi back?

Also, thoughts on the script? That's the first time I've used Nokogiri in anything, and I have to say, it's pretty nifty.
>>
>>57359405
literally it's like this

>if x is 2, how do i know x + 2 is 4?
> ... x = 2 ... maths ...
> how do you know x is 2?????

in your hypothetical magical reality land language, which is already different to what i'm saying in a way you haven't understood, that your language is built for platforms, while the one i've described is simply a general top level interpreted program, for which compilers exist within the language as functions or types or whatever, but anyway

How do you know that the postulate of the commutativity of integers corresponds to the postulate of the commutativity of integers?
>>
I want to write a compiler.

for the code generation step I do need to learn assembly right, no way around that?

Also, what is the SICP of writing a compiler?
>>
>>57359576
just transcompile to C
>>
>>57359559
>How do you know that the postulate of the commutativity of integers corresponds to the postulate of the commutativity of integers?
It does by definition since you can't postulate a type that isn't a mere proposition or evaluation will get stuck.
>>
>>57359213
>No, it's not. But the compiler doesn't know that, you have to tell it.
Here

in reply to
>>57359167
>And it's not a fucking x86 processor if it doesn't meet the x86 spec
This

How intuitive
>>
Can I always assume a struct is sequential and treat it like an array of possibly mixed data types?
>>
>>57359587
>it does by definition
Wow anon, you've learned a new word!

de-fi-ni-tion
>>
>>57359603
No
>>
>>57359582
import os
import sys
os.system("gcc %s -o %s" % (sys.argv[1], sys.arv[1][:-2] + ".o"))


HEY GUYS I WROTE A C COOMPILER

KEKEKEKEKEK
>>
>>57359624
Why would you write a C compiler? Why not one for a good language?
>>
>>57359603
C or C++?
You can rely on successive struct member being at higher addresses (at the first member is alwys identical with the address of the struct itself), but there may be implementation specific padding between the members.
You can also always walk it with a char pointer and look at the bytes.
>>
>>57359648
who cares about hte language, it'll probably be some shit i come up with that probably looks like c just for the sake of learning
>>
>>57359576
>for the code generation step I do need to learn assembly right, no way around that?
Well you need to know the encoding of the instructions you intend to generate, and if you want to say produce an executable for some OS you need to know the ABI and executable file format.
>>
>>57359674
Make it properly typed
It should have GADTs and erased functions at the very least
>>
>>57359576

You don't technically need to generate assembly. If you just want to write a front end, you could target an intermediate format such as LLVM IR, and let that do the backend work for you. You could also target a bytecode format such as .NET CIL, Java Bytecode, or Web Assembly.

Also, SICP of writing compilers is the dragon book, I think.
>>
File: 1453453514442.jpg (170KB, 1260x1209px) Image search: [Google]
1453453514442.jpg
170KB, 1260x1209px
Hi,

import java.util.Scanner;

public class Week_2
{
public static void main(String[] args)
{
System.out.println("Home Brew Bottling Program");

//Create scanner object
Scanner input = new Scanner(System.in);

System.out.print("\n\nEnter the total amount of home brew in liters: ");
double num1 = input.nextDouble();

System.out.print("Enter the bottle size in milliliters: ");
int num2 = input.nextInt();

//Constant
final int ML_PER_L = 1000;

//Calculations
int total = (int)(num1 / num2);
System.out.println("You will need " + total * ML_PER_L);

double remainder = (num1 % num2);
System.out.printf(" %n%s Litres of brew will be left over (unbottled).", remainder);

//close scanner
input.close();


I've recently started learning Java in class (it's my first time actually pursuing programming ever).
I'm trying to make a program to calculate the number of bottles that when put the value:
>22.5 liters
>355 mililiters

will net the result of:
>63 bottles
>0.13 leftover (using modulus)

But honestly when I run the program it just gives me back 0 bottles with 22.5 leftovers. What am I doing wrong? (also if possible I'd like the answer in bottles to not have decimals so I tried converting? it somehow. probably am doing shit wrong so sorry.)
>>
>>57359520
Optimizers are written with a specific hardware in mind, so if the hardware has particularly efficient instructions or sequences of instructions for handling overflow the compiler can chose those for the FiniteNumber type.
>>
>>57359694
>the encoding of the instructions
so basically AN assembly of my own choosing

it will be just to learn about compiling, i think i'll just learn att assembly and compile for linux

is thta a good plan
>>57359707
i kinda want to do it using assembly, it's certainly doable
>>
>writing gigantic post about how my std::map was time travelling
>4 hours on this bug
>reconsidering my life
>close browser accidentally
>fuck this shit
>code editor shows up, as it was behind the browser
>instantly realize I was passing the map as a copy instead of reference
>change it
>it works
>feelsgoodman.jpg
>>
>>57359665

c++
>>
>>57359729
So it has to be built into the language/compiler, gotcha.
>>
>>57359743
>mutability
>>
>>57359553
You just popped in at the wrong time is all. ily.

It looks pretty well intuit but I'm groking how the bars around post in the for each statement work. If they hold the variable to be used in each iteration, why the bars?

That code actually read very easily now that I think about it. I didn't have to micromanage my understanding at all...

and the unless word.empty? part? what does it do for the word in the case that it is/isn't? It looks to be ternary but besides the obvious I'm still left wondering...how do you get an empty word?

are the bars representing like a shaft or a vent of some sort?

Ruby really isn't all that bad.

Could you explain that last line before puts?
>>
>>57359718
You forgot to convert num1 to milliliters from liters before dividing
>>
>>57359754
Obviously it has to be built in into the compiler since it's responsible for generating the actual machine code.
But it doesn't have to be anymore 'built in' than replacing power of 2 multiplications with shifts - just some canonical transforms and replacement table.
>>
I have an intro to programming class and the teacher is fucking awful. Laughs at students' problems and tells us to Google it.

Every lab we've done is self taught basically and I've finally found one I had an issue with

I have to use java to print out the number 4 comprised of asterisks, like ascii art or something. Am I just supposed to print like 10 lines of asterisks that line up correctly or is there something I'm missing?

Fuck Edward Walsh
>>
>>57359832
>Am I just supposed to print like 10 lines of asterisks
I think so
>>
>>57359832
>I have an intro to programming class and the teacher is fucking awful. Laughs at students' problems and tells us to Google it.
So basically if /dpt/ were teacher

>I have to use java to print out the number 4 comprised of asterisks, like ascii art or something. Am I just supposed to print like 10 lines of asterisks that line up correctly or is there something I'm missing?
Presumably, but maybe you can find ways to use Java to streamline the drudgery.
>>
>>57359808
Consider this, then: the language specifies that the programmer can use "inline LLVM" to provide efficient implementations of data types and operations on them, as well as to do FFI. I suppose in that case you could bake in properties like commutativity, but for more complex things like FFI you would still need to postulate properties.
>>
>>57359865
Not him, but i am the other guy

So in your language, you have postulates.
What do they achieve?
What stops me taking the program that adds the description "do not compile on x86" and compiling it on x86?
>>
>>57359854
>>57359857
That's dumb but whatever I'll do it
>>
something to edit idv3 tags in java
>>
>>57359857
>streamlining drudgery

Are you sure he won't just make it worse? It is Java
>>
>>57359772
having a hard time groking*
>>
>>57359882
They don't prevent that. But some would say that the program assumes that it is okay to follow the x86 specification given that the x86 target has been chosen.

In general, postulates just let you say that a type is inhabited (i.e. a proposition is true) when you can't construct a value (proof).
>>
>>57359907
>They don't prevent that
They don't?
So what is wrong with what I gave you, which would do even better as it could prevent you from doing that?
>>
>>57359922
What is that, exactly?
>>
>>57359832
Yes. For the most part you will be using monospace fonts and won't have to worry about them not lining up. I think it's 8 pixels per character, and 8 bits used to draw them.
>>
>>57359927
What I told you earlier, you have a machine specification. You write to that specification, and there are a variety of techniques that can force you to do so.
>>
>>57359832
>Am I just supposed to print like 10 lines of asterisks that line up correctly
Yup. That's about it.
It's basically your teachers version of
>newfags can't triforce

I've had a couple of teachers like that. I hated them at the time, but in the long run forcing me to learn to work independently has made me more competent than i would have been otherwise. I guess the classmates who couldn't hack it and dropped out can't say the same though. I might easily have been one of them myself.
>>
>>57359952
But what prevents you from compiling for the wrong target?
>>
>>57359963
A desire to get the job done correctly? Maybe experience? Good practice examples? A sane mind? *PANIC*
>>
>>57359963
It won't compile or typecheck

like the C++ example I gave you
>>57359279
y doesn't compile because the type Y doesn't have a commute function
>>
>>57359974
Exactly.

>>57359978
Why? I can postulate whatever I want and it will type check.
>>
>>57359984
>Why? I can postulate whatever I want and it will type check.
What are you programming in Javascript or C or something?
You can't fucking do that in any sane language.
>>
>>57359984
You aren't turning me on him. He's right and you know it. >>57359974 here
>>
>>57360003
You need to be able to postulate (or do something similar, like unsafe in Rust) in order to do anything non-constructive, i.e. practical.
>>
>>57360021
No you don't. And you're dealing with a complete spec of an abstract machine, so you have all the materials you need to write anything for it.
>>
>>57360031
No, I'm dealing with an actual machine.
>>
I need to convert a hex char array and have it return the decimal value. I'm stuck on finding the length of the array. The function looks like

 
unsigned long int hex2dec(const char *hex){


any help?
Also can't use hex to decimal functions
>>
>>57360041
Look, I've told you this before.
You have a specification of the abstract machine.
You can now completely safely compile valid programs for that machine, making arbitrary requirements, and you know it won't typecheck if the requirements aren't met.

You get back a bytestring of the machine code.

Whether or not someone decides to run that machine code on the target machine is not something you can fucking know.
>>
>>57359772

>It looks pretty well intuit but I'm groking how the bars around post in the for each statement work. If they hold the variable to be used in each iteration, why the bars?

The bars in a Ruby block denote the block's parameters. Since not every block has parameters, some sort of syntax must be used to denote which part of the block is the parameters, and it was decided that bars would be used for this purpose.

>That code actually read very easily now that I think about it. I didn't have to micromanage my understanding at all...

That is the point of Ruby.

>and the unless word.empty? part? what does it do for the word in the case that it is/isn't? It looks to be ternary but besides the obvious I'm still left wondering...how do you get an empty word?

empty? is a method on strings that returns true if the string has a length of 0, and false otherwise. It is not ternary, although there is a ternary operator in Ruby that uses the ? character. Rather, methods are allowed to end in a question mark in Ruby as a sort of special case. Many string and array methods contain a ? or ! at the end to signify that they are a predicate, or that they mutate the object. This is taken from Scheme method names.

>Could you explain that last line before puts?
Sort hash table by number of occurrences, iterate in reverse order.
>>
>>57360041
Then learn regular C

Critical thinking does not mean be a pain in the ass for as long as it takes for them to burn it into you. Critical thinking means tearing apart your own understanding and checking to see if it makes sense separately. If it doesn't, fill in the discrepancies with a concrete understanding. If it is not enough, ask specific questions as they relate to the problem of understanding.

You definitely don't want to drag us around as you pontificate over prerogative of the blissfully ignorant.
>>
>>57360069
>You have a specification of the abstract machine.
>You can now completely safely compile valid programs for that machine, making arbitrary requirements, and you know it won't typecheck if the requirements aren't met.
Only because you've postulated that these types and properties are apt.

>Whether or not someone decides to run that machine code on the target machine is not something you can fucking know.
Yeah, I know. That's why I think postulates that assume that kind of thing should be made loud and clear.
>>
>>57360092
>Only because you've postulated that these types and properties are apt.
No, it doesn't matter where it comes from
Maybe the developer of that platform wrote the spec (in the language).

Maybe you wrote it.

Maybe you wrote an adaptor for something else.
Who knows?

>Yeah, I know. That's why I think postulates that assume that kind of thing should be made loud and clear.
They are. They are so clear that it DOESN'T COMPILE if they mismatch.
You can imagine your idea as a subset of my idea where the compiler written in the object language then demands that all the postulates in the meta language are satisfied by a given platform
>>
File: 1452991168362.jpg (274KB, 1269x1431px) Image search: [Google]
1452991168362.jpg
274KB, 1269x1431px
rate my file downloader for 4chin
pastebin com cgZ5r8Jk

pls be gentle
>>
>>57360067
> I'm stuck on finding the length of the array
There is no array in this code. There is a pointer, but that's not quite the same. If you want the length of the string you could use strlen, or, since you probably have to loop over every single character anyway, you could use a loop that repeats as long as the current character is not 0.
>>
>>57360131
You can't actually prove that the implementation matches the specification though. That's my point.

>the compiler written in the object language then demands that all the postulates in the meta language are satisfied by a given platform
How does it do this?
>>
>>57360150
>python
0/1000
you lose
good day sir
>>
>>57360067
hex is a pointer so you can't find the length.
If hex is a string (i.e null terminated) you can get the length with strlen(hex), otherwise you have to pass the length in as a second argument.
But assuming hex is a string, why would you need the length?
You can just walk the string until null terminator and do the conversion to decimal value on the fly.
>>
File: confused.jpg (1MB, 1699x1130px) Image search: [Google]
confused.jpg
1MB, 1699x1130px
>>57360153
I thought that if a pointer was declared, so was an array and the pointer points at the first index of the array. Pls correct me if I'm wrong.
>>
>>57360162
>You can't actually prove that the implementation matches the specification though.
This is like saying "You can't actually prove that the x86 compiler will compile x86 programs"
It's silly and you keep restating it

The specification is all you care about.
You want your program to fit that specification.
If it fits that abstract machine, then it fits any physical implementation of it.

"commutativity of addition of machine integers" is abstract, and not physical
"How do you know an implementation of a machine described as having commutative addition actually does?"
>>
>>57360190
Yes, but you need to keep track of the length.
>>
>>57360196
Of course it's silly, it's obviously true. That's why you need postulates, to externalize the reasoning.
>>
>>57357273
Haha stupid weaboo image got deleted :^)
>>
File: gear.png (195KB, 318x347px) Image search: [Google]
gear.png
195KB, 318x347px
the feature I want to add to the codebase
>>
>>57360230
don't reinvent the gear
>>
File: inca.jpg (51KB, 448x336px) Image search: [Google]
inca.jpg
51KB, 448x336px
>>57360230
the code
>>
>>57360204
No dude, a pointer is not an array. It's practically just an integer that is the address of some other shit.
Consider:
int *poop = (int *) 12345

Now I have a pointer to some address that's probably not valid, but there's no UB involved as long as I don't dereference an invalid address. In this example, exactly where is the array?
>>
>>57360219
You haven't understood at all
It doesn't even matter
>>
>>57360162
>You can't actually prove that the implementation matches the specification though. That's my point.

There are ways but not all are keen to it. Besides the obvious running the code through a debugger, there is the simple act of being next to the machine and listening to it run. If it pulls on a load you'll hear the abysmal quality of the sound. If it doesn't have a problem with it, you might hear a click of sorts but that could still be misleading as it could be sharing a set of properties with the abysmal code just doing so recursively.

Basically, it shouldn't scale unless that's a quality of the program. And in that case, keep it away from me.
>>
>>57360204
so something like a for loop that goes from i->hex[i], but I need some restriction. So if I use a function like strlen, then place that into an int n, I could use the "n" as the limit.

so,


int n = hex.strlen();
for ( int i = 0; i < n ; i++) {



Something like that? Or would strlen not work because I'm using a pointer still.
>>
>>57360266
This is what my ex-girlfriend did to me while she was trying to learn on philosophy. I'd explain something, we'd reach a point where there wasn't much more to be said but some applied examples that return the proof and she'd stop as if she was satisfied and reiterate what I told her. I'd then say "yes, I just spent this time telling you that" and then she'd say "No, I just said that" and smile as if to hide her smug attitude. *PANIC*
>>
>>57360266

>>57360350
here

I'm agreeing with you. They don't understand. And they're happy with just the phonic interpretation of the data. They are part of the singularity.
>>
>>57360304
>hex.strlen
'hex' is not an instance of a class.
As I said, you could do
for (size_t i = 0, n = strlen(hex); i < n; ++i) {
...
}

or, since every C-style string is delimited with a zero character
for (char *p = hex; *p != 0; ++p) {
...
}

Which is probably the better solution, because the string is only iterated once, as opposed to the first case, where strlen iterates over the whole shebang and your for loop too.
>>
>>57360304
Just don't iterate up to n and iterate for as long as hex[i ] != `something`
>>
>>57360249
This is what being a maintenance engineer feels like.

>move thousands lines of code around so your new feature can slide in
>reshape everything so it all fits back together again
>rewrite all the tests to accommodate your new feature
>if a SINGLE thing breaks its your fault
>gee, why did that take so long? we just wanted a foo here!
>>
Why does lisp feel impossible to understand? Everything I do feels like a nightmare. I'm trying to write a += macro but I'm having trouble figuring out where to use backquote and commas, or even if I need them.

(defmacro += (v y)
(setf v (+ v y) )
)


anyone who knows lisp wants to help me out? I really feel like I'm wrong with my parameters, as every example I see uses a (var &rest bodies) but my macro should only take two args, a variable and a number so I'm not sure if I should change it.
>>
>>57359832
i have completed my assignment

public class Four {
public static void main(String args[]) {
System.out.println("* *");
System.out.println("* *");
System.out.println("* *");
System.out.println("********");
System.out.println(" *");
System.out.println(" *");
System.out.println(" *");
}
}
>>
>>57360382
Lisp is literally insane, just learn a better esoteric language like Haskell
>>
There are quite a few ways to parse cli arguments in haskell, which ones are easiest to use/most used? Not sure which one to pick
>>
>>57360373
oops, ( hex + i ) != `something`;
>>
I'm using c#.

Can I save space by making use of bytes, shorts etc? How much is the runtime cost of converting something to an int for math/string stuff?

I'm doing basic bitch console app game stuff. But if I have a stat that won't ever go above 100 it seems like a massive waste to use an int.
>>
>>57360405
I wish I had a choice, this language is complete shit
>>
>>57360414
Unless your program is running like shit it is pointless doing optimizations like that. Stick to ints. It gives you hardly any more space/speed, it's nearly always the algorithm you need to improve
>>
>>57360407
getArgs
>>
>>57360446
ty
>>
python novice here, I feel like this is super bloated but I'm too retarded to think of a way to shrink it down. Any ideas?

def is_valid_digit_group(m):
group = m.split()
index = 0
length = len(group)

for x in range(len(group)):
a = group[index]
if a.count("0") > 1:
z = "false"
elif a.count("0") == 1 and a.count("*") != 0:
z = "false"
elif a.count("0") == 1 and a.count("|") != 0:
z = "false"
elif a.find("*|") != -1:
z = "false"
elif a.count("*") > 4:
z = "false"
elif a.count("|") > 3:
z = "false"
else:
z = "true"
index += 1
if z == "false":
break
return(z)
>>
>>57360463


It's in System.Environment
It doesn't include the program name, but if you want that, there's getProgName and getExecutablePath

http://hackage.haskell.org/package/base-4.9.0.0/docs/System-Environment.html#v:getArgs

On an unrelated note, if you ever want to work with directories and stuff you should use this cabal package:
https://hackage.haskell.org/package/directory
>>
>>57360414
depends, is your app aimed towards running on lemons?
>>
>>57360190
You're wrong.
>>
>>57360370
I think the 2nd for loop makes sense. so it keeps going in the string until reach the "\0" in the array. Now I just find the hex->decimal. i love you. :))
>>
>>57360471
Sorry, I wasn't really paying attention at all to what you typed, I know how to use getargs, which is fine for small programs, but I want to use a more advanced parser for when i have arguments in the tens
>>
>>57360467
Why are you using "false" instead of False?
>>
>>57360476
>>57360414
Performance isn't a problem. The game doesn't draw or have a logic loop that runs in real time, it uses a standard command line style input output pattern. I guess its going to be tiny no matter what I use so I shouldn't worry about it.
>>
>>57360502

you can do folds with changes, and then have a function recognise specific args, e.g.

myFun state [] = state
myFun state ("-sf":x:xs) = myFun (state { f = x }) xs
myFun state ("-asdf":y:z:xs) = myFun (state { a = read y, b = y ++ z }) xs

then have a default state and pass it in

then you have all your args in a record
>>
>>57360442
If your professor is Indian. Change your program as much as you can. Make it smaller. Runtime cost is literally a shorter shift, and on a turing machine, likely no cost at all. Ultimately it all runs on the basis of an int and that's what makes it easy for Indians to use the common way to trap people into a sort of mode of thought. It begins by selling something as general and then introducing common errors that only they can fix, based on a patent of sorts. In the case of programming, you live around these machines and algorithms and eventually it becomes embedded in the culture. If your family or type can live more comfortably than another, yours becomes prevalent and desirable. If you keep this up, you can charter higher ground this way and come to find that only your manner sells well, as it's more comfortable, and then you can start allowing your culture to embed itself over certain more practical manners as opposed to more "modern" ones.

At this point, ignorance is bliss becomes the norm and the less people know the better, which usually denigrates into more stupid people and less for the developers of said device to worry.

Sadly, everything uses Indian programmers so we're stuck with people coinciding a precipice of incompetence for as long as the current indian family can continue to provide remediation.
>>
>>57360502
>>57360548
Is this what you wanted?

https://hackage.haskell.org/package/base-4.9.0.0/docs/System-Console-GetOpt.html
>>
>>57360467
def is_valid_digit_group(m):
for a in m.split():
if a.count("0") > 1:
return False
elif a.count("0") == 1 and (a.count("*") != 0 or a.count("|") != 0):
return False
elif a.find("*|") != -1:
return False
elif a.count("*") > 4:
return False
elif a.count("|") > 3:
return False
return True

Python can loop over arrays for you; you don't need to keep track of an index.
>>
>>57360414
You can save space, but like you said it may actually cost more time to do arithmetic. Usually, wherever there is a time/space tradeoff you want to optimize for time. The one big case where you want to optimize for space is when you have lots and lots of items stored contiguously and you want to reduce the number of cache lines that need to be loaded from main memory. Though in the end that is to improve the running time.

I'm not counting things like serialization to a file/database/network, obviously you want to optimize for space there.
>>
>>57360414
What matters is that you are optimizing for your cache line. Making space for datatypes wont matter if you're referencing array elements that are all over the place.
>>
>>57360638
I don't need you to hold my hand through it and I'm not the other anon buuuuut... how does one optimize for the cache line. This might be the first time I've encountered that premise...I can handle a not so step by step approach if it makes explaining a little more intuitive for you.

I reallly don't want to google this question. I don't do stack exchange for a reason.
>>
>>57360700
If you're using C# then you don't worry about it because it's mostly out of your control and not a bottleneck.
>>
>>57360710
Cool, but are you the same anon? I could bot be using C# if it meant actually doing something. C# right now is too loud.
>>
>>57360725
I'm >>57360635.
>>
>>57360619
yeah, it's just there's getopt, cmdargs, optparse-applicative and more, I dunno any of the pros or cons of others
>>
>>57360150
Post the actual link, you autist.

pastebin.com/cgZ5r8Jk
>>
>>57360700
Essentially, when memory is being read for something, the CPU also grabs the memory near what you're reading and throws it into the cache. So what you want to be doing is making sure that when your program is reading data that subsequent reads go to the cache rather than all the way to your main memory. Makes sense if you're iterating over an array of integers, but it gets complicated with OOP because a lot of the time in OOP you're grabbing arrays of objects and then taking just one object from them etc.

Also, ordering of variables matters. If you order by type having the largest datatypes first (in terms of bytes) and smallest types last, your data will be better packed together. There's some information on how that works here
http://www.catb.org/esr/structure-packing/

This is a good talk on the subject
https://www.youtube.com/watch?v=rX0ItVEVjHc&feature=youtu.be
>>
File: 1416411920709.gif (2MB, 533x300px) Image search: [Google]
1416411920709.gif
2MB, 533x300px
What's the common pitfalls to using std::threads and copy constructors together in C++? Because everything is good until the method that I'm threading (which takes in a deep copy of a class) tries to call another method, at which point it promptly crashes.

Basically want to write a series of images but since the write time for the images is so long, I wanted to have threads do the writing separate from the main AND have to deep copy the class that holds the image memory so i can delete the image memory later.

The main thread constantly writes over a single image, then i want to pass a copy of the image (once I've finished writing that image) to a thread that then writes in to disk, if that makes sense.
So the main thread creates a write thread whenever there is a image to write atm, I wanted to get the basic concept done before looking at further control/thread pooling, etc.
>>
>>57360873
Ah okay, you mean heading the retrieval since the processor doesn't grab for such specific values and rather grabs and next prime indicant. If the pull for a 1023 byet string comes after a 1024 pull, it'll use 1024 config because `why add a step there`. Gotcha! And I do this already. The problem with that is that it creates bog points in the progression where the background noise can seep through. Thank you, though. It makes perfect sense.

I really don't like background noise. It seems to counteract the idea that we don't run internet machines and have personal computers. I know I didn't add that noise. Who did?
>>
>this autist using memechan again
>>
>>57360956
*PANIC*
>>
So I understand how to populate an array recursively with a tree's preorder traversal, but how can I do the same for it's post order traversal? I can't just make it return (*a++ = pre->data); can I?

int *preCheck(node *node, int *arr)
{
if(node)
{
arr = preCheck(node->left, arr);
*arr++ = node->data;
return preCheck(node->right, arr);
}
else
return arr;
}


sorry in advance for asking stupid questions.
>>
My Program found this pastebin full of usernames and passwords. Anyone can think of what it might be for?
pastebin.com/bweNWdjT
>>
>>57361150

ROBLOX
>>
>>57361150
>wowthisischeap:wishyouluckonscammingthosekidslol
>>
>>57361161
I see a bunch of usernames and passwords that relate to a couple games including Wow, roblox and runescape so it probably isn't roblox.
>>57361179
It isn't my pastebin, I just found it.
>>
Anyone know of some good books/tutorials for setting up a game engine using OpenGL? I literally cannot even into code structure.
>>
>>57361150

I like these:
>fuck you scammer:fuck you scammer noob stop scamming people
>STOPSCAMMINGFAGGOT:SUCKABIGBLAXCKPENISTYOUMONGO
>HaHaYou_Scammer:mymomsaysno
>kysnub:faggotassaccountstealer
>Tmanssome:imnotgivingyoumyaccount
>>
>>57361208
see>>57361185
>>
>>57361185
i was pointing out the funny ones like ruby chan
>>
>>57359334
>Rubyist
>>
>>57361150
they work
>>
>>57361241
>>57361208
Im a fucking retard, I thought you were being sarcastic and making me look like a dick. Didn't realize those were real usernames. So I guess what happened is someone told kids to email them usernames and passwords and they would give them something. So most likely roblox or runescape
>>
>>57361201
gameenginebook.com

Not OpenGL specific but if you're not retarded it's the best resource you'll have.
>>
>>57361284
Yeah I got that you interpreted it as me showing you as the scammer, you're too hard on yourself tho, shit happens x
>>
>>57361309
No, I am a fucking retard, let me self loath. Also it is roblox accounts. one of the accounts worked for me.
>>
>>57361150
>I AM F***ING REPORTING YOU BECAUSE ON DPD LICENSED DRIVE I WANTED A QUICK TALK THEN YOU KICKED ME AND WHY DID THAT GUY WHO ADMIN ABUSED GET HIS F***ING RANK BACK HE DID IT WITH ME AND I AM REPORING YOU BECAUSE YOUR A TIGHT,MEAN AND YOU KEPT KICKING ME ON DPD:LD WHEN I ONLY WANTED A QUICK TALK
WHAT YOU DIDNT ACCEPT.HOWEVER,THE KID WHO ABUSED WITH ME GOT HIS RANK BACK AND HE SAID I WILL GET
MY RANK BUT I DIDNT.ONE LAST THING,I AM 5 AND YOU UPSET ME SO BAD MY MUM WILL BAN ME FROM PLAYING ROBLOX AND ITS ALL YOUR FAULT SO THX SO MUCH FOR BANNING ME.NOT.


I WILL NEVER LIKE YOU NOW.
>>
>>57361333
At least you're a fucking one I guess, would be cooler if it was paypal or something
>>
>>57361368
5 year olds shouldnt be allowed on the internet
>>
Any anon come in over the past hour and know how to lisp? I'm about done with this garbage assignment, I just need a little push to get me over the goal line.
>>
File: histogramplan.png (11KB, 744x412px) Image search: [Google]
histogramplan.png
11KB, 744x412px
>Exercise 1-13: Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orientation is more challenging
I can't figure out how to make the vertical one. I already deleted an abortion that didn't work so I'm starting from scratch.
I drew pic related and got
int i, y;
for (i = 0; i < biggestlength; ++i) { //Loops the amount of times required to print the biggest vertical bar on the histogram
for (y = 0; y < wordcount; ++y) { //Loops as many times as there are words to print the blocks on the histogram
if (wordarray[y] >= (biggestlength - y)) //Length of the word greater than or equal to longest word minus the distance from the top of the histogram
putchar(254); //254 is the value of the ASCII square character
else
putchar(' ');
}
putchar('\n');
}


from it, but that's exactly the same thing I wrote last time. Am I on the right track at least?
>>
>>57361404
Wait I just realized the fucking distance from the top of the histogram is biggestlength - i not biggestlength - y fuck goddamn.
>>
>>57361305
I'll look into it, thanks.
>>
>>57361404
>254 is the value of the ASCII square character
No it's not.
ASCII only goes up to 127.
>>
New thread:
>>57361528
>>57361528
>>57361528
Thread posts: 326
Thread images: 13


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