[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: 324
Thread images: 31

File: 1466890554900g.jpg (2MB, 1346x2002px) Image search: [Google]
1466890554900g.jpg
2MB, 1346x2002px
/dpt/ - Daily Programming Thread

old thread: >>56061461

What are you working on, /g/?
>>
>>56065832
First for D
>>
>>56065832
thank you for not posting a fag thread
>>
>>56065842
third for feminine d(ick)
>>
Let's continue the constructive debate on the merits of Haskell from the previous thread.

Some norsk-posting would be nice too.
>>
>>56065832
Working on converting every drop of my PHP knowledge into Node
>>
>>56065867
>>56065832
Anime is cancer. Good to see a thread without it.
>>
>>56065903
That's like going from pig shit to horse shit.
>>
>>56065832
>tfw i have all more than 100 photos of this girl
>>
How do I build website backends?

I don't want to learn JS.
>>
>>56065746
From my understanding the algorithm checks if the last solution can be improved/minimized with the respective sum of A[i]+the B values.
(C[n]>sum)
And in that case we know that there might be more values in the interval a[last],b[last] that could be improved.

In Figure 1 we then look start looking from j=n-1 down to a[last] for the first j where C[j]>sum and update the intervals accordingly.

Which of course brings the runtime up to O(n^2)

In Figure 2 we only check if C[j]>sum is true for a[last] and the paper argues:
Note that if C[j]>sum holds for j = a[k] for some
k, it follows from Observation 1 that this inequality also holds for all j > a[k]. Hence, it is sufficient to check this condition for all starting points a[k] of non-empty intervals.

This check however, can never be true as j (at least when calculating it as in the pseudocode on Figure 2) is < i meaning that there is no sum for C[j] that would start with A[i].
>>
>>56065915

Granted, but F# has always been the 'oh camel'ly red-haired step child of the .NET family. C# is where the real action happens.
>>
File: 1460197539579.png (260KB, 600x800px) Image search: [Google]
1460197539579.png
260KB, 600x800px
>>56065884
>merits of Haskell
>>
File: 1454534273426.jpg (49KB, 540x656px) Image search: [Google]
1454534273426.jpg
49KB, 540x656px
>>56065832
>3dpd
>>
>>56065927

Understanding is a amazing skill to develop. People started shitting on haskell due to a build up of annoyance due to the constant haskell elitism and constant push to convert others to haskellism.
>>
>>56065977
It's for their own good. Countless developers are wasting their lives fighting against limited, crippled languages and tools.
>>
>>56065942
Seems an improvement to me.
Whats the back-end-lang approved by /g/ if not Node.js? Perl?
>>
>>56065967
Much better than weabshit
>>
>>56065977
And then anti-Haskell shitters have nothing but memes, leading to the clusterfuck we had last thread. Which then leads to
>WE DINDU NUFFIN, DOSE MEAN HASKELLERS KEPT DEFENDING THEIR LANGUAGE
>>
>>56065932
W-what? I forgot a ' and was bothered by it but it's not that big a deal.
>>
About a bit more than 15% done implementing the C Standard Library. Shit's fun. I need to refresh on the Taylor expansions for trigonometric functions before I tackle math.h though.
>>
>>56065746
>>56065746
>>56065746

here's my take in python

inf = 99999999999
def calculate(n, lst):
a = 0
for i in range(n):
a += lst[i]
return a

c = []
for j in range(n):
c[j] = A[1] + calculate(j, B)

a[1] = 1, b[1] = n, pred[1] = 0
last = 1
for i in range(2,n):
if C[n] > A[i] + calculate(n-i, B)
b[i] = n
j = a[-1]

while C[j] > A[i] + calculate(j-i, B) and j >= i:
C[j] = A[i] + calculate(j-i, B)
a[-1] = inf, b[-1] = inf
last = pred[-1]
j = a[-1]
if j >= i:

## not sure what write here
## probably write a helper bin search function
## to find the lasrgest value j

else:
b[-1] = i-1, a[i] = i
pred[i] = last
last = i
else:
a[i] = inf, b[i] = inf
>>
desu, I would probably learn Haskell if I were truly smart enough for functional programming and had even the most basic grasp of what a proper type system looked like.
>>
>>56065884
>Normann brevning
>dkn ditt språk inte är ett jag-jag
>>
>>56066041
That's pretty nifty, what sections do you have completed so far?
>>
>>56065996

You're using haskell as a tool to satisfy your ego. Because you are using haskell you perceive yourself as better than the "countless other developers" who follow a different route. You think your truth is more valid than the truth of another.

Arguments and viewpoints formed of purely ego only attract strife and violence.
>>
>>56066041
You shouldn't use Taylor series for trig functions. Consider Chebyshev polynomials instead, they are more efficient.
>>
uncurry (++) . partition (9 /=)


Just look at this oh my GOD it's so fucking beautiful I can't even believe something this pure could exist in our plane of existence.
>>
>>56066068
I'm going in order as according to
https://www-s.acm.illinois.edu/webmonkeys/book/c_guide/index.html

Just finished float.h
>>
>>56066089
that line calls 10000 lines in the background.

lmao
>>
>>56066089
And what does it do?
>>
>>56066069
I'm using Haskell because it lets me write correct code faster. I have used mainstream languages and found them all wanting.
>>
>>56066077
Thanks! I'm a bit rusty on the maths.
>>
>>56066101
I think you're missing the point of high-level languages.
>>
>>56066041
Any specific reason you are doing your own implementation?
>>
>>56066102
It monoids your types into higher lambda calculus applicative functors. Trust me it's extremely useful and anyone who programs in a language without equivalent capabilities is basically a literal retarded baby playing with blocks.
>>
>>56066111

That is fine. However, it does not conclusively prove the languages you found wanting are not the best language for others to use. It also doesn't excuse calling anything or anyone not using haskell "wasting life" or "crippled" and ardently trying to push others into your "truth".
>>
>>56066048
Looks very similar to what I have, probably wouldn't work either though. See: >>56065948

   aux[0] = B[0];
for(int i=1;i<n;i++) {
aux[i] = aux[i-1] + B[i];
}
for(int j=1;j<=n;j++) {
C[j] = A[1] +aux[j-1];
}
}
uint32_t last = 1;
a[1] = 1;
b[1] = n;
pred[1] = 0;
int j = 0;
for(int i=2;i<n;i++) {
if(C[n]>A[i]+aux[n-i]) {
b[i]=n;
j = a[last];
sum = A[i];
}
while(C[j]>A[i]+aux[j-i]&& j>=i) {
C[j]=A[i]+aux[j-i];
a[last] = UINT32_MAX;
b[last] = UINT32_MAX;
last = pred[last];
j=a[last];
}
if(j>=i) {
uint32_t start = a[last];
uint32_t end = b[last];
uint32_t middle;
while(start<=end) {
middle = (start+end)/2;
if(C[middle]<=A[i]+aux[middle-i]) {
start = middle+1;
} else {
end = middle-1;
middle = middle-1;
}
}
b[last] = middle-1;
a[i] = middle;
} else {
b[last] = i-1;
a[i] = i;
}
pred[i] = last;
last = i;
}
else {
a[i] = UINT32_MAX;
b[i] = UINT32_MAX;
}


Binary Search is still untested and wrong maybe
>>
>>56066164
Well memed my dude
>>
>>56066176
I said that the languages they use are crippled, not that they themselves are crippled. I see so much boilerplate in other languages that would not have had to be written in Haskell, and it is deeply dispiriting.
>>
>>56066162
I find Xinu's library is rather unfit for how I want to implement my OS.

Going for the ultimate goal here folks,
An os running on hardware I designed under an ISA I've designed. The OS is written in a language I designed and compiled in a compiler I wrote and then ported to build in that language itself. I want a self hosted-everything. Except for maybe fabrication. I'm horribly clumsy with small things.
>>
>>56066003
Assembly
>>
this thread is so fucking retarded, it's even funny
fucking autists, top kek
>>
>>56066188
aux[0] = B[0];
for(int i=1;i<n;i++) {
aux[i] = aux[i-1] + B[i];
}
for(int j=1;j<=n;j++) {
C[j] = A[1] +aux[j-1];
}
uint32_t last = 1;
a[1] = 1;
b[1] = n;
pred[1] = 0;
int j = 0;
for(int i=2;i<n;i++) {
if(C[n]>A[i]+aux[n-i]) {
b[i]=n;
j = a[last];
while(C[j]>A[i]+aux[j-i]&& j>=i) {
C[j]=A[i]+aux[j-i];
a[last] = UINT32_MAX;
b[last] = UINT32_MAX;
last = pred[last];
j=a[last];
}
if(j>=i) {
uint32_t start = a[last];
uint32_t end = b[last];
uint32_t middle;
while(start<=end) {
middle = (start+end)/2;
if(C[middle]<=A[i]+aux[middle-i]) {
start = middle+1;
} else {
end = middle-1;
middle = middle-1;
}
}
b[last] = middle-1;
a[i] = middle;
} else {
b[last] = i-1;
a[i] = i;
}
pred[i] = last;
last = i;
}
else {
a[i] = UINT32_MAX;
b[i] = UINT32_MAX;
}
>>
>>56066188
>uint32_t last
wew lad, just use size_t both for last and all i,j loop variables
>>
>>56066231
Thats what an underage btard would have replied
Mind giving a serious answer?
>>
>>56066274
learn Go
>>
>>56065944
any lewds?
>>
>>56066003
machine language
>>
>>56066282
>Go, created by Google
nice try FBI
>>
>>56066224
Damn, good luck my lad, that's quite the undertaking
>>
>>56066270
Wew lad. Everyday I learn something new
>>
>>56066220

Isn't wasting life the same as being crippled? Both imply inability to live up to full functionality.
>>
>>56066154
I'm not that guy but I am missing the point. But really is there a situation where you can come up with this short piece of code, be amazed by it this much without it having taken you a lot of time already? Give me a picture of how much it's saving you.

There's also the issue of your users time being spent processing things unnecessarily, wasting energy etc. Is your software really usable if this kind of code would generate thousands of lines of code? Surely you're not doing such incredibly trivial stuff that you never run into performance issues.
>>
>>56066316
I have parts of each task a good part done.
I rotate the sub-projects so it doesn't get dull ever. I think I'll have it in about 5 years.
>>
>>56066003
Just use a C++ webbackend framework. Like Facebook.
>>
>>56065944
>>56066293
Anon asked
>any lewds?
>>
File: as.png (733KB, 1196x662px) Image search: [Google]
as.png
733KB, 1196x662px
>>56066293
>>
>>56065944
Her name is Mandy you filth. You aren't high class enough to lay eyes on her. None of you are.
>>
>>56066364
nooice
>>
What's your favorite language feature of any language?
>>
>pinky hurts
>keep going
>middle of palm hurts
>fearing SRI
What do?
>>
>>56066392
booleans
>>
>>56066331
I think in terms of high-level combinators. If I am using a language that does not support them, I must then transcribe the code. It is much quicker for me to write in Haskell and avoid any need for transcription.
>>
>>56066392
Type classes are pretty cool, nice way of fine-tuning how generic you want a function to be.
>>
Trying to make a snake game, trying to store the snake as efficiently as possible. Outside of that everything is pretty easy.
>>
>>56066420
donate to stemcell research
>>
>>56066310
retard

>>56066364
>imgur
link to the gallery?
>>
>>56066445
just store the snake on the actual map, and when the snake moves, move the tail cell to where the cell of the head moves to.
>>
>>56066474
reverse image search OP's pic
>>
>>56065295
>>56065568
>>56065746
>>56065948
>>56066254

Bump on this question chain
>>
File: sampleScan2.png (151KB, 1920x1080px) Image search: [Google]
sampleScan2.png
151KB, 1920x1080px
>>56065832

who wants to see what I came up with since the thread with Rob Schneider
>>
>>56066053
meh, just learn F# if you're already on .NET
>>56066392
i really do like row polymorphism, since it seems to clean up so many of the "problems" with static types. like you can get rid of all the boilerplate that even plain HM type inference won't give you (you still have to define types or classes). plus, it lets you reuse labels for records or sum types which is pretty cool.
one of the really cool things you can do with it is create nanopass-style compilers without having to define the types all over again for each pass (and that actually lets you write shorter code than the equivalent Scheme code)

the best feature is still probably macros, though, because you can basically implement anything else with them
>>
>>56066102
Shuffles all the 9s in a list to the end.

partition
filters a list into two lists: one whose elements satisfy the given predicate and one whose don't.

uncurry
turns a function of two arguments (here list concatenation (++)) into a function of one pair.

(.) is function composition,
(f . g) x = f (g x)
>>
>>56066474
>link to the gallery?
i only have links to individual photos, not gallery or album.

i run a python script to download all photos
>>
File: sampleScan2chunked.png (21KB, 800x600px) Image search: [Google]
sampleScan2chunked.png
21KB, 800x600px
>>56066502

r8

def getChunks(spawns):  
iterations = 5
def chunks(spawns):
maxDistance = .250
foundIndexes = []
output = []
for i in range(0,len(spawns)-1):
found = []
for j in range(0,len(spawns)-1):
skip = False
if j not in foundIndexes:
d = getDistance(spawns[i]["latitude"],spawns[i]["longitude"],spawns[j]["latitude"],spawns[j]["longitude"])
if d < maxDistance:
found.append({"latitude":spawns[j]["latitude"],"longitude":spawns[j]["longitude"]})
else:
skip = True
if found:
newPoint = avg(found)
output.append({"latitude":newPoint[0],"longitude":newPoint[1]})
foundIndexes.append(j)
elif skip:
output.append(i)
return output

bigout = spawns
for i in range(0,iterations):
length = len(bigout)
bigout = chunks(bigout)
if len(bigout) == length:
break
return bigout
>>
>>56066492
>Milf
This is mislabeled surely. She doesn't look old enough to classify as milf.
>>
>>56066480
The thing is I'm trying to do it like the atari would have done.

The atari 2600 had 128 bytes of memory and the Surround game had a playing field that's 18x33.

I doubt they stored the snakes as matrices.
>>
>>56066503
Sounds a bit memey desu (claiming it solves almost all your problems) but I'm interested
>>
>>56066508
wow so elegant muh monads lol xdDDD
>>
>>56065944

> girl
>>
>>56066561
>The atari 2600 had 128 bytes of memory and the Surround game had a playing field that's 18x33.
What were the cartridge size on these? That sounds like the far more interesting statistic.
>>
>>56066566
It doesn't use monads.
>>
>>56066536
>for i in range(0,len(spawns)-1):

do you know that range starts at 0 by default?
>>
>>56066558
might be have lil kids, i'm guessing she's in her early thirties
>>
>>56066566
Now blame Haskellfags for being so pretentious that they forced you to make that post
>>
>>56065977
> People started shitting on haskell due to a build up of annoyance
People who shit on Haskell (and FP generally) do so mainly because they'd prefer to believe that they understand "programming" rather than "imperative programming".

It's important to note the distinction between criticism and "shitting on". And it's rarely all that hard to determine which is at play.
>>
>>56066579
here's your reply, you attention seeking faggot
>>
>>56066597
I assumed she's younger than me and I'm 23.
>>
>>56066503
>meh, just learn F# if you're already on .NET

I should.
>>
>>56066591
The game carts had 4kb of ROM, so there's no way they were swapping between that and the main memory to store the snakes.
>>
>>56066579
Proof?
>>
>>56066561
Ah, you meant efficient regarding space rather than time. Definitely just an array of the coordinates of the snake's cells and then the direction of the snake; I don't think there is a different way.. Shoving the entire array every frame seems horrible, so I may be wrong.
>>
File: not compatible.jpg (518KB, 1500x1553px) Image search: [Google]
not compatible.jpg
518KB, 1500x1553px
So i have these two functions written in Java and i'm looking for PHP implementations for both such that data can be encrypted/decrypted by both PHP and JAVA interchangeably.
private static Pattern PEMDecoder = Pattern.compile("\\s*-+[A-Z\\s]+-+\\s*([A-Za-z0-9+\\/=\\s]+)-+[A-Z\\s]+-+\\s*");
public static String encrypt(String publicKey, String data) throws Exception {
Cipher cipher = Cipher.getInstance("RSA");
Matcher m = PEMDecoder.matcher(publicKey); if (!m.matches()) throw new Exception("Invalid key.");
byte[] bytes = Base64.getDecoder().decode(m.group(1).replaceAll("\\s+", ""));
cipher.init(Cipher.ENCRYPT_MODE, KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(bytes)));
return DatatypeConverter.printHexBinary(cipher.doFinal(data.getBytes(Charset.forName("UTF-8"))));
}
public static String decrypt(String privateKey, String encrypted) throws Exception {
Cipher cipher = Cipher.getInstance("RSA");
Matcher m = PEMDecoder.matcher(privateKey); if (!m.matches()) throw new Exception("Invalid key.");
byte[] bytes = Base64.getDecoder().decode(m.group(1).replaceAll("\\s+", ""));
cipher.init(Cipher.DECRYPT_MODE, KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(bytes)));
return new String(cipher.doFinal(DatatypeConverter.parseHexBinary(encrypted)), Charset.forName("UTF-8"));
}


>>56063991
The only library i found is phpseclib which is extremely slow and gives me decryption errors if i try to decrypt a cipher encrypted with java.
Pic related.
>>
>>56066655
>Using Java when glorious Haskell exists
Really ate to see your potential go to waste like that.
>>
>>56066520
http://www.imagefap.com/photo/1079700765/

You are now my bitch.

Make me a sammich,bitch
>>
>>56066565
it doesn't solve everything really, but it's a nice way of making statically typed code a lot closer to the dynamically typed version
you can just introduce new data structure in your code without defining them (the same way you can write new data structures using objects in javascript).

function f(x, y, z) {
return {a: x, b: y, c: z};
}

is like
let f x y z =
{a = x; b = y; c = z}


you can use that to perform what's essentially structural subtyping in OOP code, so say you could have two types that are subtypes of an interface you never defined:
class X = object
method greet = print_endline "Hello!"
end

(* In Java, this would have a different type than X, so you can't use them without declaring an interface
or base class and having them extend or implement it *)
class Y = object
method greet = print_endline "Howdy!"
method greet_person name = print_endline ("Hi, " ^ name)
end

let f o = o#greet (* Calls the greet method on any object *)

so in the above code, you could use the two different classes interchangeably for the function f because they define the same methods
>>
>>56066679
>falseflagging
>>
>>56066595

> iterations = 5

Do you know it still would have executed if I didn't have spaces around the =?
>>
>>56066680
you can reverse image search!

wow. want a cookie?
>>
>>56066715
Except unnecessarily passing 0 actually changes runtime.
>>
>>56066640

check her blog
>>
>>56066649
> Definitely just an array of the coordinates of the snake's cells
Woefully inefficient, given that the snake's cells must be contiguous.

Given the position of the head, the adjacent cell can only be at one of four positions. For each of the remaining cells, there are at most three positions.

So you can easily get it down to the position of the head plus two bits per cell. With a bit of effort, you can get it down to log[2](3)~=1.585 bits per cell (so 20 cells in a 32-bit word: 3^20<2^32).
>>
>>56066776
Neat!
>>
>>56066744
Yes.

Now you don't know what to do eh?
>>
So after some more Snake research it appears that the earliest Snake games just grew the snake by the blocks the head had visited.

Only later games grew the Snake grew the snake by how much food it had consumed. So it's possible that the Snake was stored as a matrix.
>>
>>56066883
what do you mean?
>>
how are you even supposed to use random libraries? most of the time it's more effort to figure them out than to just write them yourself

>
Eigen::Vector3d p_EB_E2n_EB_E( const Eigen::Vector3d& p_EB_E, const double& a, const double& f )  {

double a2 = a*a;
double e2 = 2*f - f*f;
double e4 = e2*e2;

double q = ( ( 1 - e2 )/a2 )*p_EB_E(2)*p_EB_E(2);
double p = ( p_EB_E(0)*p_EB_E(0) + p_EB_E(1)*p_EB_E(1) )/a2;
double r = ( p + q - e4 )/6;
double s = e4*p*q/(4*r*r*r);
double t = cbrt( 1 + s + sqrt( s*( 2 + s ) ) );
double u = r*( 1 + t + 1/t );
double v = sqrt( u*u + e4*q );
double w = e2*( u + v - q )/(2*v);
double k = sqrt( u + v + w*w ) - w;
double d = k*sqrt( p_EB_E(0)*p_EB_E(0) + p_EB_E(1)*p_EB_E(1) )/( k + e2 );

double scalar = 1/( sqrt( d*d + p_EB_E(2)*p_EB_E(2) ) );

Eigen::Vector3d n_E;
n_E << scalar*k/( k + e2 )*p_EB_E(0),
scalar*k/( k + e2 )*p_EB_E(1),
scalar*p_EB_E(2);

n_E.normalize();

return n_E;
}


NVectorPosition p_EB_E2n_EB_E_and_z_EB( const Eigen::Vector3d& p_EB_E, const double& a, const double& f ) {

double a2 = a*a;
double e2 = 2*f - f*f;
double e4 = e2*e2;

double q = ( ( 1 - e2 )/a2 )*p_EB_E(2)*p_EB_E(2);
double p = ( p_EB_E(0)*p_EB_E(0) + p_EB_E(1)*p_EB_E(1) )/a2;
double r = ( p + q - e4 )/6;
double s = e4*p*q/(4*r*r*r);
double t = cbrt( 1 + s + sqrt( s*( 2 + s ) ) );
double u = r*( 1 + t + 1/t );
double v = sqrt( u*u + e4*q );
double w = e2*( u + v - q )/(2*v);
double k = sqrt( u + v + w*w ) - w;
double d = k*sqrt( p_EB_E(0)*p_EB_E(0) + p_EB_E(1)*p_EB_E(1) )/( k + e2 );

double scalar = 1/( sqrt( d*d + p_EB_E(2)*p_EB_E(2) ) );

Eigen::Vector3d n_E;
n_E << scalar*k/( k + e2 )*p_EB_E(0),
scalar*k/( k + e2 )*p_EB_E(1),
scalar*p_EB_E(2);

n_E.normalize();

NVectorPosition position;
position.n_EB_E = n_E;
position.z_EB = -( k + e2 - 1 )/k * sqrt( d*d + p_EB_E(2)*p_EB_E(2) );

return position;
}
>>
What's the way to do simple timers in a game? I was thinking of just calling GetTime() and checking if the amount of time passed was more than the amount of time I needed the code to run.
>>
r8 my code, im learning java
its a thing that calculates square root
public class MySqrt
{
public static void main(String[] args)
{
if (args.length < 2) {
System.out.println("Useage: java MySqrt NumberToFindSquareRootOf StartingGuess");
System.out.println("To show number of iterations use -i");
System.exit(1);
}
double n = Double.parseDouble(args[0]);
double guess = Double.parseDouble(args[1]);
boolean showIteration = false;
if (args.length == 3 && args[2].equals("-i")) {
showIteration = true;
}
if (guess <= 0) {
System.out.println("StartingGuess must be greater than zero");
System.exit(1);
}

double diff = 0.0000000000000000001;
double last_guess = 0;
int i = 0;
while (Math.abs((guess-last_guess)) > diff) {
last_guess = guess;
guess = 1.0/2.0*(guess+(n/guess));
if (showIteration) {
System.out.print("iteration number " +i+ ", ");
System.out.println("sqrt("+n+") = "+guess);
}
i++;
}
System.out.println(guess);
}
}

>>
>>56066655
Nevermind, figured it out.
>>
>>56067140 Question is kind of ambiguous, but that's usually the best way.
>>
Anyone here good with MongoDB? I'm designing a simple recipe app. Each recipe has many ingredients. only thing that is tripping me up is attaching a quantity to each ingredient - would it be better set up as a subdocument instead of below? Anyway, feedback appreciated.

recipe.js

var recipeSchema = mongoose.Schema({
name: String,
ingredients: [{type: Schema.Types.ObjectId, ref: 'Ingredient'}],
});


ingredient.js

var ingredientSchema = mongoose.Schema({
name: String,
quantity: Number,
description: String
});
>>
>>56067404
Up until now, I had always been creating an int and subtracting from it every frame, but I realized with delta times and differences in hardware that it's probably not the best method.
>>
Monads are triples
>>
I vote mods ban everyone in this thread and delete it.
>>
File: c_chan.png (45KB, 621x755px) Image search: [Google]
c_chan.png
45KB, 621x755px
creating a mongolian basket weaving forum in C

anyone know of good way to do file i/o for this?
the board is a linked list of threads and the threads are linked lists of posts
>>
>>56068043
You aren't the guy from yesterday who was doing the same thing, but he was using a database. Using a DB is the better way to do this, but if you don't know how don't sweat it.

Why linked list? If you used an array then the text for each post could be stored contiguously in memory, making access much faster. Using a linked list means that the posts won't be guaranteed to be contiguous, because the pointer to the next post could point anywhere in memory.

A dynamically sized array would be the faster option for both. Then IO is much easier, you can just push out the whole array to a file. As it is, you will have to concatenate every single post/thread together.
>>
>>56068043
that's actually cool as shit dude

make a coloured TUI
>>
why is it called a shebang line?
>>
>>56068157
shebang = #!
# she
! bang
#! shebang
>>
>>56068157
shebang = #!
hash = #
bang = ! (I don't know why)

Let's scripts become "real" executable files to the os, if the os reads those first two bytes as #!
>>
>>56068109
i'll be honest, it's an assignment for my data structures class , of course using a DB makes a million times more sense.
I have to write and read from a file but i'm not really sure how to structure it. I'm guessing use some sort of delimiter and loop through the whole file

>>56068113
thanks breh
can you add colors to console?
>>
File: tuturu.jpg (63KB, 1280x720px) Image search: [Google]
tuturu.jpg
63KB, 1280x720px
>>56065832
>3DPD
Absolutely disgusting, just post a picture of Battlestation or something you fucking faggot
>>
>>56068259
Depends, do they want you to design a nice data structure for the file as well? In which case you probably want to have you internal linked list output as a XML/JSON. But if that's not important, I guess you could just write out a binary file (minus the pointers) and set the pointer using malloc when you read back in.
>>
>>56068259
You can, but on Windows it doesn't work well, so don't bother. cmd.exe doesn't support the nice escape codes that GNU/Linux terminal emus do.
>>
>>56068275
>posting worstgirl

kys fagt
>>
>>56068343
>watching anime
>>
>>56068259
look up curses i think it's called
>>
implementing a CHIP-8 interpreter. should note that this is the first time I've ever fooled around with anything like this or anything similar to this.

stuck right away. so I initialize everything (registers, etc...) which is trivial. now I'm trying to pass tests for the first instruction - storing a constant into a register. so, the opcode is passed to an execute function...then what? surely, I can just parse out the destination and the value and then set the correct register. easy.

but how do I deal with invalid input? what about eventually supporting all the instructions? how do I design my execute function without a huge switch statement or a series of if-else statements? I don't want it spoonfed to me, but at the same time I'm completely clueless as to how to design this in a clean way.
>>
File: CubeBlob example big.gif (2MB, 800x600px) Image search: [Google]
CubeBlob example big.gif
2MB, 800x600px
>>56065832
Just for fun...
>>
>>56068414
I'm inexperienced af, but from some chip-8 emu code I've flicked through, most seem to go the switch statement route for instructions.
>>
>>56068419
>that comeback from red at the end
>>
>>56066593
>It doesn't use monads.
>instance Monad [] -- Defined in ‘GHC.Base’
>>
>>56068424
couldn't I use some sort of lookup table or something?
>>
>>56068414
A basic chip8 interpreter is literally just translating all the instructions with a giant switch statement.

As for invalid input.. It literally doesn't exist if you follow the specifications for chip (16 key keyboard).

A alternative more complex route is implementing the cpu as a state machine and then translating the raw program into a series of state changes.
>>
>>56068445
types with monadic instances aren't monads on their own
>>
Someone posted a link a few days ago that explained shit like functors and monads really well, anyone have it?
>>
>>56068463
why?
>>
>>56068458
thanks.

I'm going to keep things nice and simple for now. The state machine route sounds like it's a little too much for my current skill level.
>>
typeclasses should replace OOP
>>
>>56068157
https://www.youtube.com/watch?v=9RrLQUN8UJg
>>
>>56067140
You typically want to measure time in elapsed ticks (update cycles) rather than "physical" time. This is more deterministic if you can't maintain a constant tick rate (e.g. if your game pauses for 1/10th of a second due to I/O access, you don't want your timers to expire 1/10th second earlier relative to everything else happening in the game).

But in general, you implement a timer by storing the expiry time. That way, if you have a million timers, you don't need to decrement a million counters every tick, you just need to update the global tick count. You store the timers in a list sorted by increasing expiry time so that you don't need to check each one each tick.
>>
>>56068475
http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
>>
>>56068502
Out of interest, what language are you using, and how good at programming do you think you are right now?
>>
>>56068542
Thanks my dude
>>
File: homer10.jpg (26KB, 293x313px) Image search: [Google]
homer10.jpg
26KB, 293x313px
>>56068275
Oh look, it's a virgin
>>
I tried and failed to make a greasemonkey script.

I've wanted to be able to flip through full images from search results for ages. (There's an android app to do that)
Can't easily debug.
// ==UserScript==
// @name Danbooru Slideshow
// @namespace danbooruSlideshow
// @description Slideshow for danbooru, kinda.
// @include https://*.donmai.us/*

// @version 1.4.1
// @grant none
// ==/UserScript==

pageHtml = '\
<div id="image-gal" hidden="false">\
<img id="current-image" src="">\
<p>test!</p>\
</div>\
<style type="text/css">\
#image-gal {\
position:fixed;\
z-index: 9001;\
background-color: rgba(0,0,0,0.7);\
}\
</style>'

images = []
display = document.getElementById("image-gal");
currentImage = document.getElementById("current-image");
imageIndex = 0;
document.body.innerHTML = pageHtml + document.body.innerHTML;

function changeImage(amount) {
imageIndex += amount;

if (imageIndex < 0)
imageIndex = 0;
if (imageIndex > images.length)
imageIndex = images.length;
displayImage();
}

function toggleSlideshow() {
//make sure we have a reference to the image display
if (display === null)
display = document.getElementById("image-gal");

//toggle the visibility of the gallery
display.hidden = !display.hidden;

updateImages();

}

function displayImage() {
display.src = images[imageIndex];
}

function updateImages() {
postClass = "post-preview";
postImageAttribute = "data-file-url";
posts = document.getElementsByClassName(postClass);
images = [];

//add all of the file links to the images array
for (var i = 0; i < posts.length; i++) {
images.push(posts[i].getAttribute(postImageAttribute));
}

displayImage();
}

document.onkeydown = function(event){
switch (event.key){
case "x":
case "ArrowRight":
changeImage(1)

break;

case "z":
case "ArrowLeft":
changeImage(-1)

break;

case "g":
toggleSlideshow();

break;

}
}
>>
>>56068549
Java, because it's the language I'm most comfortable in at this point in time.

and not too great, desu.
>>
>>56068492
because there are types that could have multiple monads. just like you wouldn't call the Int type the Int monoid (since you could define it in terms of + or *) it wouldn't make sense to think about the list itself as being a monad
>>
>>56068213
>>56068201
huh

so is the 'she' from some encoding or is that just the name people gave the #?
>>
>>56068690
it probably just comes from slurring "hashbang", the propert name for #!
>>
>>56066420
Stop using emacs.
>>
which one and why, /g/?

A
GtkWidget *new_grid()
{
GtkWidget *grid = gtk_grid_new();

return grid;
}


B
GtkWidget *new_grid()
{
return gtk_grid_new();
}
>>
>>56068693

The # character is a called an octothorpe, though.
>>
>>56068693
"shebang" is an existing word, and easier to pronounce than "hash-bang".
www.dictionary.com/browse/shebang
>>
>>56068593
ah cool cool. I'm trying to gague whether or not I have enough experience to even attempt an emulator at this point.
>>
>>56068735
The former because you're planning to write more between that gtk_grid_new(); or you shouldn't have written the function.
>>
>>56068790
Chip 8 is actually really easy. It's easier to write a Chip 8 emu than it is to actually write software for Chip 8.

Nice video from Bisqwit implementing a Chip 8 emulator (You'll need to be familiar with C/C++ though).
>>
>>56068740
> The # character is a called an octothorpe, though.
Of its many names, that's probably the least used. Outside of computing, "number sign" or "pound sign" are more common. In computing, "hash" is almost universal due to brevity.

The Unicode name is "NUMBER SIGN"; PostScript uses "numbersign".
>>
>>56068790
If I were attempting emulation I would probably study operating systems and their basic function seriously for a month (but then again, I never studied them at all so I'd be starting from the ground). I know berkeley has an online course or two dealing with that
>>
>>56068735
Second one.

>>56068740
No, it's called pound.
>>
>>56068835
>>56068865
Thank you both. I'll check out the Bisqwit video now. I'm actually taking a Computing course rn, so I have the basics of CPUs/registers/fetch-execute cycle down.
>>
>>56068865
Really you should focus on lower level concepts rather than operating systems. Stuff like assembly and computer architecture is more important than operating systems.

Especially for something like Chip 8, where there isn't even an OS on it.
>>
>>56068890
Be warned that Bisqwit sometimes uses an odd style of C++, and he doesn't program live in the videos. So you are basically required to pause the video regularly and actually think through what he's doing. If you just let it play live, it'll go past way too fast and you'll miss it all.
>>
>>56068835
>It's easier to write a Chip 8 emu than it is to actually write software for Chip 8.

That's true for a lot of things. Writing a brainfuck interpreter is almost trivial, but writing brainfuck software is almost impossible.
>>
>>56068862
>>56068875
>they don't say octothorpe

Fucking weirdos, the whole lot of you. No wonder you've ended up on 4chan.
>>
>>56068921
Yeah. Understanding and implementing what each individual Chip 8/Brainfuck instruction does is a really easy task, and writing a small interpreter that implements them is easy. But the understanding of how to chain those instructions together into actual programs is a much harder task.
>>
say i know c++ what things would i learn from c that c++ does not have
>>
>>56068921
>almost impossible
It's just a different kind of language, but it's not bad. You can just think of each cell as a register, and learn the essential functions and it's not half bad.
>>
>>56068989
Punctuation.
>>
>>56068989
C is weakly typed, so lot's of C code that doesn't require casts will require casts in C++.

But really there aren't many language features that C has that are missing from C++. What you will find challenging is that you probably don't know how to use those C language features in C++, you will be used to the C++ way of doing things.
>>
>>56068917
Yeah I just watched it. There's a lot of things I notice that I'm familiar with, but not enough to put into use (for example, he declares most of his variables as unsigned, but I'm not completely sure why. Just good practice as the stored value will never be negative?).
>>
>>56068989
A more sane programming practice.
>>
>>56069001

Writing something USEFUL, I mean.
>>
>>56069054
It's just a style thing. Some people like to use unsigned wherever there is no chance for it to be negative.

For something like "unsigned char", this is an oldschool way of declaring an 8 bit value. But size of char is implementation defined, so it's better off to use the modern fixed size ints. So in this case it would be better to use "int8_t" instead of "unsigned char".
>>
>>56069086
Yeah, probably. Although it's already hard enough to write anything useful in any language.
>>
>>56069129
>8 bit value
I mean like declaring a single byte, 0-255, 00000000-11111111
>>
>>56069145
8 bits is a byte my dude
>>
>>56069129
Ahh fuck, and you should use "uint8_t" for a byte, the u at the start means unsigned!
>>
>>56069129
Thanks for the explanation! I'm trying as best I can to keep up with modern standards while I'm learning C.
>>
>>56069160
In C, you'll find those typedefs in stdint.h, C++ should use cstdint.
>>
>studio dot h
>>
>>56069156
I know, I was just clarifying.
>>
>>56069212
this
>>
>>56069215
Oh, are you the same anon? It read like "No, not an 8-bit value, I want a single byte"
>>
>>56066655
>Eclipse
>Java
>Notepad++
>Shitfox

<- that's you btw
>>
>>56069353
You can't expect much from someone using Java for their own programs (not school or work)
>>
>>56065832
I'll make a php interpreter that runs on Go
>>
>>56065832
just boot into macOS and use the free iMovie, courtesy of Apple, the glorious software company.
>>
>GET login page
>POST login page with calculated login security checks in the form of a 25-variable dictionary
>GET logged in page
>POST logged in page (which uses dynamic url, incedentally) with another, different 5-variable dict with calculated responses
you have to set up your referers and headers properly too for each step

life is difficult eh
>>
https://www.youtube.com/watch?v=rpLoS7B6T94

Bisquit is LEGIT. This guy is crazy skilled.
>>
>>56069428
>>>/g/wdg/
>>
>>56069129
> But size of char is implementation defined
sizeof(char) is guaranteed to be 1 (i.e. it's guaranteed to be one byte), but CHAR_BIT isn't guaranteed to be 8 (i.e. it isn't guaranteed to be 8 bits; at least, not by the C standards, although POSIX requires this and you'll probably never encounter a system where a byte isn't 8 bits).

> so it's better off to use the modern fixed size ints. So in this case it would be better to use "int8_t" instead of "unsigned char".
Note that the C standards don't require the fixed-size types to provided. The _least types (uint_least8_t etc) and _fast types (uint_fast8_t) are guaranteed to exist, but the exact-sized types (uint8_t etc) aren't (although, again, you'll probably never encounter a system where they aren't).
>>
>>56069506
I meant the size of char (in bits) not sizeof char.
>>
>>56069527
>>56069145
>>
>>56069054
it's not just a style thing, it's what you should use by default for bitwise stuff, it can improve performance by avoiding sign extension and it avoids undefined behavior when you would cause a signed integral variable to overflow
>>
Has anyone read through the LuaJIT source and can give me a high-level explanation of how it works? I know generally how JITs work, but I'm talking specifics.
>>
What are the semantics of
int i = 0;
unsigned u = (unsigned)i;
?
Does it mean change implementation of the numeric value or reinterpret the implementation value?
>>
>>56069433
He's a bit weird, but he is great. Bit of a character, works as a bus driver, only a hobby programmer.
>>
File: ch1-Z-G-3.gif (454B, 165x36px) Image search: [Google]
ch1-Z-G-3.gif
454B, 165x36px
>running casually through sicp
everything is going fine
suddenly
> Translate pic related into prefix form
I know the idea of what I'm supposed to do, but I have no idea what the symbol
"5 + ???? + (..."
any help?
>>
what's your excuse for not writing nanopass compilers, /dpt/?
>>
>>56069835
it's a 4, with some really shitty font rendering
>>
File: 1470748368255.jpg (2KB, 126x126px) Image search: [Google]
1470748368255.jpg
2KB, 126x126px
do you guys stream your music (youtube, spotify,...) or save them in your computer?
>>
They have the same bit representation, but if the most significant bit is 1, the int interprets it as a 2's complement negative, while unsigned interprets it as normal (i.e. a huge ass number)
>>
>>56069839
what is a nanopass compiler, and why should i care?
>>
>>56069839
Do you do anything other than interpreters and compilers in FP languages?
>>
>>56069879
No. why?
>>
>>56069433
It's funny he likes working as a bus driver.
>>
>>56069877
basically, you represent changes between the source language and target language incrementally, so one step might be expanding a for each loop (that the source language has) into a normal for loop (that the target language has). it's kind of like the "Do one thing, and do it well" philosophy, but for compilers
if you want a video that goes more in depth, this one's pretty good:
https://www.youtube.com/watch?v=Os7FE3J-U5Q
>>56069855
both. if im listening to my own music i use saved files, but if i want to find new music i stream and just go with the suggestions
>>56069879
yeah, i've even made a game engine with OCaml. although honestly compilers are my favorite thing to make (which is probably why i like FP as much as i do)
>>
English is not my first language, sorry if something's not clear here.

So, I never coded anything in my life and just started learning Python on Codeacademy.
I wanted to test if I understand everything on my side, by creating a basic multiple choice text adventure thingy. Just for a few lines, to see if everything works.
Now I got that :

name = input ("What\'s your name?")

print (name + ", " + "ok.\n"
"""At least you know your name. But do you remember what you did last night?
You don't, do you?""")


Question1 = input ("""You just woke up in a dark room. What do you do?

1 Look in your pockets
2 Call for help
3 Cry""")

if Question1 == "Look in your pockets" or "1":
print ("You find a cellphone.")
if Question1 == "Call for help" or "2":
print ("The only answer you have here is your voice echoing.")
if Question1 == "Cry" or "3":
print ("Oh, I'm sorry. There, there. Everything/'s gonna be alright. NOW TRY TO GET OUT OF HERE YOU FUCKING BABY!.")


As a result, whatever I type in after the question, I always get all 3 answers together one after another. Why?

Also, if I wanted to type a phrase, and then another one but with a pause in between (like 3 seconds for example) how would I do?
>>
File: snek.png (1KB, 560x300px) Image search: [Google]
snek.png
1KB, 560x300px
I made a snek game.
>>
>>56070045
Cute.
>>
>>56070000
>quads
CHECK'EM
>>
>>56070081
nice one dood
>>
>>56070030
Read the code tags section in the sticky first, it's especially important for Python
>>
>>56070045
source?

i wanna play too
>>
>>56069790
http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1570.pdf
>Page 51
>6.3.1.3
>When a value with integer type is converted to another integer type other than _Bool, if the value can be represented by the new type, it is unchanged.
>Otherwise, if the new type is unsigned, the value is converted by repeatedly adding or subtracting one more than the maximum value that can be represented in the new type until the value is in the range of the new type.
>Otherwise, the new type is signed and the value cannot be represented in it; either the result is implementation-defined or an implementation-defined signal is raised.
So to answer your question, it's actually converted. For the unsigned case, it's pretty much modular arithmetic.
>>
File: thedig.gif (1MB, 630x296px) Image search: [Google]
thedig.gif
1MB, 630x296px
>>56069855
Save. Always. I save youtube clips I like aswell. Sometimes I save hour long talks just so I know they won't disappear. I compress them without regard for viewing pleasure but rather focused on how much information I can discern from it.

Here's a 3 hour longplay of a game called 'The dig' (pic related) in 51mb. Most of which is spent on audio quality.
>>
>>56070093
Oh, I see, sorry. Thanks.
Testing :

name = input ("What\'s your name?")

print (name + ", " + "ok.\n"
"""At least you know your name. But do you remember what you did last night?
You don't, do you?""")


Question1 = input ("""You just woke up in a dark room. What do you do?

1 Look in your pockets
2 Call for help
3 Cry""")

if Question1 == "Look in your pockets" or "1":
print ("You find a cellphone.")
if Question1 == "Call for help" or "2":
print ("The only answer you have here is your voice echoing.")
if Question1 == "Cry" or "3":
print ("Oh, I'm sorry. There, there. Everything/'s gonna be alright. NOW TRY TO GET OUT OF HERE YOU FUCKING BABY!.")
>>
>>56070133
You need to indent each of those print lines, at the moment your if statements don't have anything to do if they are true.
>>
>>56070133
You need to indent, dude.
if Question1 == "Look in your pockets" or "1":
print("You find a cellphone")
if Question1 == "Call for help" or "2":
print("etc")
>>
>>56070107
it's worth noting that the standard only describes the behavior, the implementation with two's complement is just that for example when converting a 32 bit signed int to 32 bit unsigned int it's just the same bit pattern, if it's a 64 bit signed int being converted to 32 bit unsigned int it's the same bit pattern but with the 32 most significant bits chopped off
>>
File: 1411179764778.gif (1MB, 444x250px) Image search: [Google]
1411179764778.gif
1MB, 444x250px
>>56070128
>tfw Obduction at the end of this month, and Syberia 3 in December
It's a good time to be a point-and-clickfag.
>>
>>56070133
Fix your indentation

Look at the precedence of "==" vs. "or"
http://www.mathcs.emory.edu/~valerie/courses/fall10/155/resources/op_precedence.html

Also worth noting that a value of 0 is the same as the boolean value False, everything else is the same as the boolean value True.
>>
>>56070159
>>56070158
Uh...It was actually indented when I copied it form repl.It (using this since I'm at work can't install Python)
Anyway, even with indents, same result.
Whatever you answer it prints all 3 answers together.
>>
>>56070128
Awesome.
i download videos from youtube with youtube-dl and convert them using ffmpeg.

what commands do you use (in ffmpeg) ?

looks like you do that too.

how much storage capacity does your music occupy?
>>
>>56070214
>>>or "1":
>>>or "2":
>>>or "3":

you need
if Question1 == "thing" or Question1 == "1":
>>
>>56070103

It's Windows only:
http://pastebin.com/16VAABB5

I need to improve it a bit. The main problem it has is that it's rendered in console and almost every console font has a greater height than width.

Obviously this is a problem because it means the vertical movement will be faster than horizontal movement.
>>
>>56070242
>>56070209
Cool. Thanks guys.
>>
To anybody who was in here last night or the night before and tried to help me figure out my issue with Visual Studio not giving options for an ASP.NET MVC 5 project the problem is solved.

After a re-installation and some updates were applied I was able to use it. Microsoft has really muddied the waters by renaming various packages to go into the ASP.NET Core 1.0 stuff and has a lot of out of date stuff listed in the docs still.

In the end though I'm really liking ASP.NET but it has lots of built in conventions that are a lot to wrap your mind around.
>>
>>56070278
congrats dude
>>
New to programming. Is it a decent idea to start with c++ and VS?
>>
>>56070319
C

N A N O
>>
>>56070319
honestly, I think you should start with Go (golang). problem is, I haven't seen many good books for absolute beginners... do you have *any* experience writing programs/scripts?

this one is a good book: https://www.golang-book.com/books/intro
there is a pdf the ^
then follow this: https://tour.golang.org and https://golang.org/doc/
>>
>>56070319

I can't recommend C++ but VS is a pretty solid IDE. I'd just recommend a different language. If I had to put together a course to teach someone programming I'd start them with Python to learn the basics and write some simple applications and then take their new found knowledge and move them up to either some more complicated stuff in that language (probably a site in Flask or something like that) and then move them to a more rigid language like C#.
>>
>>56070356
>>56070362

I should've probably said I made a few basic console programs in c++ and Java solving math problems, I've barely touched on stuff like structs.

I want to look into making a simple GUI next, is there any reason c++ is bad in general or what are the pros of the other languages? I prefer it over Java so far
>>
>>56070262
Also if you want to stick with something more like your first thing you could write

if Question1 in ["thing", "1"]:


Since that's easier to type if you want to have a lot of alternatives.
>>
>>56070319
Depends what you want to do.

C# is friendlier, a lot more modern and (contrary to popular belief) performs favourably up against C++

There's also very little you can't do with C# right now, once WebAssembly swings around you'll even be able to write web apps natively in it I imagine.

I'd recommend C# to almost anyone unless they have a specific focus that necessitates a lower level or simpler language.

http://www.learncs.org/ Here's a nice little basic primer to get a feel for it.
>>
File: 1373598200613.jpg (39KB, 400x300px) Image search: [Google]
1373598200613.jpg
39KB, 400x300px
>writing program
>need to slog through boring parsing I/O shit before you can get to the fun stuff
>>
>>56070493
One of the reasons I like Mathematica, Import works on everything.
>>
>>56070493
Programming isn't for you senpai

The fun parts in programming is the implementation details
>>
>>56070493
Parsing is easy as pie with (delimited) continuations.
>>
File: RiCIiOR.png (8KB, 1615x25px) Image search: [Google]
RiCIiOR.png
8KB, 1615x25px
Post bullshit you can do in your language.
>>
File: 2016.jpg (28KB, 367x390px) Image search: [Google]
2016.jpg
28KB, 367x390px
>>56070493
>parsing with I/O
>>
>>56070642
type T = T with
static member ($) (T, _:int ) = (+)
static member ($) (T, _:decimal) = (+)

let inline sum (i:'a) (x:'a) :'r = (T $ Unchecked.defaultof<'r>) i x

type T with
static member inline ($) (T, _:'t-> 'rest) = fun (a:'t) -> (+) a >> sum

let x:int = sum 1 2 3 4 5
let x:int = sum 1 2 3 4 5 6 7 8 9 10
>>
File: fact_trace_swooder.png (34KB, 642x638px) Image search: [Google]
fact_trace_swooder.png
34KB, 642x638px
>>56070642

That's not YOUR language! Microsoft made that.
>>
>>56070687
>that picture
more like shit you can't do tbqh mi familia
>>56070670
why is F# so disgusting
>>
File: lambda.png (2KB, 169x70px) Image search: [Google]
lambda.png
2KB, 169x70px
>>56070642
Anything, it's turing complete
>>
>>56070707
how do you do variadic functions in Ocaml, this is haskell apparently
class PrintAllType t where
process :: [String] -> t

instance PrintAllType (IO a) where
process args = do mapM_ putStrLn args
return undefined

instance (Show a, PrintAllType r) => PrintAllType (a -> r) where
process args = \a -> process (args ++ [show a])

printAll :: (PrintAllType t) => t
printAll = process []

main :: IO ()
main = do printAll 5 "Mary" "had" "a" "little" "lamb"
printAll 4 3 5
printAll "Rosetta" "Code" "Is" "Awesome!"
>>
>>56070479

It's not *bad* per se. It's just a lot for a first language. You have to control *everything* in the program and that's a lot to wrap your head around when you're first getting started. Some people will say it's a good thing to have to do that from the beginning but I don't think it's conducive to getting people started.

If you can do it though more power to you. I don't like Java (it was what I learned on) or C++ (just dabbled). I like Python and C# though Swift is good as well.
>>
>>56070728
>how do you do variadic functions in Ocaml
you don't
(although you could use GADTs to make heterogeneous lists)
>>
>>56070774
so how does print function work in ocaml
>>
>>56070707
>more like shit you can't do tbqh mi familia

What are you saying? That's my memelang.
>>
File: Screenshot_2016-08-13_23-12-20.png (92KB, 468x164px) Image search: [Google]
Screenshot_2016-08-13_23-12-20.png
92KB, 468x164px
>>56070642
>>
>>56066392

Macros.
>>
>>56070782
really weird syntactic sugar and a type system full of hacks (https://github.com/ocaml/ocaml/blob/trunk/stdlib/format.ml, https://github.com/ocaml/ocaml/blob/trunk/stdlib/camlinternalFormat.ml, https://github.com/ocaml/ocaml/blob/trunk/stdlib/camlinternalFormatBasics.ml)
>>56070795
oh shit, i meant to reply to the original one:
>>56070642
more like shit you can't do tbqh mi familia
>>
>>56070805

D is so fucking cool.
>>
>>56070854
Here look at my one line Factorial func

static Func<int, int> Factorial = (x) => x <= 1 ? x : x * Factorial(x - 1);


Please notice me OSGTP.
>>
>>56070870
factorial x = if x <= 1 then x else x * factorial (x - 1)
>>
>>56070870

Noticed.
>>
File: 497.jpg (9KB, 177x278px) Image search: [Google]
497.jpg
9KB, 177x278px
>>56070932
>>
>>56070870
>>56070882
>recursive factorial
>not co-recursive
>>
File: Screenshot_2016-08-13_23-33-46.png (174KB, 499x316px) Image search: [Google]
Screenshot_2016-08-13_23-33-46.png
174KB, 499x316px
>>56070854
It's pretty not bad
>>
http://codegolf.stackexchange.com/questions/89621/random-golf-of-the-day-7-a-distinctly-random-character/89651#89651

whew
>>
>>56065842
ayyyy lmao

how do you feel about scope finally getting implemented?
>>
>>56071017
>using mixin for no reason
>>
>>56071033
Yeah, I realized right after I didn't need it
>>
>>56066758

If i need the extra clock cycle I'll delete it then
>>
>>56071022
golfing languages really shouldn't count
>>
>>56070687
It's DrRacket, and I'm sure you are not using version 1.0.
>>
>>56071084

That's the joke. It's my own not lisp and I named it Dr Racquet for a laff.
>>
>>56071076

they should make it assembly only
>>
>>56071127

So you made a language that is obviously similar in syntax to lisp / scheme and decided to rip off the name of a scheme dialect?
>>
>>56071155
what's the point of making your own memelang where you use all of single utf8 characters
>>
>>56071160
>rip off
lol
>>
>>56071160

I mean, it's mostly a joke. If you want to be that way about it, then sure.
>>
>>56071127
>choosing to make a lisp
pathetic
>>
>>56071204

No they don't

others from before UTF-8 might use ASCII for example

they all become CPU instructions however
>>
>>56071235
>choosing not to make a lisp
you're literally the one ruining this world
>>
>>56071280
What's the difference between Lisp and cancer?

parentheses
>>
File: needsthis.png (38KB, 740x1174px) Image search: [Google]
needsthis.png
38KB, 740x1174px
>>56071209

That's perfectly fine. However, you need to make a editor for it with a interface like this picture
>>
>>56071028
Definitely a nice step towards good safety in D Deadalnix. Unfortunately I tend not use pointers in D =/, so I might not be seeing it that much.
>>
File: file.png (95KB, 1330x284px) Image search: [Google]
file.png
95KB, 1330x284px
I'm writing a python parser and am trying to find a way to extract Google's old reCAPTCHA from a web page but I can't seem to get it without having it execute some javascript in a browser.

The page includes a script like this:
https://www.google.com/recaptcha/api/challenge?k=[challenge key]

It returns a RecaptchaState object with the keys:
challenge (the challenge key),
site (the site public key)
t3 (some generated value)

The image loads through some sort of js function in recaptcha.js with an unknown th parameter
https://www.google.com/recaptcha/api/image?c=[challenge key]&th=[some generated key]

At the moment I'm using selenium webdriver that launches firefox and visits the site to extract the captcha image. Is there any way to obtain the image without having to run a browser?
>>
>>56071350
>Deadalnix

He's french, he can't help being a retard.
>>
>>56071364
lol, I enjoy seeing him shit on other people though
>>
File: gnl.png (29KB, 1108x518px) Image search: [Google]
gnl.png
29KB, 1108x518px
>>56071322

But I did!
>>
>>56071430
man, i miss being able to design GUIs for everything
>>
>>56070854
This is some code I wrote to generate C#-like property accessors which I think is kind of cool. Those calls to `.format` are processed at compile time, not runtime.

mixin template Property(alias member, Access accessOption = Access.getSet)
if (member.stringof.startsWith('_'))
{
static if (accessOption.among!(Access.get, Access.getSet))
{
enum mixStrGet = `
@property typeof(member) %s()
{
return member;
}
`.format(member.stringof.dropOne());

mixin(mixStrGet);
}

static if (accessOption.among!(Access.set, Access.getSet))
{
enum mixStrSet = `
@property typeof(member) %s(typeof(member) val)
{
return member = val;
}
`.format(member.stringof.dropOne());

mixin(mixStrSet);
}
}

unittest
{
struct Test
{
int _prop1;
int _prop2;
int _prop3;

mixin Property!(_prop1);
mixin Property!(_prop2, Access.get);
mixin Property!(_prop3, Access.set);
}

Test t;
assert(t.prop1 == 0);
t.prop1 = 1;
assert(t.prop1 == 1);

assert(t.prop2 == 0);
assert(!__traits(compiles, t.prop2 = 1));

assert(!__traits(compiles, { auto _ = t.prop3; }));
assert(__traits(compiles, { t.prop3 = 1; }));
t.prop3 = 1;
assert(t._prop3 == 1);

assert(!__traits(compiles,
{
struct Test
{
int prop;

mixin Property!prop;
}
}));
}
>>
>>56065903
Use a scripting language for the back end like Ruby or Python. JavaScript should have never left the browser.
>>
>>56071486

I'm totally garbage at it, and my business logic is always tangled with presentation logic because I'm not gud at meme-view-etc.

Oh well.
>>
>>56071559
hey, it still looks pretty.
btw, do you still have that thing with tabs for different windows?
>>
>>56066038
>>56065730
OK so it seems idris isn't production ready and really doesn't have the design philosophy I'm looking for.

Why can't this just be a thing? It's not complicated stuff.
>>
>>56065832
>At the moment I'm using selenium webdriver that launches firefox and visits the site to extract the captcha image. Is there any way to obtain the image without having to run a browser?
no, that's really about it
unless you want to try to reverse engineer recaptcha
I've never messed around with it, but I hear PhantomJS works well
>>
>>56071691
>>56071354
I'm a total idiot and responded to the wrong thing
>>
>>56071686
>it's not complicated
Do it then faggot
>>
>>56071559
Holy shit you're not good at MVVM?

I can't believe I'm better than OSGTP at something.

I've been working on my first MVVM app and this shit is a huge game changer. There's a vast amount of boilerplate involved compared to a non-mvvm implementation, but the second you're done with the boilerplate you can crank out views and models at the speed of light.

Took 4 seperate attempts to get it to click with me, finally got there in the end though.
>>
>>56068989
You'll learn that the types of programs you make in C don't require OOP or templates. It's not just because it doesn't support it, but 99% of the time C programs are made to function in a precise and/or specific manner that doesn't require generic functions, polymorphism, or tying functions to data.
>>
>>56071711
Oh alright thanks for the info
>>
>>56071691
>>56071711
Yes you can use phantomjs, I used it to screencap posts on 4chan fully cropped as well
>>
>>56071686
Idris is so close to being perfect but it's so broken that i'd never use it for a real project
>>
>>56071712
But I don't want to write and maintain a language. I'm sure you also see how stupidly simple it is. Its just pulling out facts about hardware into the language and make completely trivial changes based on it.
>>
>>56071756
What have you achieved by baiting me?
>>
>>56071776
I'm just sincerely replying my thoughts based on your replies.
>>
>>56071776
Why would you fall for such easy bait?
>>
>>56071816
because I believe in /dpt/
>>
>>56071756
>pulling out
HaHA!
>>
Bump limit!!
>>56071860
>>56071860
>>56071860
>>
>>56071868
But we haven't hit it yet.

Fuck off.
>>
>>56071880
You sure?
>>
>>56071868
Nice false flag but you forgot to rename the OP image
>>
File: windclas.png (188KB, 826x544px) Image search: [Google]
windclas.png
188KB, 826x544px
>>56071718

No, but I'll probably figure it out at some point when I'm forced to contend with the WPF meme. The rub is that I'm usually trying to get a working application rather than one that's well organized.

>>56071620

I'm surprised you remember that, it was last summer, I believe.
>>
>>56071860
>>56071860
>>56071860
New thread!
>>
Trying to learn to program my PIC32MX250F128B. I don't know how to code and I hate coding but I got the ADC to work at least. Now I need to figure out how to output the serial out value to some seven segment displays.

I'm guessing I want to use a serial in parallel out shift register on the output of w/e pin sends the output serial data then build a decoder with discrete logic gates or get a decoder IC though the output isn't BCD.

Why is this shit so hard?

#include <p32xxxx.h>                // include chip specific header file

// Configuration Bits
#pragma config FNOSC = FRCPLL // Internal Fast RC oscillator (8 MHz) w/ PLL
#pragma config FPLLIDIV = DIV_2 // Divide FRC before PLL (now 4 MHz)
#pragma config FPLLMUL = MUL_20 // PLL Multiply (now 80 MHz)
#pragma config FPLLODIV = DIV_2 // Divide After PLL (now 40 MHz)
// see figure 8.1 in datasheet for more info
#pragma config FWDTEN = OFF // Watchdog Timer Disabled
#pragma config ICESEL = ICS_PGx1 // ICE/ICD Comm Channel Select
#pragma config JTAGEN = OFF // Disable JTAG
#pragma config FSOSCEN = OFF // Disable Secondary Oscillator

#define SYSCLK 40000000L

//Variables


void setup() {
// put your setup code here, to run once:
ANSELB = 0x8000; //Set all of PORTB pin 15 as analog and all else digital
TRISB = 0x8000; //All PORTB are outputs except PORTB pin 15
PORTB = 0x0000; //PORTB initialized to 0

// initialize serial communication at 9600 bits per second:
Serial.begin(300);
}

void loop() {
int potVal = analogRead(A2);

int voltage = ((potVal * (3.3 /1023)) / 3.3) * 100;
Serial.println(voltage);
}
>>
>>56071897
>I'm surprised you remember that, it was last summer, I believe.
hm, must've been before i had a tripcode. still waiting on that source though :^)
>>
>>56071925

It's looking like probably never because I'm a huge nigger!

And anyway, I'll be busy learning MVVM now.
>>
>>56071935
>learning MVVM now.
learn NVVN instead
>>
>>56071017
>print_type(t)(T arg)
It's like they're not even trying to hide the implementation. Gross.
>>
in what situation should you be unrolling loops before deployment?
>>
>>56071925
>using the smiley with a carat nose
>>
File: 1453656893900.png (1021KB, 870x717px) Image search: [Google]
1453656893900.png
1021KB, 870x717px
>>56072218
In the situation where you want to post replies with smug anime girl reaction pictures such as

>>not unrolling your loops
>>
Hey guys, I was working on ssl handshake in android, and it works, but the downfall is that I have to use this line
keyStore.load(kSIS, "password".toCharArray());
at one point I had the password in cleartext, and so as a temporary fix I have it prompt for a password before doing sslhandshake. What approach would I do without needing to manually input password or would this be the best way?
>>
i've just finished working on a branch&bound optimizer for magiccardmarket in python,
guess now i'll do some serious testing to find bugs
>>
>>56065832
>>56065842
I'd give her the D
Thread posts: 324
Thread images: 31


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