[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: 38

File: commodore.jpg (877KB, 1200x910px) Image search: [Google]
commodore.jpg
877KB, 1200x910px
What are you working on, /g/?

Previous thread: >>55931637
>>
im going to make video games
>>
I don't know. I can't work up the willpower to do anything to completion.
>>
Working on a network stack in Python
It finally answers ARP
>>
>>55938098
I get myself to completion multiple times a day.
>>
Nothing because my 3 week vacation from the software dev job starts today. Glorious, glorious vacation. Ahhhhhhhhhhh.
>>
File: c64-lit.jpg (1MB, 3264x2448px) Image search: [Google]
c64-lit.jpg
1MB, 3264x2448px
>>55938046
>>
I have c++ code and I'm on windows.

I want to compile this c++ code for mac. How do.

Shortest way that doesn't involve me setting up an entire damn Mac VM.
>>
>>55938046
Procrastinating studying for my A+ cert.
>>
>>55938046
I need to learn how to do GLSL sampling and filtering so I can downscale images for my image viewer.
My goal is bicubic interpolation, but I have no idea how to achieve this.
Any ideas?
>>
>>55938421
You should do that whilst on /gta/ instead of /dpt/.
>>
(oops posted to the wrong thread)
at this point i have no idea whether my code even works/makes any sense at all or im just really high and writing random things until it compiles
>>
why does kill yourself = kys?

shouldn't be ky only, with the s?

ky = kill yourself
>>
>>55938064
/thread
>>
>>55938753
>ocaml or f#
why
>>
Am I doing this right?

class FizzBuzz{
int i = 1;

public:
~FizzBuzz(){
if(i <= 100){
if (i % 3 == 0) cout << "Fizz";
if (i % 5 == 0) cout << "Buzz";
else if(i % 3 != 0) cout << i;

cout << endl;
i++;

delete this;
}
}
};

int main() {
auto dfb = new FizzBuzz();
delete dfb;
return 0;
}
>>
C++ question: Is there a name for this type of class? I don't understand what it does and want to look it up

template <typename T>
class MyVector :
public vector<T>,
public string

also how the fuck do you do that block of code thing on this board. pinned thread has nothing and after scanning the wiki for 5 seconds i couldn't find it either
>>
>>55938861
>multiple inheritance
>stl container inheritance
>MULTIPLE STL CONTAINER INHERITANCE

Shit nigger, what are you doing?
>>
https://github.com/Djent-/SmogonToBulbapedia/blob/master/SmogonToBulbapedia.user.js

Made this quickly today. My first Grease/Tampermonkey script.
>>
>>55938886
looks very nice. what does it do and how long have you been learning javascript?
>>
File: 1213.jpg (35KB, 342x266px) Image search: [Google]
1213.jpg
35KB, 342x266px
>>55938878
it's meant for a simple test CRTP, this is the full code
i just used string instead because i didn't want to post it all, and don't know what the fuck is going on
>>
>>55938126
Bazinga! xD
>>
>>55938046
>let's put glasses on an attractive guy, that will make him a nerd for this staged photo
>>
>>55938861
User code and \code with square brackets around them to format your code. As for your question, I don't think there's a standard name for a class with a vector and a string.
>>
File: smogontobulb.png (108KB, 2183x594px) Image search: [Google]
smogontobulb.png
108KB, 2183x594px
>>55938910
It adds Bulbapedia article links to Smogon Strategy Dex entries. I play on console more than metagame, so Bulbapedia has more relevant information to me (Egg moves, level up table, etc.)
Might end up replacing Smogon's move article links completely rather than adding a [Wiki] link next to them.
>>
>>55938861
I'm >>55938951, didn't see the colon. This is just multiple inheritance.
>>
>>55938957
>how long have you been learning javascript?
>>
>>55938910
Also I've never really learned Javascript - this is the first time I've used it for any real purpose. I've been reading Javashit for a while now, haven't bought into any millenial frameworks though
>>
/* 
HELLO
WORLD
*/

#include <iostream>
using namespace std;

int main()
{
cout << "Hello world!";
return 0;
}

Am i a programmer now
>>
>>55938192
this divine feeling could be your every day reality if you opened your heart to the gospel of NEETdom
>>
>>55938848
because im writing a compiler and it makes my life 100x easier to use ML
>>
>>55938046
this

/**
* Pajeet simulator version 1.0 */
public class Pajeet{
private String hasName;
private String inLocation = "tech support";
private boolean bowelsAreFull = false;
private boolean isHungry = true;

public Pajeet( String hasName){ this.hasName = hasName;}

public void doTheNeedful( boolean kindly){
if( getIsHungry( )==true ){
eat( "curry");}
if( getBowelsAreFull( )==true ){
poo( );}
if( kindly==true ){
setInLocation( "tech support");}
doTheNeedful( kindly==true ? kindly==false : kindly==false);}

public void eat( String food){
if(food.indexOf( "curry") >= 0){
setBowelsFull( true);}
setIsHungry( false);
doTheNeedful( true);}

public void poo() {
setLocation( "street");
setBowelsAreFull( false);
setIsHungry( true);}

public String getHasName( ){ return this.hasName;}

public String getInLocation( ){ return this.inLocation;}

public boolean getBowelsAreFull( ){
return this.bowelsAreFull==false ? this.bowelsAreFull==false : this.bowelsAreFull== true;}

public boolean getIsHungry( ){
return this.isHungry==false ? this.isHungry==false : this.isHungry==true;}

public void setInLocation( String inLocation){ this.inLocation = inLocation;}

public void setBowelsAreFull( boolean bowelsAreFull){
if( bowelsAreFull==false ){
this.bowelsAreFull = bowelsAreFull==true;}
else{
this.bowelsAreFull = bowelsAreFull==true;} }

public void setIsHungry( boolean isHungry){
if( isHungry==false ){
this.isHungry = isHungry==true;}
else{
this.isHungry = isHungry==true;} } }
>>
>>55939046
doesn't work , Rajesh
>>
>>55938852
After a while there's going to be a double free and then a memory corruption
>>
>>55939023
> let (>>=) ...
> List.
> ((=) tag)
> List.map2 (fun a b -> (a,b))
>...
>>
>>55939046
I believe the "offshore" teams I work with consist of similar programs.

"needful" looool
>>
>>55939121
OCaml lacks way too many abstractions in its standard library, but i'm using a nightly compiler build so im not able to make use of any of the alternate standard libraries. if i added batteries-included i wouldnt need any of that dumb boilerplate
>>
>ywn save Java w/ Subramaniam
https://www.youtube.com/watch?v=e4MT_OguDKg
>>
I'm learning Clojure. Seems like a practical, modern functional language. I think it's the bee's knees so far, but it's just not as widely used as I would expect it to be, having been around for 9 years. Why is it unpopular?
>>
File: csg.png (117KB, 1280x997px) Image search: [Google]
csg.png
117KB, 1280x997px
>>55938046
Making a visual Constructive Solid Geometry modelling system. The goal is to be able to create 3d objects and run finite element analysis with a twist.

Im doing it in a visual programming style because some of my colleagues will use this who dont know programming. Also i feel its faster to slap together some blocks and wires for quick results.

The graphical interface is based on pyqtgraph, the csg engine is stolen and rewritten in cython for speed, its still slow.
>>
>>55939220
because it's functional
>>
>>55939293
How long have you been programming? That looks impressive
>>
So is codeAcademy /g/ approved? Should I she'll out $20 a month for the premium feature?
>>
>>55939334
codecademy is a poor excuse for an education imo. do the free stuff first, and then start reading books
>>
>>55938314
This might help
http://stackoverflow.com/questions/693952/how-to-compile-for-os-x-in-linux-or-windows

Not sure tough. Haven't tested it.
>>
>>55939334
yes yes goy!

that will do it!
>>
>>55939382
trying this right now in cygwin.

trying to get the sdk files now

https://github.com/tpoechtrager/osxcross
>>
>>55938540
which part are you struggling with? do you know how to load textures and sample them in the shader?
>>
>>55939334
>So is codeAcademy /g/ approved?
no
>Should I she'll out $20 a month for the premium feature?
no

>>55938764
kys = kill you're self
>>
>>55939305
I dont know, like 10-15 years, but mostly for the lols. For serious stuff id say 3 years, starting with my bsc thesis and then for work related stuff.
>>
What's the best resource to learn Python from as an already experienced programmer?
>>
Why do we use 64-bit pointers? Shouldn't we just store everything in an array and access them through indices to save those extra 32-bits?

Paying twice as much for a 64-bit pointer just doesn't seem worth it at all.
>>
File: sicp.png (518KB, 846x475px) Image search: [Google]
sicp.png
518KB, 846x475px
Have you read your sicp today?
>>
>>55939649
Console $ python
"start doing shit"
>>
>>55939672
Are you serious?
>>
>>55939672
top kek
>>
>>55939077
i'm torry?
>>
>>55939686
Yes? If I could I'd overload & to give me the index and not the absolute 64-bit address. For most use cases I don't need to store 18,446,744,073,709,551,616 different things. 3 or 4 millions is more than enough and everything else is just wasted.
>>
I'm working on my game in Unity. Please no bullh my PC can't run UE4, and for once I think if I wasn't so lazy I could actually finish it, in 3 years, as Unity is a fairly robust platform.
>>
>>55939787
Then don't use fucking 64 bit pointers if you don't want to, you idiot
>>
>>55939672
>>55939787
the dumbest shit i've read all day and i've read some dumb shit. i don't know where to even begin. the cpu has 64 bit registers and you shouldn't be storing a very significant number of pointers for any significant amount of time
>>
>>55939817
But why are 64-bit pointers the default? It's retarded. It's a huge inefficiency.
>>
>>55939834
kill yourself
>>
>>55939834
You're a complete fucking idiot, you know that right?

int* pointer = ...

unsigned char i = ...

pointer[i]
>>
>>55938064
Well, yeah, that's kind of the point of these threads.
>>
>>55939852
Yeah so what the compiler should do is store a "base memory location" and then change all pointers to be relative from that base, and the offset should be stored in a uint_32t, not a 64 bit value
>>
>>55939897
I hope you never use C or C++ or similar ever again
>>
>>55938272
Hey what kind of tables and chairs are those? They look pretty sexy ;)
>>
>>55939897
>and then change all pointers to be relative from that base
Right, it's called memory address 0x0.
>and the offset should be stored in a uint_32t
What If I want to store something larger than 4GiB in memory?
>not a 64 bit value
Linux's x32 ABI exist for dumbasses like you.
Nobody really uses it for you though.
>>
>>55939897
>a base memory location
>all pointers relative from that base
it's called 0x0
>>
>>55939909

I wish no one would have to. :^)
>>
>>55939909
Fuck you I'm just gonna learn Rust
>>
File: squinty pepe.jpg (60KB, 500x495px) Image search: [Google]
squinty pepe.jpg
60KB, 500x495px
>>55939046
>tech support
>is hungry
>eat curry
>bowels are full
>poo
10/10
>>
>>55939963
Good, it was made for stupid people after all
>>
>>55939672
if you have n objects... go ahead and store them in an array which you access through an offset into the array rather than through n different pointers. what's the fucking problem?
>>
>>55933495
So let's say I wanted to do actual cool ai
Where do I start?
>>
>>55939992
define "actual cool ai"
>>
File: 542140.jpg (14KB, 400x400px) Image search: [Google]
542140.jpg
14KB, 400x400px
>>55939963
https://github.com/rust-lang/rust-www/issues/268
>>
>>55939992

Well all ai should probably start with pathfinding algorithms and then move up from there.
>>
>>55940013
> dat haircut
> dem glasses
"i'm offended by everything!"
>>
File: 1443040608269.jpg (24KB, 712x400px) Image search: [Google]
1443040608269.jpg
24KB, 712x400px
>>55940013
>Solely referring to 'gender' does not recognise the non-binary or agender folk.
>>
File: 1469294744377.jpg (186KB, 1376x2348px) Image search: [Google]
1469294744377.jpg
186KB, 1376x2348px
Somebody tell me if this works at all:
https://bitbucket.org/EZ3CHI3L/eternity
It's an image viewer.
>>
>>55939672
Well there's no way around it. Performance wise your language abstraction that allows you to address all memory using 32bit values would just have to be translated to 64bit pointers because that's what 64bit architectures use. Sure. It could be nice if you had a flag or something that let's you choose a 'chunk' you're in and addresses change based on that. The CPU would keep the chunk bits separate from your data and you can move around your 32 bit values. But you can already do that no problem really. Just never let the additional bits go out of scope. Write your own structure for pointers. And do some arithmetic when accessing. I doubt you will see major gain. If you do I suspect that you have too many pointers. Poor data locality most likely.
>>
>>55940036

Welcome to modern logic.. If you're using neutral terms clear you're not recognizing how special of a snow flake they are and intending to insult them or exclude them.
>>
File: C o C.png (6KB, 505x74px) Image search: [Google]
C o C.png
6KB, 505x74px
>>55939992
What do you want it to do?

>>55940049
I like your anime images
>>
File: 1467131735909.gif (1MB, 640x360px) Image search: [Google]
1467131735909.gif
1MB, 640x360px
>>55940088
>-_-
>:P
>>
>>55940006
>define "actual cool ai"
Well he's making the claim that current ai research is lacking. I'm wondering how and how I can make my project non-lacking. So its really a fairly free choice.

My image of his complaint is that people are doing things like making drones maneuver in complicated ways but all of that is really nothing all that interesting. Its just work we know how to do but there's effort involved in accounting for things.
>>55940026
I already know that fairly well. But I haven't mapped the real world yet. So yeah good suggestion. I don't feel that there's any 'cool ai' value in that though.
>>
File: mipsmon-01.png (171KB, 1680x1050px) Image search: [Google]
mipsmon-01.png
171KB, 1680x1050px
Writing a monitor ROM in assembly for an emulated MIPS system.

Also writing said emulator.

So far it disassembles code.
>>
>>55940108
ML stuff is for example taking medical data and categorize people into groups which may be more likely to get some disease or whatever. it's incredibly boring. if you want AI where it's a robot that acts like a human, that shit's virtually impossible to achieve (for now at least), if you do succeed you could get bill gates-tier rich off of it.
>>
File: it_works.png (475KB, 1004x629px) Image search: [Google]
it_works.png
475KB, 1004x629px
>>55940049
it works
>>
>>55940107

I don't judge you for repeatedly posting that image. Do I anon?

>>55940108

Well it depends on what your definition of "Cool" is. You can always try doing fancy things with neural networks and genetic algorithms.

Any real advanced ai is going to require a good amount of money for hardware and time for building the machines (Not to mention repairs on failures).
>>
>>55940147
>"it's an image viewer"
>it's actually a trojan
>>
>>55940150
>depends on how your definition of cool is
Well maybe it's more appropriate to ask how he (or anyone else) finds AI research lacking.
I agree, but I don't have better ideas. I haven't thought about it much. But it's very underwhelming.
>>
>>55940198
>trojan
>linux
>>
I wish I still had my Vic 20.

This thread makes me sad.
>>
>>55940235
And?
>>
>>55940216

Well at this point all of the "Cool" ai work in my opinion is non-trivial and would require a solid idea / theory / goal and the ability to acquire funding. New AI research isn't cheap if you're lucky you can start up with only $100,000 or so for research and then get enough of a small part of the concept developed to get larger funding. All the cool stuff generally has million + dollar budgets.
>>
/g/ Windows developers, what method DLL injection do you prefer?

SetWindowsHookEx, CreateRemoteThread + LoadLibrary, CreateRemoteThread + WriteProcessMemory, SetThreadContext/NtSetContextThread or finally simply a DLL passthrough/wrapper?

I'm using SetWindowsHookEx right not but I'm noticing an oddity with process suspension which triggers DLL_PROCESS_DETACH
>>
>>55939897
>>55939909
>>55939934
>>55939936
> i've never heard of segmented memory!
>>
>>55940308
i have no idea what are you talking about
>>
File: 1465297400484.jpg (100KB, 500x500px) Image search: [Google]
1465297400484.jpg
100KB, 500x500px
>>55940318
>segmented memory: the act of only using 32 bit pointers
>>
>>55940295

I should clarify .. Million dollar budgets are for small toy startup style ideas when it comes to ai funding. The big projects get 500 million or more in funds.
>>
>>55940318
Thank god we've moved on from that shit.
But that isn't what we were talking about.
>>
>>55940308
CreateRemoteTHread + WriteProcessMemory here
>>
>>55940308

Here is a hint (Most of my dll injection was for game cheating)

LdrLoadDll
ZwQuerySystemInformation
PsLookupProcessByProcessId
PsLookupThreadByThreadId
KeAttachProcess
ZwAllocateVirtualMemory
memcpy
RtlInitUnicodeString
UserApcPending == TRUE
ExAllocatePool
KeInitializeAPc
KeinsertQueueApc
LdrLoadDll
ZwFreeVirtualMemory
ExFreePool
KeDetachProcess
ObDdereferenceObject
>>
>>55940398
Multiplayer by any chance? You listed some driver api
>>
>>55938046
looks like that one macfag

someone post the drawing/picture
>>
>>55940435

Yeah, you had to do injection in kernel mode for some games. Typically anti cheats didn't have very good detection for kernel mode injectors.
>>
>>55940450
Was it profitable writing cheats?
>>
>>55939672
So, the biggest problem is that if you are addressing more than 2^32 bytes, or 4GiB, you simply can't represent each individual byte with only 32 bits of information.

If there are going to be that many addresses in play (and note that for technical reasons you have to be able to address every byte you want to access, not just the first byte), you can't use 32-bit.

The only real cost you pay for 64-bit pointers is the space they take up in memory and cache. Generally speaking, this is an acceptably small portion of your program's active memory compared to the stuff being pointed to. Exceptions include pointer-heavy data structures, like linked lists, chained hash tables (ie, linked lists again), and self-balancing trees.

Obviously there are some cases where it is a more significant cost than others.

You can essentially emulate mixed 32-bit and 64-bit pointers by allocating a 4GiB chunk of memory, and computing offsets into it. Implement your own malloc and free on top, and call it a day. That's what basically has to happen no matter how you slice it.
>>
>>55940528
Not him but you really could sell anything to those hackforums kids
>>
>>55938046

Has he tried actually plugging his C64 in?
>>
>>55940444
>looks like that one macfag

It's a Commodore Vic 20 you penis
>>
>>55940528
>>55940571

It could be.. I know aim bots and other simple stuff could sell for $50 or $100 in large amounts.

The problem is sometimes the work of reversing and anti cheat advancement made things really painful. A patch could come out and you'd be on a death march to update for it.
>>
>>55940566
>>55939672
Oh, and to elaborate a bit: remember, memory access is virtualized from your program's perspective. The CPU will need to speak 64-bit addresses with the RAM no matter what because it needs to be able to address all the memory from every program on the computer.

In theory there could be some separate RAM allocated just for 32-bit addressing, but that's a heck of a lot of architectural support just for this incredibly niche use case of margin performance and efficiency improvement are best.
>>
Say I have a directory full of zip files and I want to compare the checksums of their contents to those in a dat file. Do I have to unzip all the files?
>>
>>55940740
Depends. Do you want to validate the checksums within the zip, or do you just want to use the checksums that are actually there?

Also, are the checksums in your dat file CRC32? (I do of course mean the version zlib uses.)

If the checksums are not CRC32, or you want to actually validate the files in the zip, then yes, you have to unzip all the files.

If they ARE CRC32, you can either get APPNOTE.TXT and code your own information reader, or use Info-ZIP's unzipper (as used on Linux) and run "unzip -lv foo.zip", and then steal the CRC32 from there.

Something like this:
unzip -lv Untitled.zip | head -n -2 | tail -n +4 | sed 's/.* \([0-9a-f]\{8\}\) \(.*\)/\2 \1/g'
>>
File: 1435458869.01.S001.LXXXXXXX.jpg (88KB, 600x770px) Image search: [Google]
1435458869.01.S001.LXXXXXXX.jpg
88KB, 600x770px
Any y'all fampais read this? How is it?
>>
>>55941201

I saw it a while back never really picked it up though. Realized it wouldn't be worth dropping the money on it. I don't particularly like 3d games as much as I do 2d games or Isometric games.
>>
>>55939992
convincing an entire field of smug assholes that there's actual work to be done. after that, idk. i doubt our current computers are powerful enough to make much actual progress unless you have access to a super computer. the idea is moving towards actual general intelligence or at least inventing some machine learning method that works better than what's in use right now (which is much easier than general intelligence, but also infinitely less useful).
>>
>>55938046
Trying to program a dial plan over a serial bluetooth connection with AT commands. I've tried some libraries for node and python. Neither receive a response. I can use screen on tty without issue; Samsung flip phone acknowledges commands.

Any experience or advice?
>>
>>55940308
For actual injection, just CreateProcess + LoadLibrary. I don't really remember how the damn thing went though as it's been a few years.
>>
Could you train a neural network to correct jpeg artifacts?
>>
>>55939963
lol rust still uses pointers you moron and they are still 64 bit addresses

look in the source of the rust compiler, it has a lot of specialized types for storing 32 bit offsets into some huge piece of data
>>
>>55941382
if you know what the original image looked like, then yeah. http://waifu2x.udp.jp/ this uses CNNs to do that, but it only works for line art (especially anime drawings). i think photographs are much to irregular to be able to apply this, but you could train a version for portraits or for mountains, etc.
>>
>>55938918
WHY does static member initialization have to be so fucking weird in C++ ?
>>
https://github.com/sviperll/higher-kinded-java

how do you feel about this
>>
OK so I have a bunch of animations, and a list that keeps track of which animations need to be updated, and once the animations are done, I remove them from the list.

This is what I'm doing right now, but it looks retarded (or is this the "right" answer?:

        List<AnimationController> delete_list = new List<AnimationController>();
foreach(AnimationController animation in master_animation_list)
{
animation.updateAnimation();
if(animation.done == true)
delete_list.Add(animation);
}
foreach(AnimationController delete in delete_list)
{
master_animation_list.Remove(delete);
}


Any suggestions?
>>
>>55941631
entirely indifferent
>>
>>55941636
Is this Unity? Animation Controllers are for a stack of animations they are not each one animation file, so yes, you done fucked up.
>>
>>55941663
I'm not using the Unity animation controller bullshit, I wrote my own thing that just lerps an object from one Vector3 position to another
>>
what do you think is a good scripting language for a game? I was wondering about php or ruby. I know a lot of people use lua.
>>
>>55941828
people use lua since there are tons of libraries out there

others use python
don't use php
>>
>>55941828
Literally why? It's much, much better to not use a scripting language and just use whatever language you use for your game programming. If you absolutely NEED a scripting language, use AngelScript.
>>
any c++ mac devs here
>>
File: 1468970355418.jpg (11KB, 166x231px) Image search: [Google]
1468970355418.jpg
11KB, 166x231px
>>55938852
>delete this
>in the destructor
delet this
>>
File: 39431.png (306KB, 593x540px) Image search: [Google]
39431.png
306KB, 593x540px
>>55941867
>c++
>mac
>dev
>>
>>55941828
If you have to sandbox it, use Lua

Otherwise, Ruby's API is alright, though I don't have much experience with it

Python's API is a garbage-collection nightmare

AngelScript is alright if you're using C++ for your base engine, if you don't like C++ you'll probably not really like AS as it's also trial-and-error as to whether you pass by val or by ref

If you want any idiot to be able to edit it, roll your own
>>
>>55939220
It's alright, unfortunately it runs off the JVM and you actually have to use types from java with introspection (sometimes) because who knows.
>>
>>55938046

Anyone else working on a pokemon go bot? it seems that is flavor of the month on shithub
>>
>>55941884
plz
>>
File: pokemon go-y.png (84KB, 645x512px) Image search: [Google]
pokemon go-y.png
84KB, 645x512px
>>55941987
Yes goyim, farm pokeymans for big data...
>>
>>55941987
does that not violate some kind of contract
>>
File: DELETE THIS.gif (602KB, 640x360px) Image search: [Google]
DELETE THIS.gif
602KB, 640x360px
>>55941880
>>
>>55939672
>>55939787
Just use a 32bit cpu then you fucking goon

problem solved.
>>
File: fixed.png (89KB, 645x512px) Image search: [Google]
fixed.png
89KB, 645x512px
>>55942038
>>
>>55942050

If you consider the terms of service to be a contract...

I'll see you in court, nintendo.
>>
>>55940013
How did a successor to C attract so many webshits
>>
>>55942050
only if you use it
>>
File: le rice merchant.jpg (27KB, 314x437px) Image search: [Google]
le rice merchant.jpg
27KB, 314x437px
>>55942099
>>
File: 1368463813434.jpg (13KB, 250x241px) Image search: [Google]
1368463813434.jpg
13KB, 250x241px
>point-free style
>>
File: himegoto considered harmful.png (1MB, 1000x1400px) Image search: [Google]
himegoto considered harmful.png
1MB, 1000x1400px
>>55942175
>successor to C
C was a trap language
>>
>>55942239
stupid frogposter

apply yourself
>>
File: 84d980e7b8.png (5KB, 598x183px) Image search: [Google]
84d980e7b8.png
5KB, 598x183px
>Want to search for a property in a List of objects
>can't think of how to do that procedurally
>remember that LINQ exists
I feel dirty.
>>
If you want to hear a cute woman explain some FP terms
https://www.youtube.com/watch?v=uwrCQmpZ8Ts
>>
>>55942297
>null checking

nice language :^)
>>
>>55942322
I think the linq query would return an empty IEnumerable, not a null, so that might be a silly comparison? I just included it anyways.
>>
>>55942297

Don't feel dirty. LINQ is the best.
>>
Jeg har drukket en flaske vin, hva bor jeg skrive, og på hvilket programmeringsspråk? Takk.

Hvis du forstår ikke hva jeg har skrevet, må du gå til skolen igjen.
>>
>>55942381
Mummy, please teach me C#, I did a poo on the floor because I couldn't understand the tutorials.
>>
trying to figure out what to do with my new server since niantic changed their api and fucked my pokemon tracker.

anybody got suggestions?
>>
>>55942411

It's really not that hard.
>>
>>55942381
It was solely because I couldn't think about it procedurally. But knowing linq is great, when I started reading a SQL book it looked almost the same.
>>
>>55942438
Mummy, the poo is big and smelly because I got very upset. It's a lot harder than Python. Please mummy, daddy said you would.
>>
>>55942458

I actually just finished a course on SQL this past semester. Coming from LINQ, a lot of it just clicked.

It was nice.
>>
>>55942387
What language is that? I'm learning swedish on my own and that kinda looks like it, so I'm guessing danish or norwegian?
>>
>>55942481
Norsk.
>>
File: pajeet finds street.jpg (22KB, 325x326px) Image search: [Google]
pajeet finds street.jpg
22KB, 325x326px
>in a rut
>looking for some good project ideas to waste time on
>do a jewgle search
>come upon this site http://projectsgeek.com
wew
>>
>>55942669
>in a rut
>looking for some shitty memes to not laugh at
>scroll through /dpt/
>come upon this post
wew
>>
File: wew butthurt.png (446KB, 551x669px) Image search: [Google]
wew butthurt.png
446KB, 551x669px
>>55942684
Too much curry made your butt hurt, Ranjeep?
>>
Why does Java even exist? It seems like an inferior version of C#. I don't get why anyone would use Java over C#.
>>
>>55942788
>Why does C even exist? It seems like an inferior version of C++
>>
i have no idea what im doing
>>
>>55942788
>muh jvm
>muh libraries
>muh popularity
i.e. excuses made by people so accustomed to streets filled with shit they can't have it any other way
>>
>>55942817
just use needle notation with arrows senpai
>>
Quick question. Is there anyway I can make a function who takes in a struct or a structed derived for that as a parameter.
Its a pretty lengthy function and nothing changes between the 2 so I dont want to overload the function to basically have 2 copies of the same function.
Should I look into how templates work.
>>
What's the difference between multi-dimensional arrays and jagged arrays?
Aren't they pretty much the same thing?
>>
>>55942849
multi-dimensional arrays aren't jagged
>>
File: agdgprograms.png (8KB, 797x83px) Image search: [Google]
agdgprograms.png
8KB, 797x83px
Is this true?
>>
>>55942861
unless you're working with a language with automatic or dynamic length arrays
>>
>>55942669
kek, they are like animals
>>
>>55942867
If you're using a functional language then yes.
Avoid if statements like the plague.
>>
>>55942835
what the hell is that
>>
>>55942861
Right but what does jagged mean in this context and how does it differ from multiple dimensions on an array type?
>>
>>55942880
>Most questions should be answered by a short example:
import Control.Arrow.Needle

nTest :: (Int, Int, Int) -> (Int, (Int, Int, Int))
nTest = [nd|
aLabel:==={div 2}===\
}====\ \
{uncurry (+)}==\=================) \ (==>
}====/ \ \
\ \=={nTriple}=>
\
}=={uncurry (-)}====:aLabel
|]

nTriple = [nd|
}==\==>
\==>
\==>
|]


>>> nTest (3,2,1)
(5,(-1,-1,-1))
>>
>>55942878
>>55942867
In that case, pattern matching are the way to go. Learning a functional language is a good experience and will help even when programming in a imperative/OOP language.
>>
>>55942878
Is Lisp functional? It doesn't have fancy pattern matching to conceal conditionals.
>>
>>55942893
Jagged means the arrays might not have the same length, e.g.

[ [0,1,2,3,4], [0,1,2], [0,1,2,3,4,5,6,7] ]
vs
[ [0,1,2], [0,1,2], [0,1,2] ]
>>
>>55942874
ur mum was an animal in my room last night
>>
>>55942893
Jagged are arrays of arrays. The 'child' arrays can differ in length. Multidimensional languages are regular.
>>
>>55942907
>Is Lisp functional?

">""" >yes """ "
>>
>>55942895
ta, I'll just blow my brains out
>>
>>55942907
Dont listen to this guy. Conditionals are needed to implement pretty much anything in any language.
>>
>>55942895
oh my god what the ever loving fuck
>>
>>55942918
I meant arrays, I was reading other comment and got languages in my brain.
>>
>>55942922
>>55942929

look at nTriple

} is input
> is output

}==\==>
.....\==>
.....\==>

it comes out of the input, and heads down using \

"it" could be anything, arrows are extremely generalised
could be a stream, a network signal, data, multiplexed data, etc
>>
>>55942924
Conditionals? Yes. If statements? No.
>>
>>55942924
that's like saying you should use goto because it's used to implement all the nice features in languages
>>55942895
this looks like absolute cancer, but i kind of like it
>>
File: demo_areas.png (87KB, 1044x618px) Image search: [Google]
demo_areas.png
87KB, 1044x618px
>>55942175
Successor to C++*

also probably because web is most popular shit
https://blog.rust-lang.org/2016/06/30/State-of-Rust-Survey-2016.html
>>
>>55942944
so what nTriple does is

nTriple x = (x,x,x)
but using needle notation

}==\==> -- part 1
\
\==> -- part 2
\
\==> -- part 3

for this simple example obviously
nTriple x = (x,x,x)
is preferable

but if you're working with some other stuff arrows can be useful
>>
>>55942964
whoops, the \s should all be lined up
}==\==> -- part 1
\
\==> -- part 2
\
\==> -- part 3


you can make tunnels/bridges using
    \
===)\(===>
\

so the vertical and horizontal don't intersect

you can make sort of portals using labels

====:label

label:====>
>>
>>55942239
composition (and partial application) is based, don't know why you are greentexting
>>
>>55942977
>based
>>>/pol/
>>
>>55942964
>>55942973
basically it's like turning ascii flowcharts into actual code

{ ... } embeds the computation
e.g.
uncurry (+) = \(x,y) -> x + y
}==\
{ uncurry (+) }==>
}==/

-- puts the two inputs into "uncurry (+)" and pulls out the 1 output
>>
>>55942953
An if statement is a goto. That being said its bad progamming to use a goto since the code can be written without explicitly calling a gotos. You need them but the language takes care of it for you. conditionals cannot be replaced.
>>55942945
I dont see the difference between an if and a conditional. Can you implement a while loop in a functional language without an if statement?
>>
How do I write a Linux GUI app quickly, should I use Lisp or Scheme or something?
>>
>>55943005
Haskell:

myFunction b = if b then 1 else 0

compare:
myFunction True = 1
myFunction False = 0

or:
myFunction b | b = 1
| not b = 0
-- (you could also use | b == True = ...)
>>
>>55942922
>>55942929
>>55942953
http://scrambledeggsontoast.github.io/2014/09/28/needle-announce/
>>
>>55943016
Use Qt.
>>
>>55943019
How do you think that pattern matching works?
>>
>>55942985
Tell me where the evil Nazis hurt you.
>>
>>55943036
when people say "no ifs" they mean no ifs not that your compiler can't use or be written with ifs
>>
>>55943005
>conditionals cannot be replaced.
yes they can
>>55943020
reminds me of Befunge just a little bit
>>
>>55943005
While loops are really, really rare. As the values are immutable by default, most whiles are implemented as a recursive function with a base case in a match, so it can stop. But even in procedural languages, you can use bitwise math, and use of flags to do a jump that is not conditional to the right place.
>>
>>55943005
You're wrong, and you're probably a doggo so it's okay. Conditionals are implemented using polymorphic functions of type
∀α. α → α→ α
>>
>>55943053
inb4 his uni didn't teach type theory
>>
>>55943046
Hey anon, are you still writing your OCaml variant? One time 私 was reading about type inference, and it suddenly occurred to me that we don't need string static typing, we can simply halt on a type error, like the knights of the eastern calculus do. つづく!
>>
http://esolangs.org/wiki/Funciton
wew
>>
>>55943077
You know, if you would simply respect other people and give them the benefit of the doubt, then the world would be a nicer place.
>>
Do sometimes you have a brainfart and end using an entire different solution that the simple and obvious one?

The other day, after months away of Java, I was helping a friend of some code. There was a point where was need to save two ID's to pass to a SQL select. Well, instead of the obvious solution of using

int a=x.getFirstID(), b=x.getSecondID();


I used

int[] ids = new int[2];
ids[0]=x.getFirstID();
ids[1]=x.getSecondID();


I was asked about it some days later and was ashamed of that brainfart.
>>
>>55943149
それは私たちのすべてに起こります。時には、あなたは風があなたの服を取るようにしなければなりません。
>>
>>55943168
Yeah, easily in my top five vaporwave releases of this year so far.
>>
>>55943093
>are you still writing your OCaml variant
if you can call it that, yeah. it's gonna be an ML but it's probably not gonna end up that similar to OCaml when I'm done with it.
>>
File: win32tier.png (1MB, 1000x5500px) Image search: [Google]
win32tier.png
1MB, 1000x5500px
Can I just say right now that Win32 sucks?
>>
>>55942706

>ranjeep
indian names are hilarious bruh why not use a real one

>>55938046

I'm tryina program a pic16f877a microcontroller to move a servo and display its speed on some 7seg LED displays. Sounds simple but I'm kinda new to this stuff. If anyone on /g/ has any ideas how I can input data from a keypad to control a servo's speed, it'd be much appreciated.

Right now I've written a program to use RealTerm to send serial data to the microcontroller from my laptop in order to control the speed and direction of the servo but I wanna use a separate keypad for that (to obviate need for a computer). Basically when the program detects inbound serial data it throws an interrupt and sticks the data in an array which it converts from ascii to numeric value and uses that to sets the servo speed (timer1 and CCP1 interrupts are used to send pulses of data to the servo in the program, the duration of a high pulse every 20ms determines servo speed).

It also uses a timer0 to occasionally throw an interrupt and update the 7-seg LED displays.

I have this keypad that I'm trying to replace the laptop with for the input. It's just a numeric keypad, it has 8 pin outs that presumably send the associated ascii for each digit.

I'm not very proficient with programming microcontrollers however so I'm wondering how I'll go about doing this. Someone suggested utilizing microcontroller's EEPROM to store data input from the keypad... anyone have any tutorials /suggestions I can use for this sort of thing? Here's my code thus far:
>>
>>55943201
So, hva synes du om removing static typing? Ĝi estas bona ideo, ĉu ne? つづく!
>>
>>55943218

#include <htc.h>
__CONFIG (0x373A);

#define _XTAL_FREQ 20000000

#define cycPerUs 2.5
#define reload20ms 65535 - 20000 * cycPerUs
#define PW1500us 65525 - 1500 * cycPerUs
#define cycPerCent 5

signed char servoSpeed;
unsigned char speedDisp[4];
const unsigned char segmentTbl[] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99,
0x92, 0X82, 0xF8, 0x80, 0x90,
0xFF, 0xFF, 0xC6, 0xFF, 0xF0};
volatile unsigned char RCarray[4];
volatile bit RCready;

void main (void) {
TRISC = 0xC0;
TRISD = 0x00;
OPTION_REG = 0xD6;

T0IF = 0;
T0IE = 1;

T1CON = 0x11;
SPBRG = 129;
TXSTA = 0b00100100;
RCSTA = 0b10010000;
RCready = 0;

CCP1CON = 0x0A;
TRISC4 = 0;
TMR1IF = 0;
CCP1IF = 0;
TMR1IE = 1;
CCP1IE = 1;

RCIF = 0;
RCIE = 1;
PEIE = 1;
GIE = 1;

servoSpeed = 0;
RCready = 0;
CCPR1 = 65525 - 1520 * cycPerUs;

while (1) {
if (RCready == 1){
RCready = 0;
unsigned char i;
for (i = 0; i < 4; i++) {
speedDisp[i] = RCarray[i] - '0';
}
servoSpeed = 100 * (RCarray[1] - '0') + 10 * (RCarray[2] - '0') + RCarray[3] - '0';
if (RCarray[0] == '>') {
servoSpeed = -servoSpeed;
}
CCPR1 = PW1500us + (int)(servoSpeed * cycPerCent) - 20 * cycPerUs;
}
}
}



and the interrupts...
>>
>>55943235
void interrupt ISR (void) {
if (RCIF && RCIE) {
unsigned char RCdata;
RCIF = 0;
RCdata = RCREG;
TXREG = RCdata;
static unsigned char i = 0;
if (RCready == 0) {
if (RCdata == 0x0D) { //CR check
RCready = 1;
i = 0;
} else {
RCarray[i] = RCdata;
i++;
}
// CCPR1 = PW1500us + (int)(servoSpeed * cycPerCent);
}
}

if (CCP1IF) {
CCP1IF = 0;
RC4 = 1;
}
if (TMR1IF) {
TMR1IF = 0;
TMR1 = (int)reload20ms;
RC4 = 0;
}

if (T0IF && T0IE) {
T0IF = 0;
static unsigned char j = 0;
j++;
if (j > 3) {
j = 0;
}
PORTC |= 0x0F;
PORTC &= 0xF7 >> j;
PORTD = segmentTbl[speedDisp[j]];
}
}
>>
>>55943218
Oh, I'm sorry. What's your real name? Peshwari? Tikkamasala?
>>
>>55943225
nah, im sticking with static types
>>
>>55943253
What's the deal, afraid of sneks? You might like the dynamic side...
>>
>>55943267
i like Scheme, though not as much as i like my static typing.
>>
>>55943276
I can see we're not going to have any success with you like this. *sigh* okay boys, tie him up and turn him into a snek lady or sacrifice him.
>>
>>55943250
Subramaniam
>>55939165
>>
>>55943207
Oh the ActiveX excitement.... those were the days
>>
>>55943299
Too many syllables, can we call you Subby?
>>
File: jabba.jpg (89KB, 1280x1021px) Image search: [Google]
jabba.jpg
89KB, 1280x1021px
>>55943288
>snek lady
got you covered senpai
>>
>>55943019
great, now do a while loop.
Making a helper function to replace an if statement is literally retarded.
>>
File: UI.png (29KB, 630x477px) Image search: [Google]
UI.png
29KB, 630x477px
I want to write an UI wrapper so I can design windows as something like that:

Window [ Grid(3, 2)
Size(640, 480)
Title "Hello world!" ] [ Label [ GridPosition(0, 0)
Columns 2
Text "What's your name?" ]
TextBox [ GridPosition(1, 0)
Columns 2
Name "NameBox" ]
Button [ GridPosition(2, 1)
Text "Click me!"
OnClick(fun _ ->
getTextContent "NameBox"
|> sprintf "Hi, %s!"
|> message [ OK
Alert
Title "Nice to meet you" ]) ] ]


Into the image.
>>
>>55943561
looks like a job for Lisp
btw use 2 space tabs if you're gonna have that level of nesting
>>
>>55942175
>>55942956
not really a successor to either of those, more like, another in the long line of failed java replacements
like d and go
>>
>>55943576
I wrote a child per line and made Visual Studio format it. It is somewhat better to see all that is happening, but yeah, too wide.

I was thinking in using F#, but I'm not sure if it's too big or if I should set a public git to have feedback and give me less chance to get bored. Also, not sure if it's a good syntax for window design, I was inspired by a html helper from Suave.
>>
>>55943218
If I'm understanding this correctly I think you should use a ringbuffer.
>>
>>55943561
>What's your name?
>Cuckcake
>>
Okay, what the FUCK is going on?

I'm writing a simple thing in C# and sorting a list of objects. Now I was told that .OrderBy is a stable sort, but this is not the case. Some of my elements with the same value are swapping, seemingly at random. It's only really noticeable if I'm calling the sort 200/300 times a second.

Is .OrderBy a stable sort or not? Have I been lied to?
>>
>>55943936
Is it a list or an array? I think there's a faster but unstable version for arrays. Why are you sorting something 200/300 times a second?
>>
>>55944042
Well I'm not planning on sorting it 200/300 times a second in the final product, but I'm doing it now to check for bugs. I position a bunch of sprites based on their position in this list. When it's unstable and two identical sprites swap locations with each other it looks really shitty.
>>
>>55943611
Go has lots of users unlike rust/D

https://github.com/golang/go/wiki/GoUsers
>>
File: dPo8c.jpg (385KB, 994x526px) Image search: [Google]
dPo8c.jpg
385KB, 994x526px
Working on AI. I'm trying to find all possible permutations of placing items from a given string array in three separate arrays: one being size 2 another being size 3 and another being size 4.

This is O(n!) right? I'm writing a recursive method for this but don't know how to approach it. Any ideas?
>>
>>55944095
The three separate arrays are also a combination so it would be a permutation of size 9
>>
>>55944075
>>55944042
>>55943936
Turns out .OrderBy IS a stable sort and some retard in my codebase had rolled his own sort function that was being called fuck knows where and reordering my shit, but only every few seconds.
>>
File: Stack is growing.png (13KB, 666x210px) Image search: [Google]
Stack is growing.png
13KB, 666x210px
>>55944095
I wrote a function that gives a list of all list permutations. It works by first filtering all elements so all elements are unique, so you don't have to do twice the same work for the same element. Then it removes that element once from the original input and repeats. Do it for all elements and you get all permutations.

let permute s = 
let removeOnce i s =
let rec innerRemove i s =
[ match s with
| a :: b ->
if a = i then yield! b
else
yield a
yield! innerRemove i b
| [] -> () ]
Seq.toList s |> innerRemove i

let rec innerPermute s =
[ match s |> List.distinct with
| [ _ ] -> yield s
| u ->
for i in u do
for b in (s
|> removeOnce i
|> innerPermute) do
yield i :: b ]

innerPermute s


Be aware that it can be quite heavy for large inputs. Pic is related.
>>
>>55942867
Yes. If you are using a functional language use pattern matching or guards. In OOP languages use dynamic dispatch.

Simple pseudocode OOP example of implementing not without ifs, where := is definition:

true.not() := false
false.not() := true

where the definitions are in the true and false classes. Note how in this case, calling the not method on a boolean does not involve any ifs.

Similarily you could define the or gate in the following way:

true.or(x) := true
false.or(x) := x

etc etc. You can implement a lot of control flow in OOP without ever using if statements, because of how dynamic dispatch works. Using an if statement often mean you are doing procedural programming rather than using the paradigm of the language you are writing in.

Pattern matching in FP is quite similar but more concise and in some ways more powerful.
>>
>>55944543
>you shouldn't use if statements if you're writing in OOP

I knew OOP was retarded, but I didn't realize how retarded
>>
File: vendor.jpg (11KB, 313x20px) Image search: [Google]
vendor.jpg
11KB, 313x20px
>trying out intrinsics for the first time
>>
>>55944526
Thanks anon, yeah I've noticed working with permutations is a bitch on the CPU. Have about 50k inputs to work from. Hopefully it doesn't kill my CPU
>>
>>55944733
Checked. I don't think your CPU is Genuine, bro
>>
>>55939681
New Game programming spin-off when?
>>
>>55944733
>this
Reminds me. What is that new set of CPU features Intel were gonna ship that had a in-cpu public/private key and some shit. It would allow you to ship encrypted binary that the user had little to no hope of modifying or even inspecting effectively.

I'm interested in that.
>>
>>55944829
but isn't this place "freetard - the general"?
>>
>>55942387
Dumma norrmann
>>
>>55944835
Nah. Fuck the consumer.
I'm thinking for a game. So since I'd have to support amd I'd ship two copies. One where I don't use Intel SGX and one where I do.
I could alter them so the non SGX code isn't the SGX code but even so because I'm only accepting packets encrypted with their private key it would work fine either way right? The aim is to prevent cheating. The amount of inconvenience you have to deal with to avoid cheating is frustrating. I also like the idea of having a hardware ban method.

I have to look more into this.
>>
>>55942387
Skriv D-kod. Du kommer nog att gilla det.
>>
If someone wouldn't mind helping me I would greatly appreciate it. I feel like some of my Python scripts have too many elif statements.
http://pastebin.com/6LVfRKJi
>>
>>55944992
I'm not sure if it's 'pythonic' enough for python people but I think it looks fine. For an encrypt encrypt() function. The problems with tons of conditional statements is if they bleed out into the rest of the code.

Code shouldn't be 'beautiful' it should be functional and easy to maintain.
>>
Can you help me please?

int main (void) {
int i;
foo3(globalvl);
for(i = 0; i < 2; i++) {
printf("globalvarno: %d \n", globalvl[i].varno);
printf("globalvarnattno: %d \n", globalvl[i].varattno);
}
}

static void foo3(VarList *vl) {
VarInfo *vvl = malloc(2*sizeof(VarInfo));
vvl[0].varno = 1;
vvl[0].varattno = 2;
vvl[1].varno = 1;
vvl[1].varattno = 1;
int i;
for(i = 0; i < 2; i++) {
printf("varno: %d \n", vvl[i].varno);
printf("varnattno: %d \n", vvl[i].varattno);
}

vl = malloc(2*sizeof(VarInfo));
int j;
for(j = 0; j < 2; j++) {
vl[j].varno = vvl[j].varno;
vl[j].varattno = vvl[j].varattno;
}

int k;
for(k = 0; k < 2; k++) {
printf("kvarno: %d \n", vl[k].varno);
printf("kvarnattno: %d \n", vl[k].varattno);
}
}
>>
>>55945071
forgot typedefs...
typedef struct varinfo
{
unsigned int varno;
int varattno;
}VarInfo;

typedef VarInfo VarList;

static void foo3(VarInfo *vl);

VarList *globalvl;
>>
>>55945055
Yeah. Although sometimes I feel like I improve when I manage to get the same functionality with less lines. I can't find a way to do it with this one. I don't mind adding arguments into the function.
>>
>>55945083
Yeah that's not a good 'I'm improving' feeling you have there. Less lines can very often be worse.

I'd probably construct the function to take an argument for which encryption you want to use and what string and it returns a dictionary with the encrypted string and what encryption was used. Keep the input outside the function.
It's obvious stuff of course. You probably already had that planned.

If you're feeling wild I'm pretty sure you can do some reflection stuff and have it attempt to call whatever name of the encryption function that's passed in and return an error if it didn't find it in any of the imported packages. But I haven't really gone that far with python ever.
>>
>>55943500
What the fuck are you talking about?
It's not a helper function you fool

Why would you do

f b = if b then .. else ..
when you could do

f True = ...
f False = ...

or

f b | b == True =
f b | b == False =
(or b, not b)
>>
>>55945071
>>55945081
What is the problem? You're not freeing your allocated memory. You have problematic names vvl and vl.
Is this Finnish? Write in English.
>>
>>55945071
>vl = malloc
This has no effect on the variable passed into the function.
>>
How do I multithread with C#? Anything I should know in particular? I have a main game loop that handles rendering, UI, etc. It's a turnbased game and I don't want the game to slow down to 0FPS because the opponent is calculating their moves, so I'm gonna put the AI on a separate thread. My plan is this:

Main loop runs forever, renders frame, whatever. Every frame it's the AI's turn, it checks a bool to see if the AI has submitted their turn yet. If it has submitted its turn, then it peeks inside and resolves the turn. Otherwise it renders the frame and tries again.

Meanwhile the AI thread just goes full throttle trying to figure out its turn and then once it's done, it sets its bool to true and sleeps until its turn comes up again.

Will this work as expected?
>>
>>55945178
Yeah that's probably his issue.
>>55945071
C is always pass by value. You're giving it a copy of a pointer. Unless you modify the data pointed to of what you pass in the change won't be reflected outside.

So what you want to do is pass in a pointer to a VarInfo pointer (VarInfo**). Then you can do *vl=malloc
>>
>>55945204
Yes. It works fine. If you had a more granular scale than an entire 16ms frame you may have had to worry about read and write barriers but you don't.

As long as you accept there being potentially 1 frame of lag.
>>
>>55945160
Well it's still just a ruff draft. I just wrote it a few moments ago.

>If you're feeling wild I'm pretty sure you can do some reflection stuff and have it attempt to call whatever name of the encryption function that's passed in and return an error if it didn't find it in any of the imported packages. But I haven't really gone that far with python ever.

That's kind of what I'm going for. I haven't been using Python that long. I feel like this function should only have to be a few lines though.
>>
>>55945288
OK. Well I looked it up. Its literally
 
import encryptionlibrary
....

encryptionMethod =getattr(encryptionlibrary, "aes")
encryptionMethod(stringToEncrypt)
>>
>>55938861
Apart from the retarded type composition, as std::string and std::vector have a very similar interface, thus you'd get loads of functions overriden. There is no standard name

This is a MyVector of <T> deriving from std::vector of <T> and std::string.
>>
>>55941562
it's not
>>
I'm learning canvas, are there any tips or tools to use to make things easier?

What do you suggest to know about canvas the most?
>>
>>55938918
unsigned type for counting anything is retarded unless you defend yourself from an underflow.

if ( count_ > 0 )
--count_;
else
// handle very fatal error here
>>
>>55945377
It only makes sense to use unsigned types for the size of things or for array indexes.
>>
>>55939672
Because we use 64 bit target platforms. Switch to 32bit if your task allows you to do so, or make your IDE display pointers without leading zeros.
>>
>>55945204
Assuming you're using Unity you can just use Coroutines.

If you're not using Unity then check what is and isn't threadsafe and dump all that work onto another thread with something as simple as
Task.Factory.StartNew(() => DoThing());
>>
>>55940308
>Windows just lets you write arbitrary data into other processes address space.
Seriously what.
>>
>>55942387
Fuck off and kill yourself.
>>
>>55945400
I have yet to find a situation where usage of an unsinged type did not backfire.

There are very few niches where such types make sense, such as serialization or raw memory usage. General, garden variety programmers should avoid them, especially in control loops or counters.
>>
>>55938982
Someone tell me how to work from home already, the outside air makes my neck come out in a rash
>>
>>55944793
Called GNU Game
>>
>>55944992
>>55945055
elif statements are pythonic, since there is no switch statement
>>
File: bool.jpg (39KB, 694x134px) Image search: [Google]
bool.jpg
39KB, 694x134px
what's the (7) in VS's watches?
>>
>>55945506
>There are very few niches where such types make sense,
Sizes and array indexes are hardly niche.
The size_t type is very common in C.
>>
>>55945582
The exact value of the boolean

Can cause issues if you've got something like
True (3) and True (4) because == might fuck up
>>
>>55943936
lol.

The C# compilation packages would actually invoke the compiler via shell exactly three times then quit, not checking for error conditions (or reporting them).
>>
Would it be retarded to get a degree at a community college if I already know how to program just so I don't get my applications thrown in the garbage? I don't particularly want to go into debt just to go get some meme degree, I just want to do the bare minimum to not make my application look fishy.
>>
>>55938046
x-posting from /sqt/

I have this list in python, that should return proper values. But only returns 0 when printing list elements. Any ideas?
world = [[1,0,3],[2,3,4],[5,6,2]]


for i in range(0,dim):
for j in range(0,dim):
print(str(world[i][j]), end=" ")
print("")

Why is this not working? Why does it only print
0 0 0
0 0 0
0 0 0

Instead of
1 0 3
2 3 4
5 6 2
>>
>>55945811
Your example works for me. Is 'world' being shadowed or overwritten somewhere else?
>>
>>55945832
That's weird

dim = 3
#world = [[1 for y in range(dim)] for x in range(dim)] # Instantiated here to save memory


def render(world): # Render function
for i in range(0,dim):
for j in range(0,dim):
print(str(world[i][j]), end=" ")
print("")

def getNeighbors(world,x,y): # Returns the amount of cells adjacent to (x,y)-cell
count = 0
count += 1
if dim > x >= 0:
if world[x+1,y]:
count += 1
if dim > y >= 0:
if world[x+1,y+1] == 1:
count += 1
return count

def rules(world,x,y):
# Here the algo rules will be, given a pos, returns if alive or dead (0 or 1)
return 0

def gameLoop(world):
while True:
updateTiles(world)
render(world)
break

def updateTiles(world):
for i in range(0,dim):
for j in range(0,dim):
world[i][j] = rules(world,i,j)

def testenv(world):
world[0][1] = 1
world[1][0] = 1
#print(str(getNeighbors(0,0)))
return world

def main():
print("Hello world!\n")

world = [[1,0,3],[2,3,4],[5,6,2]]
world = [["1" for y in range(dim)] for x in range(dim)]
world = testenv(world)
gameLoop(world)

print("\nGoodbye world!\n")

main()


This is all the code. I first thought that the error occurred when I had world global, so I used it as an argument instead, some crux tho,
>>
>>55945854
>world = [["1" for y in range(dim)] for x in range(dim)]
Ignore this line by the way. Just added it to see.
>>
How much commenting is too much commenting?

#!/bin/bash

#USAGE: rename.sh SOURCE_FILE DESTINATION

#set variables based on arguments passed
file=$1 #first argument should be the name of the file to be processed
dest=$2 #second argument should be the name of the directory in which to be copied
src=$file #the original name and location of the file shall be held
file=`basename "$file"` #the file variable shall be reused to refer to the end filename, starting as a basename

#If a file exists with the same name, add a numeric value to the filename and try again
duplicator(){
c=1 #the numeric value should start at 1
while [ -e "$dest"/"$file" ]; do #keep testing until the value of file doesn't exist
file="${file%.*}_`printf %03d $c`.${file##*.}" #set file in a format FILENAME_NUMBER.EXTENSION using regex and printf
let c++ #add 1 to the numeric value before trying again
done
}

#main function: move the source file to the destination with the new numbered filename
duplicator #call duplicator function
echo "moving $src to $dest/$file" #echo the source and destination
mv "$src" "$dest"/"$file" #move source to destination, edit based on desire
>>
>>55945854
>update
>then render
>given that render amounts to zeroing the whole shit
>why is it all zeroed, gee!
KYS
>>
>>55946035
*update amounts to zeroing
>>
>>55946035
Why does render zero the matrix? It just prints..
>>
>>55946043
update does
>>
>>55946035
>>55946051

OH FUCK now I see. Thanks mayne, feel like a tard now
>>
>>55946055
das cuz you are
>>
>>55946061
Fuck man I have a masters in mathematics haha
I hate myself now
>>
>>55946085
give it to me
>>
>>55946145
Non-transferable m80 :^)
>>
>>55946188
too late, it's mine now
>>
>>55944593
Well, this OOP retardedness is why python doesn't have a switch case. You are supposed to write this "pythonic" code:

def numbers_to_strings(argument):
switcher = {
0: "zero",
1: "one",
2: "two",
}
return switcher.get(argument, "nothing")

which creates an object and uses its methods, as opposed to a more C-like

function(argument){
switch(argument) {
case 0:
return "zero";
case 1:
return "one";
case 2:
return "two";
default:
return "nothing";
};
};

I'll leave you to decide which one is more concise.
>>
>>55946212
:^(
>>
>>55946226
Actually, using an array as a lookup table is much better than a switch statement in that case.
>>
>>55945978
I think that might be a bit overkill, but I rarely add comments anyway. I've only written software nobody will ever use.
>>
>>55946251
Exactly! It also allows you to add or remove cases at runtime. OOP code can be more arcane, but it definitely has its usecases.
>>
>>55946289
Lookup tables have nothing to do with OOP.
>>
Can somebody explain to me the value of using pointers in programming? I haven't had any projects where I thought I needed to use pointers, but then again I haven't done any advanced projects yet.

Also what's the benefit of using Java to program? Looking at GitHub, I haven't seen many repos with Java, but I have seen many with C++. I can't find any ideas where Java is the best language to use.
>>
>>55946302
So then what is that dot in the python code? The python implementation is as an object.
>>
>>55946426
Creating your own data structures. Most data structures you use are syntax for a bunch of pointers.
>>
>>55946515
Thanks for the info anon!
>>
>>55946426
You use Java when you don't want your boss to fire you.
>>
>>55945751
Set up public GitHub projects and use it as reference for your knowledge and capabilities.
>>
>>55946442
>The python implementation is as an object
I don't really know memesnek, but I'm pretty sure that it's a hashmap.
Here is an example of lookup tables in C:
char *lut[] = {
[0] = "Zero",
[1] = "One",
[2] = "Two",
[10] = "Ten",
};

if (n >= sizeof lut / sizeof lut[0] || !lut[n])
puts("Nothing");
else
puts(lut[n]);

Nothing OOP about it at all.
>>
new thread

>>55946704
Thread posts: 324
Thread images: 38


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