/dpt/ - Daily Programming Thread

What are you working on Jow Forums?

Prev thread =>

Attached: 1384365381216.png (1024x768, 384K)

Other urls found in this thread:

templeos.org/
templeos.org/Downloads/
wiki.haskell.org/Performance/Strictness
wiki.haskell.org/Seq
gamedev.stackexchange.com/questions/23497/how-to-move-a-3d-object-in-3d-coordinate-space
en.cppreference.com/w/cpp/string/byte/memcpy
github.com/sarabander
github.com/alpaca-lang/alpaca
twitter.com/SFWRedditImages

First for anime and C.

so you want to specify a set term of recursion? Just keep a counter with your recursion dude

or in other words, have your base case be number of 0 for termination

then just input 40m as the argument, taking away 1 from 40m each iteration

>there are people that haven't learned C for their waifus
>current year

Attached: monika.png (849x1200, 1.2M)

How did you get into it?

I did that
foreach :: (a -> a) -> a -> Integer -> a
foreach f acc 0 = acc
foreach f acc n = foreach f (f acc) (n-1)

I still have a stack overflow. Unless the problem comes from something else, but I can't pin it down as this is like the only recursion I have in my code.

Rust is better C.

I'm going to learn HolyC

>Rust is better C.
Indeed it has better jsw support, it has more NEETs using it as percantage, and you dont have to be corporate slave in order to use it, you can stay in your mommas basement and live of social! Rust truly is best!

I went on a TempleOS/HolyC binge earlier today. Shit's wild.

I can't even take the fucking tour without TempleOS crashing lmao, time to hope a clean reinstall solves it

Attached: ebin.png (640x480, 16K)

Behold the power of Ring 0

Downloading from templeos.org/ instead of templeos.org/Downloads/ solved it, time to become Terry's templar

did you build it or run it in the REPL?

finally reached the monoid chapter on the haskell book

currently on the door that leads to the path of Satori bros

(f acc)
isn't being evaluted because of lazyness i believe
don't know enough about hasklel to help you beyond that desu

Haskell Programming from First Principles is it good?

REPL.
Could this make a difference ?

It would somehow just compose f ( f' (f'' acc))) and wait until I've done the 40M iterations before evaluating ?
I thought using and iteration with acc prevents that kind of behavior.

reading it, yes it is

it is done btw, just in RC stage since they wanna print it as well

Can someone explain this?

char *ptr;

/* write to the shared memory object */
sprintf(ptr,"%s",message_0);
ptr += strlen(message_0);
sprintf(ptr,"%s",message_1);
ptr += strlen(message_1);


Why are they doing ptr += strlen(message_0); and ptr += strlen(message_1);

Good there is 1.0RC2 from 2017 version on libgen. Thanks!

of course m8, I just compiled your code and it worked fine

but of course I just put in a addition function as the arg

ptr is part of some larger buffer. ptr points to the free area of the buffer. Once a message is written into the buffer, ptr is moved so that it points to the area just after the message that was written i.e. into the new free buffer region.

Just ran the binary.
No stack overflow exception.
The program just hangs. I find it really hard to believe that it'd be impossible to do something as simple as
int x = 0;
int y = 0;
for(int i=0; i < 40000000; i++) {
x = f(x);
y = g(x);
}
return y;

Do I really need 200 IQ to use hasklel?

when I say fine, I do mean it is unoptimized as you would expect

I do remember doing something like this but with concurrency in F# and then later comparing with Big Data integers

I am using a i7 6700k with 16 GB and that code does use lots of ram.

In short, you have to use strict mode for haskell due to the lazy evaluation fucking you over in this case. wiki.haskell.org/Performance/Strictness

iterate f z !! n

not that guy but is there a way to force strict evaluation?

Attached: csrlbz.png (960x472, 8K)

Data.List.iterate'
' usually marks something as strict

If they didn't move the pointer further along the buffer, they would just be overwriting the same spot.
To represent it somewhat graphically
| | | | | | |
^

|a|a|a| | | |
^

|a|a|a| | | |
^

|a|a|a|b|b|b|
^

|a|a|a|b|b|b|
^

Not that it's a language thing or anything, just a library thing. ' is a valid token in identifiers.

getting parse error with import Data.List.iterate'

or even Data.List (iterate')

even with
import Data.List

asd = iterate' (+1) 1 !! 10

this gets me
main :: IO ()
main = putStrLn $ show $! iterate (+1) 1 !! 40000000

> TotalSeconds : 11.8177757


using OpenMP would be better but whatever

Can someone explain to me in layman's terms how I can modify positions of models in a 3d space using MonoGame?

So far I lifted the following code from a tutorial
foreach (ModelMesh mesh in model.Meshes) {
foreach (BasicEffect effect in mesh.Effects) {
effect.EnableDefaultLighting();

effect.World = Matrix.Identity;
effect.View = Camera.Instance.ViewMatrix;
effect.Projection = Camera.Instance.ProjectionMatrix;
}

mesh.Draw();
}
But I was wondering what are those World, View and Projection fields?

How would changing them modify the displayed object?
From what I think I believe that World is the position of the object in the 3d space, but what about View and Projection?

I want to build a simple grid-like display system.

I'm using MonoGame for this btw

If a thing can either be 1 or 0 and I want to check if it's 1 is there any advantage writing if(thing ==1) or (if thing > 0)?

What are you using that's giving you a parse error?
iterate' is a perfectly valid identifier, try it in ghci

might have to do with the version of the base package you have. you can just see the implementation of iterate' to see how to add strictness:
iterate' :: (a -> a) -> a -> [a]
iterate' f x =
let x' = f x
in x' `seq` (x : iterate' f x')


this explains it
wiki.haskell.org/Seq

well technically speaking you should always check only for the thing you want, since everything else is undefined behaviour.

>he dosn't use if (thing)

Attached: 1485747552895.jpg (1031x876, 145K)

well if it's not a boolean...

You have been jedi mind tricked to use booleans

Just make the function strict on the accumulator
foreach f acc n = seq acc $ if n

I'm stupid, I'm working with some sort of nested type, therefore just adding strictness by doing
for f (f $! acc) n

or wouldn't work as I need a deepseq.

I guess if I rewrote the function f and do some strict evaluation of its args inside, that could work too maybe.
Anyways, thanks everybody.

>gamedev.stackexchange.com/questions/23497/how-to-move-a-3d-object-in-3d-coordinate-space
?

With risk of sounding retarded.
I'm working on an API and I can connect to it through localhost:8080 in chrome. However, when I try to connect to it from android studio I get ConnectException: Failed to connect to localhost/127.0.01:8080

* anyone know what's going on?
Working with Spring boot for the first time.
Launching the server from a jar-file

oh my god I just realized
Is it because an android emulator obviously can't connect to localhost?
I'm so fucking retarded someone kill me

What is a good resource for learning common algorithms and data structures /dpt/?

How to bitwisely cast object in C++?
assuming (sizeof(Foo) == sizeof(Bar)) == true
is this a good way to do it?
Foo foo;
Bar bar;
std::memcpy(&bar, &foo, sizeof(Bar));

depends on your language, but usually google.com with the context of your problem

sicp

>depends on your language
That topic is language independent.

>purely functional data structures

Your point being?

Those data structures aren't "purely functional", these terms can refer only to the programming languages that use them. Purely functional languages make use of immutable persistent data structures, which you can implement just as well in C or python.

laziness vs strictness is important in the implementation of data structures

as long as both Foo and Bar are TriviallyCopyable
en.cppreference.com/w/cpp/string/byte/memcpy

Wow. I'm reading SICP online and the way it is written isn't any help at all. I bet only around 10% of /dpt/ managed to get through this book to the end...

the usual posters of /dpt/ who have are long gone, like johnson tripfag

github.com/sarabander

uhh probably best if you use a union
just don't use pointer casting

Im trying to use pinvoke to use a c++ dll in c#.
In my source.cpp I have
extern "C" __declspec(dllexport) int One(){
return 1;
}

then in the program.cs I have
[DllImport("engine.dll", CallingConvention= CallingConvention.Cdecl)]
public static extern int One();
static void Main()
{
One();
}


But I keep getting the error that the compiler cant find an entry point. Does anyone have any experience with this. Using Visual Studio 2017 if it helps.

meant source.h

Do you?

Attached: c.png (756x350, 14K)

Attached: trop.png (1280x720, 1.07M)

Is it really necessary to cast it?

To make sure it's int. You just don't to this?

#define let __auto_type
let p = (int*) malloc(sizeof(int[8]));

Have you set the C++ to compile as a DLL specifically? Perhaps it's set to compile it as a .exe and expects a main or WinMain.

int *i = malloc(sizeof *i * 8);

int i[8];

I've been coding for a year now and have "learned" six languages and written over 100+ programs (from basic console stuff to java forms to webdev backend stuff).

Still, I don't really feel like I "know" how to program. What's next?

learn Haskell

>Six languages in a year
That's why you don't know how to program

The cast adds absolutely no additional type safety.
It's literally completely useless.

start lifting because your problem is your sense of self worth

What does Jow Forums think of Alpaca lang?
github.com/alpaca-lang/alpaca

>reading a book written for 80' math majors

Attached: satanya laugh.gif (640x358, 1.9M)

cute debiru.

int (*i)[8] = malloc(sizeof(int[8]));

Whats a nice scripting language that can actually optimize tail recursion?

The only valid purpose for doing this is if you want a (strict) C++ compiler to be able to compile your program. Otherwise it's completely useless.

haskell.

Guile Scheme.

NigScript

Bash?

what language should i use if im looking to make a roguelike game?

>using malloc in C++
literally only one reason to do this

haskell

malloc > new desu

are you blind? I said NigScript. it's the scripting language of the future

I use malloc in C++ because I pretty much want to just write C but with classes like I'm in the 80s

would it be legal for application to say "enable telemetry or you can't use this program"?

Javascript is a better language if your waifu is a trap. It feels kind of like C but is worlds less efficient, just like traps look like cute girls but have weewees.
Imagine programming in a language that looks like C but definitely isn't, while a precious curly headed little femboy that looks like a girl but definitely isn't is wiggling his thicc round ass in your lap and letting you snuggle him and kiss his head while he (((k)))odes.
Even though the two of you are calling it "pair programming" so you don't feel left out, it's just as well that you can't use the keyboard because you need both hands to hold him in your arms and explore his body. After all, programming is a subset of traps. A masculine, normal, reliable, mentally healthy male, cannot be a good programmer. He lacks the requisite "programming socks" and "programming HRT." The highest purpose he can fulfill is provider, of financial, emotional, and physical support and care, for the *real* programmer, to let him do his work without worry.
"But a good programmer would never use JavaScript anyway!" i hear you cry. I beg to differ. A good programmer needs to occasionally use bad languages. Especially if it's because it's a language well suited to traps.
Also it's cute when women, and sufficiently woman-like mentally ill men, use bad languages and still think they're good programmers, because we all secretly know we manly men are actually much better at everything including programming of course but sshhh.

Attached: 1526629573447.png (400x250, 45K)

Python with libtcod.

dumpbin your dll and check if the function exists.

i don't see why not?
it's not as if the "or you can't use this program" isn't a choice you're giving them. you're not forcefully invading their privacy, if they don't want your botnet they can just not install it.
i mean windows is legal and they don't even bother to ask. well i mean they do but the options they provide for it don't even work

I don't know, my company will do something similar. I find it unethical. I was just wondering if it is legal or not.

The bigger problem is, customers already bought the application. So if they are not able to use it, it is kinda a scam.

Is there anything more boring that OS programming? I sure hope this shit pays off. I could have been learning another language now

Attached: 1509195642647.png (1127x685, 37K)

is going through a code base line by line with the debugger a valid method to understand it?