Old thread at >>51218729
What are you working on, /g/?
Converting a MATLAB program into C++.
It's a pain in the ass.
>>51222251
You should restructure it, I highly doubt a direct translation is either efficient or elegant. Matlab is for testing algorithms, not design.
thoughts on pypy/pypy-stm?
>>51222231
Please don't use an anime image next time.
>>51222231
Got my GUI kit's scrollbars working better than they ever have. So, not great but at least they render.
>>51222251
That's on my to-do list. I'll probably just end up using Python instead.
Ask your beloved programming literate anything.
>>51222231
>>51222231
>What are you working on, /g/?
a general utility C library for /dpt/
>>51222492
How do I draw simple graphical shapes using C?
>>51222520
SDL
OpenGL
Cairo
etc.
>>51222532
Which one do you prefer?
>>51222520
ASCII, stdout
>>51222520
Do you mean circles, lines, squares and so?
>>51222492
I'm interested in NLP but obviously it's too big of a field.
Now let's say that instead of processing any given arbitrary sentence, first it filters the sentence looking for keywords (permutations of a few verbs + nouns). If they aren't found, then it simply returns an error.
If it does find one of the keys, then it attempts to map the sentence into a function.
For example
>Foo, Bar and Baz were at the study group session yesterday. Quux too.
The
>were at the study group session
block means that the program should add those persons to a roll call table for example.
If I can process the verb-noun block then everything else is relatively easy. Once the program understands the sentence as adding to a roll call, it just finds patterns that match people and dates (I can easily provide what to look for each function).
There are some loose ends, like "yesterday and last monday, but Quux wasn't last monday", but let's say I don't care about such complicated cases.
Since I only have a few functions, I think it should be manageable. What's your opinion?
>>51222580
Something like Swing graphics
>>51222610
OpenGL, use SDL or just Win32
>>51222610
SDL: http://sdl-draw.sourceforge.net/
Cairo: http://cairographics.org/
Who here is programming in the new Pipes language?
>>51222721
sounds vaginal and empowering
Got a basic implementation of my Lisp going. I plan to start playing around with Mark and Sweep GC soon.
>>51222432
this tbh fam
Trying to wrap my head around llvm. If I understand it correctly (which I probably don't) if someone were to write a llvm frontend for java, could it run natively, ie no jvm?
Just using java here as an example btw
>>51222721
>yet another meme language
>>51222721
It's shit.
>>51222901
there's already a java compiler
>>51222901
Sure. If you created a transpiler for Java -> LLVM IR, you could theoretically write native Java.
>>51222901
yes like gcj
>>51222492
Are you a girl?
Why is apple cider so good?
>>51223446
Apples are tasty
>>51223498
Is that why Apple phones are great?
Can anyone offer a hint how I might structure some data better? I'm doing the following many times for many palettes and it's a little gross.
This being C++.int vBlues[] = { 0x26839E, 0x2D85BF, 0x369FE5, 0xF6F792, 0x3DD3FF };
palette Blues(vBlues, 5);
why is she hugging her huge boner?
>>51223561
A struct?
>>51223590
girls just wanna have fun
>>51221293
this is my best shot at it
I basically reinvented the wheel to do it, my library doesn't do the whole line.rotate thing and collision detection at the same time
so I had to convert 360 degrees into radians and use cos and sin and do my detection on the individual lines intersecting the points..
ton of debugging but finally got it to work
and the line wasn't even captured by the screen recorder thing
http://pastebin.com/N9tF70Li
>2015
>coding in anything but scheme
Trying to figure out which functional language to learn. I'd really like to do second order predicate logic a al prolog but in a modern language... does anything like that exist?
I'm working on a game that is a reflection piece on what God is doing in my life. The idea is that there are monsters that represent sin and you get power ups / skills from God to help you beat them.
Multivariate Gaussian classification of GLCM texture-analysis
>>51223686
Do you actually need to rotate the line? I'm pretty sure that's just a visualization of the algorithm. For a given point (also given that you know the extreme point), finding the next in the hull should be a simple O(n) search amongst the n remaining points, giving you <O(n^2) for the entire algorithm.
>>51223549
Apple phones are not tasty. They are also not great.
>>51222492
What all is in your library?
>>51223808
Learn Scheme
Then you won't want to learn anything else
>>51223874
do they pay you for this or do you do it without payment?
>>51223874
>Scheme
will look at it.
>>51223901
Scheme is open-source and backed by MIT senpaitachi, it doesn't need shills unlike tacky OOP IN LOO languages like J*va.
>>51223930
so they don't pay you then?
>>51223869
fixed length arrays (・_・ ;)
I'm probably an idiot, but why does my linked list do nothing? I try to print the list and nothing happens. I'm new to C so call me naive.
>>51223839
in hindsight the whole thing could be done without a visualization at all.. just a few simple manipulations of a 2d array
oh well
Hoping someone can help me out. I'm learning C++ from pic related and I'm learning about constants. I'm trying to get constexpr to work, but the compiler doesn't recognize it and throws an error. I looked up a fix and changed my compiler settings in Code::Blocks to: "Have g++ follow the C++11 ISO C++ language standard".
Problem is, whenever I change my settings to that, I get an error in "locale_facets_nonio.h". I've found if I exclude "std_lib_facilities.h", I don't get the error anymore, but I need "std_lib_facilities.h" for the book I'm learning from. Any fixes for this?
>>51224134
Pick a better compiler.
C++11? Come on, it's 2015.
>>51224088
try assigning ptr to root after you malloc root.
>>51224152
I'm currently using "GNU GCC", which was the default. Which one of these would you recommend?
>>51224134
you could always add the includes yourself if you peep in the std_lib_facilities.h
other than that, i dont know
>>51224134
Post code and errors.
>>51224010
Anything else?
>>51224199#include "std_lib_facilities.h"gives this error on "locale_facets_nonio.h":
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
1869 | error: template-id 'do_get<>' for 'String std::messages<char>::do_get(std::messages_base::catalog, int, int, const String&) const' does not match any template declaration
locale_facets_nonio.h line 1869:messages<char>::do_get(catalog, int, int, const string&) const;
>>51224162
Nada. I've revised the code, though, removing infinite looping while loops. Program still freezes.
>>51224195
I recommend you use an entirely different IDE.
>>51224277
>std_lib_facilities.h
I'm learning Java by writing a simple chess engine. Right now I'm profiling my naive implementation of a multi-threaded alpha-beta search. I get okay scaling for a few cores, but if I go full bulldozer or improve my move search ordering I'll need much smarter threading to see the same improvement.
>>51224319
I need that header file for the book I'm learning from.
>>51224306
I thought Code::Blocks was pretty much the /g/ standard.
it's just a project from uni, but i gotta make a UI for this little calculus sheet i made, sorry for the spanish though, it's done with simple circular linked lists in C.
>>51224134
-std=c++11 is normally all you need to pass to g++
Creating a Wordpress plugin.
Writing a particle sim and one of my class methods is doing a thing I don't want it to.__str__(self)for some reason does not want to return a string.
Here's the body.(Yes, I realise that python is not really suited to physics simulation. I'm being lazy)#for the particle class
def __str__(self):
return 'position = {0}, velocity = {1}, mass = {2}'.format(
self.position, self.velocity, self.mass)
As a note. The position and velocity attributes are from another custom class for vectors. relevant vector code below. I like my tuples.def __str__(self):
if type == CARTESIAN:
return 'Vector(' + str(self.value) + ')'
elif type == POLAR:
return 'Vector(' + str(( Vector.abs(self), Vector.angle(self) )) + ')'
[\code]
Where do you guys go for ideas for projects? I find it hard to pick a project and stick to it.
Can anyone explain why people use NewLisp? I don't understand why anyone still use dynamic scope
Can someone explain two's complement to a retard?
>>51224646
Personally. I haven't done a whole lot but I mostly think about something I haven't seen before.(like a hyper-dimensional particle simulator) and scratch out a few ideas on how it might work. If I get bored after that then I go onto teh next idea that strikes my fancy.
Maybe carrying a notebook can help with keeping those ideas readily available. I carry a sketchbook around for my various hobbies anyway.
also having a good idea to have is to use a phased design process to give yourself a clear idea of what you want and build a way to go about making things.
I'm >>51224549 btw
>>51224733
Want to convert a number between positive?
Flip the bits and add one.
Out of curiosity, how do processes read the memory of other processes?
In example, there are programs like MultiEx which are designed to take a live running application, scan the process' memory and rip 3D meshes directly from the memory rather than decrypt/decompress a binary archive.
I want to see if I can rip a regular 2D image from a game.
>>51224010
>>51224088
These are both pretty reasonable fonts. I will never stop loving Terminus, but what are these?
>>51224806
Acorn Nostalgia (>>51224010)
>>51224366
> I need that header file for the book I'm learning from.
Then find a better book. E.g. one which uses standard C++ rather than rolling its own dialect (the header is probably just to make all of the examples shorter).
Or you could try pastebin-ing that header in the hope that someone bothers to look at it.
>>51224791
> Out of curiosity, how do processes read the memory of other processes?
Highly platform-specific. On Linux, there's ptrace() or /proc/<pid>/mem. No idea about Windows.
How do I deal with the feeling of futility that comes from the knowledge that I have to write my own implementations of famous algorithms to understand them, yet I will have to inevitably throw them all away and use implementations (much better) written by other people?
>>51224892
Even so, parsing the memory structure?
Is there some kind of literature on this?
Is C++ much harder than Java?
>>51225041
you're asking the wrong questions.
>>51225033
Maybe they just find out where the heap starts and rip all of the allocations that there were.
Going through the official rails guide because why not get an easy 100k / year job
>>51225000
You make a better version or suck it up.
If you make it good but not quite as good, that's potentially better than their version since you know the code well and have easy access to the source meaning changes are easier.
>tfw building qt from source
see you next week
Hi anons, I'm trying to write a python program which organises my music folder for me. Specifically, I'm trying to get it to break up the names of my mp3 files into artist and title, then rename the file, and add the artist as a tag to the file. I'm editing the files using the Mutagen library as follows:from mutagen.easyid3 import EasyID3
from mutagen.mp3 import MP3
import mutagen.id3
.
.
.
def handleNewFile(file):
#some other stuff
try:
edit = MP3(file, ID3=EasyID3)
edit["artist"] = artist
edit.save()
except:
#do some stuff
And this all works fine. The artist shows up when I look at my ID3 tags in my console. But when I look at them in my file system (running wangblows 8.1), the artist doesn't show up in the "contributing artists" field. This is really irritating as it means that the artist won't show up in Foobar2000 either. Can anyone tell me what I'm doing wrong?
>>51224791
ReadProcessMemory
still working on http://nask.co/
So like, how come when it's printed in the info section it shows up correctly as as a decimal of 0.5
but when I print it later on it shows only as 0
I'd imagine it's because the first time it's literally the print command, and the second time, it's io.write
so how would I show a decimal in the string?
Language is lua
>>51225431
Are you treating it as an int?
>>51225448
integer? I don't know...
I could literally just write it in for the enemies, but the player can have different ones naturally, and I don't think I can print a variable with a string, or whatever things in quotes are called
>>51225411
any suggestions/feature requests/bug reports/testing are welcome
>>51225033
> Even so, parsing the memory structure?
At what level?
/proc/<pid>/maps tells you which parts of which files (executables, libraries) are mapped where, and with what permissions. Those will at least have a symbol table, and possibly debug information.
If there's no debug information, anything below the level of individual sections (code, data, rodata, bss, heap, stack) is guesswork.
>>51225458
So it's the exact same variable with no modifications at all?
Is it basicallyfloat myVar = 0.5;
print(myVar);
printWithOtherMethod(myVar);
If not then there's a chance that during one of your calculations you're treating it as an int somewhere. Make sure the data's actually what you're expecting it to be before you start doubting the library (I had a similar problem with non-english characters in C# showing up as "?", turned out the console just doesn't support them with its default settings).
>>51225431
http://powershell.com/cs/blogs/tips/archive/2014/03/05/formatting-numbers-easily.aspx
>>51225502
In many languages, the default print style of a decimal which is some distance from some integer just prints the integer.
Since it's unlikely that Unicode is fucking with him, it's surely because he didn't realize that if he expects a certain format from his strings, then he should explicitly format it and not rely on the standard library to format it to his expectations.
what other operations an fixed-length array does need ? currentlyArray<T> Operations:
Error Array<T>_initialize (CPP_Array<T> dest, C_Length length)
Size Array<T>_length (CPC_Array<T> a)
Void Array<T>_finalize (P_Array<T> a)
Void Array<T>_finalizeCleanup (PP_Array<T> a)
T Array<T>_get (CPC_Array<T> a, C_Index i)
Void Array<T>_set (CP_Array<T> a, C_Index i, T e)
Size Array<T>_size (CPC_Array<T> a)
Void Array<T>_copy (CP_Array<T> dest, CPC_Array<T> src)
>>51225502
float, right that's a thing I should remember,
Anyways I turned it into
Pmultiplierstring = '0.25'
and that prints normally, but in the
io.write string.format line it returns it 0
>>51225555
my variablesPmultiplier = 0.25
Pmultiplierstring = '0.25'
and execution
print ('Damage Multiplier: ',(Pmultiplier))
io.write (string.format ('Test : %d', Pmultiplierstring))
assuming I did that right
>>51225523
is the spacing thing just a powershell issue then?
>>51225549
0.5 has the decimal right next to the dot though.
And I was meaning to just make sure it wasn't a mistake with your own code before thinking it's a mistake with someone else's, the first thing he thought of was io.write was wrong which is most likely not the case.
>>51225550
Strictly speaking, a fixed-length array should only require allocation of memory and its related actions (initialization), and memory access.
Everything else is extra.
get() and set() should only apply to an entire datastructure.
In data collection nomenclature, get() is most commonly used to refer to an element in the collection, and is suitable for access and mutation of the element.
>>51225550
Construct from a C array.
Copy from a C array.
>>51225555
>>51225563
>%d
I think that's your problem, isn't it %f for floats?
>>51225583
copy,get, and set are here for safety reasons (there no bounds checking in C).
Hi /g/
I do not usually post in these threads as I don't have much experience in programming but I recently came up with an idea of a program.
I like to do film photography as a hobby every now and then and I'd like to record some information about the films and pictures. Basically I would like to manage information about the film rolls that I have in my inventory and that I have used. Typical information that might be useful is film brand/type, ISO speed, number of frames and expiry year/month. Currently I am using a spreadsheet file to manage this information.
And for each of the frames of a film roll I probably might want to store short descriptions about the subject, lighting conditions and photographic settings (focal length, shutter speed, lens aperture). And if some of the film frames ends up being scanned, I might also want this program to know whether or not this frame has been digitized.
Do you think it would be a totally silly idea for a beginner programmer? If not, would you have any advice on how to proceed with this idea? Also, I often see Python as the recommended language for beginners. Would learning Python be a good starting point for me?
>>51225609
That's true, but there's no reason you couldn't have a single get() function that performed out-of-range checks.
The only feasible reason I could see for having set() is to differentiate this array from an immutable array, which is kind of dumb.
>>51225625
That sounds like a job for a database, learn whatever language you want then learn about databases.
It'll probably take you a while to get to that stage though (a month or two would be my guess if you're going straight for it).
>>51225550
i want to be able to easily loop over the array
>>51225625
You never mentioned what your actual idea is.
>>51225633
>there's no reason you couldn't have a single get() function
how so ?
also considering adding slicing operation. eg:Array<T> Array<T>_slice (Array<T> a, Index start, Index end);
>>51225625
excel will be better than anything I can write for you, sorry
Really anything you program will take you hours more to work out and will not be worth it at all
just trust me on this one
>>51225656
>and I'd like to record some information about the films and pictures. Basically I would like to manage information about the film rolls that I have in my inventory and that I have used.
That's clearly a basic inventory management program.
>>51225664
I said it before.
set() doesn't belong with data collections. It should only be used with monolithic data structures.
There is already a well defined get() function present in most OOP languages which returns a reference to an element in the data collection, at which point you can both access and mutate that element.
A proper get function would look like
T* Array<T>_get (CPC_Array<T> a, C_Index I)
Although I have no idea how your language handles references.
>>51225602
Didn't know that was a thing, but now I have this issue I guess even with the one that's in quotes
>>51225625
Just go digital nigga
>>51225671
Of course. I could have told him to write a database, and then he could store whatever the fuck he wanted.
But how does he actually want to interact with that database? Does he want to make a GUI with a set of dropdown templates so that he doesn't have to completely rewrite each item he inserts in the database?
>>51225678
I guess I could just print the first half, but then, I don't think the normal print command can handle multiple variables
>>51225678
Try %.2f (this is java's String.Format, I'm assuming it carries over to other languages somewhat similarly) where .2 is the number of decimal places you want.
>>51225678
Look up printf-style formatting, you can do some nifty stuff.
>>51225695
thanks, seems to have fixed it
why wasn't I simply born stupid but charismatic, coding is such a bitch
>>51225700
they're called formatted strings, bud.
PowerShell may or may not have a recent C#6.0 feature called "String Interpolation", where you can literally just jam variables directly into a string. It's intended to be syntactic sugar for String.Format().
>>51225714
and it appears to have all worked out, now I just need to decide if I'm actually going to continue working on this or make a GUI or ASCII version
>>51225717
In this specific case it's using printf-style, though. There are other styles of formatted strings, as well as interpolation and stream-control-based formatting.
>>51225741
make it similar to anything made using ncurses
>>51225676
can't do that, Array<T> does mean that the array has elements of type <T> so getting the nth element result of a value of type <T>, not of type <T*>. Otherwise, that would mean that anything could manage the memory of the array without passing by the interface which would put too many constrains on the underlaying implementation (especially when concurrency is involved).
>>51225741
Work on your variable names.
>D10a, D10b, D10c, Emultiplier, PDR, PHP
>>51225761
I was just going to go with love2D or something, but that might work, not sure if it'll work for the ASCII route though, I need to somehow get multiple units on the screen
that appears to be GNU, but is it still available for commercial use?
>>51225783
They make more sense to me I guess, D10 is a 10 sided die, E Multiplier is Enemy Damage Multiplier, PDR is Player Defense Rating, and PHP, is Player hit points naturally
>>51225792
I mean the convention, you don't start variables with uppercase, you certainly don't make them all caps (unless they're constant).
Pick a common convention and stick with it (or just pick the most common one for that language).
http://lua-users.org/wiki/LuaStyleGuide
>>51225824
I suppose, probably just going to stick to what makes sense to me though
>>51225839
Learn a convention and make that make sense to you, you'll thank yourself later when you move onto larger projects.
Why don't people realize that braces are a really awful way to denote code blocks?
/rust general/ - embedded edition
This is Rust General, embedded in the DPT. All posts for rust general should quote this post so they can all be linked together.
https://doc.rust-lang.org/stable/book/
>>51225978{
string s = "suck";
}
{
string s = "my dick";
}
{
string s = "python";
}
>>51226020
Actually, I'm an Ada shill :^)
In Haskell, why can't I pattern match with specific stuff when something is a generic type? Example:myFunc :: a -> String
myFunc 0 = "You entered 0!"
myFunc 1 = "You entered 1!"
myFunc "asdf" = "You entered a string!"
>>51226041
Still a type of snake if you go by phonetics.
>>51225999
That's a smexy language and it performs extremely well.
I'm not going to bother learning it until it gets popular, though. I just don't have time to waste.
>>51222417
please respond
>>51223821
hi terry
>>51223821
how about changing the paradigm of what makes a video game, instead of merely changing the plot devices?
>>51225684
Nigga, I already have K10D that I use most of the time. Sometimes it's just fun to shoot a mechanical camera.
>>51225665
Indeed, Libreoffice does this job quite well and is easy to use. I just thought it would be a nice way to learn.
>>51225688
GUI would be nice but I was thinking that some kind of text user interface would be easier to do, is that correct?
>>51226158
Translation: Make another walking/reading simulator.
>>51226221
it's actually flying/listening simulator
/dpt/
I'm trying to make a user interface library like Qt, WPF or Swing or whatever.
I'm looking for some guides and information on how to do this for some of the more complicated aspects.
I can create simple widgets, draw buttons and so on... but things like ListViews and TableViews are pretty complicated.
I can always take a look at Qt's source code (and I have a few times before) but I'm looking for something a bit more instructive.
Do you know of any sites or books, etc?
>>51226221
not exactly. all games have the same core mechanics: power ups, some ability, press this button repeatedly to do everything, all the mechanics of an rpg, all the mechanics of shooters, of puzzle games, etc.
nobody thinks of anything different. if you've played 5 games, you've played them all. the only difference are the plot devices, teh things that make the plot. terrible example, but i can't be arsed to write a treatise: call of duty, and halo. yeah, one game you have to get shot a few more times before you die, than in the other. but they have the same plot devices, just arranged in slightly different ways.
>>51226221
>>51226276
well i guess you were right, except i mean *dont* make another one of either of those
>>51226308
This is like complaining all books have the same structure, they have a problem then the problem is solved. Read one and you've read them all.
You're over generalising (and you're wrong anyway, not all games have those things).
>>51226308
>. if you've played 5 games, you've played them all.
K tard
>>51223727
>>51223874
Scheme vs Common Lisp
Go
>>51226308
>Overgeneraliations: The Post
#include <stdio.h>
main()
{
printf("hello, ");
printf("world");
printf("\n");
}
working on hard c ^^
implemented webm into my image manager, and basically project is finished, old pic because i dont any recent
>>51226535
Racket scheme especially appears to be more powerful. But I like the lisp-2 semantics, it makes calling the result of a computation more explicit.((make-closure) (compute-data))
versus
[code
(funcall (make-closure) (compute-data))
this way you don't rely on subtle parenthesisation differences that programmers must scan for, instead they detect the "keyword" and they go okaaaaaaaaaay.
Why does this works so well?const Rational sum(const Rational& rhs) const;
Rational& Rational::operator+=(const Rational& rhs) {
*this = sum(rhs);
return *this;
}
>>51226302
I don't know any. I've looked into it once or twice before. Best thing is to just look at the API's for UI library's you like and do all you can to understand how they work.
>>51226757
Your const-correctness make no sense. Why are you constructing a new rational from sum and returning it as constant? The copy constructor you have by default isn't affected, but it clashes with move semantics
>>51226059
In some cases you have to specify generally what kind of data the parameter is. In this case it sees the numbers being pattern matched, then sees the string being pattern matched and realizes that strings aren't a numeric type, so it stops.
I don't really know what the intent of this function would be, but I made a couple examples that compile
In this case the constraint (Show a) makes it so a can only be something that can be turned into a string. Yes I know it makes redundant single and double quotes in its output but I don't feel like fixing it just for this example.myFunc :: Show a => a -> String
myFunc x = "hello, you entered: " ++ show x ++ "!"
This one just pattern matches strings...myFunc' :: String -> String
myFunc' "hello" = "world"
myFunc' "world" = "hello"
myFunc' _ = "goodbye world"
I can't really think of an instance where your example would be useful. Could have just made all the inputs strings.
>>51222231
>What are you working on, /g/?
I finished a box today. .webm related
It sends data and the receiver has to be programmed now.
>>51227018
looks pretty cool anon :^)
>>51227018
>>51227025
woops. forgot the webm :^)
>>51227038
damn man, that box is ugly af
and congrats, you can turn on an LED!
>>51227063
>>51226680
well done, maybe hiroshima will make it a feature, if it can run on the webserver. idk if it's a windows thing or a javascript extension
>>51227075
woah
I didn't notice it in the webm, but you have like, what, 10 light sources?
how the fuck can you deal with that
>>51227187
typical of a cheapo multi-led desk kamp
God my lisp is so ugly and unreadable.(defun helm-mpd-tracks (artist album)
(helm :sources
'((name . "MPD Find Track")
(candidates
. (lambda ()
(mapcar
'(lambda (candidate)
(let ((number (car candidate))
(title (car (cdr candidate))))
`(,(concat number ". " title)
. ,title)))
(sort
(mapcar
(lambda (title) (map1 artist album title))
(mpd-list "title" :artist artist :album album))
(lambda (t1 t2)
(< (string-to-number (car t1))
(string-to-number (car t2))))))))
(action
. (("Play track"
. (lambda (title)
(progn
(mpd-clear-playlist mpdconn)
(mpd-find-add :artist artist :album album :title title)
(mpd-play mpdconn)))))))
:buffer "*Helm MPD Album*"))
Any tips on how to write clean lisp?
In java, i have a square matrix, m[i][j]
After reading the matrix elements, i need to parse the matrix like in the picture, and display the numbers in the order of parsing
For example, in the matrix
1 2 3
4 5 6
7 8 9
The output would be 1 2 3 6 5 4 7 8 9
How do i do this?
>>51227379
forgot picture
>>51227386
>homework
>>51227379
structure your matrix as a single dimensional array in row major order and it becomes absolutely trivial
>>51224088
>rand()
Obsolete garbage.
>>51227386
I saw this question a couple days ago and now again//not java
for i in range 100
if i % 1 = 0
print list[i].reverse()
else print list[i]
>>51227431
in range list.countRows()*
>>51227379#include <stdio.h>
int main(void) {
int m[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
for (int i = 0; i < 3; i++) {
int j, stop, inc;
if (i % 2)
j = 2, stop = -1, inc = -1;
else
j = 0, stop = 3, inc = 1;
while (j != stop) {
printf("%d ", m[i][j]);
j += inc;
}
}
printf("\n");
}
First thing that came to mind. There's probably a better way.
>>51227436
That code is really over complicated.
>>51227318
Not just yours.
>>51225000
Learn DP and you'll do everything that way at some point.
Writing a text adventure with a GUI just because I kinda felt like it. How does it look? Any advice?
>>51227510
what language?
>>51227456
How would you simplify it?
>>51227498
What do you mean?
DP algorithms are the ones I rather implement myself because existing code is usually completely incomprehensible (how fucking hard is it to just add a comment with a short description of the underlying recursive function and the eval order? do people just omit this just to fuck with you?)
>>51227539
Python, using GTK and Glade.
>>51227510
Why would you add a GUI to a text adventure?
>>51227562
Because I can.
>>51222231
Learning some Prolog today for my AI class, fun times! First time playing with a declarative language, totally new way of thinking and it is pretty fun, I like it!
>>51227574
For anyone who is interested : http://www.learnprolognow.org/
>>51227543int main(void) {
int m[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
for (int i = 0; i < 3; i++) {
int j;
for (j = 0; i < 3; j++) {
if (i % 1 == 0)
printf("%d", m[i][3 - 1 - j]);
else printf("%d", m[i][j]);
}
printf("\n");
}
}
>>51227613
Good one. I made some more changes.#include <stdio.h>
#include <stdbool.h>
int main(void) {
int m[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
bool even = true;
for (int i = 0; i < 3; i++, even = !even)
for (int j = 0; j < 3; j++)
printf("%d ", m[i][even ? j : 3 - 1 - j]);
printf("\n");
}
>>51224366
gcc is fine. The problem is that it seems to include non-standard headers.
>>51227543#include <stdio.h>
#define SIZE 3
int main(void) {
int m[SIZE][SIZE] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
for (int i = 0; i < SIZE; ++i) {
for (int j = 0; j < SIZE; ++j) {
printf("%d ", m[i][i % 2 * (SIZE - 1) + j * (1 - i % 2 * 2)]);
}
}
printf("\n");
}
>>51227650
I thought about defining the size, but you give the array in the function, so I don't really see the point.
>>51227647
Nice one
>>51227647
>stdbool
ew
>>51227613
small time#include <stdio.h>
int main(void) {
int m[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
for (int i = 0; i < 9; i++) {
printf("%d\n", *(m[0]+i)); // YOLO
}
}
Im currently in my first semester of computer science and have trouble with the programming. Can somebody recommend me some good sites where i can learn myself and look stuff up?
>>51227650
>>51227681
those work
thanks dudes
>>51227698
What are you programming about?
>>51226712
Except because of the parentheses, it's impossible to miss the fact you're calling an expression so the argument is invalid. Lisp2 >>>/trash/.
>>51227670
What's wrong with it?
>>51227712
Stuff like that gives me the impression that C is a failed by design language.
>>51227717
who needs bool when you've 1 and 0
what is the most useful short piece of code you have ever seen?
I think for me Dekkers Algorithm is pretty darn elegant and powerful
>>51227733
Because 2.
>>51227717
>implying 1-bit types make sense for any language somewhat close to hardware
>>51227705
Well i guess for you guys.
Pic related is one of my problem i have to solve
>>51227743
is no 2
>>51227737
I like to define useful as something with practical value, which an algorithm in itself does not have.
To answer your question, a solver.
>>51224088
>>51224299
Initially you didn't assign ptr to a valid root (so ptr remained NULL). The program should've segfaulted due to such dereferences. This tells me that the program never even entered any of the loops and it is hanging elsewhere.
>>51227762
Interesting thought process. Dekkers solves the issue of Mutual Exclusion allowing for concurrent applications to run, don't you think that has practical value?
>>51227750
What is your problem exactly? The syntax of Java? Problem solving?
>>51227681
>>51227650
im retarded
explain how these work
>>51227777
your quints
I have a question, guys.
I have something like this in Javamain {
...
ArrayList<String> a;
.....
method(a);
...
}
public static VOID method (ArrayList<String> a){
....
a.remove(0);
....
}
Will the value at position 0 be deleted from the list back when I keep working with it in main?
>>51227789
Awww shit nigga, my first quints. I'm fucking blessed.
>>51227796
> Homework
>>51227802
It's an end of semester project
>>51227785
Learn how memory and arrays in C works
>>51227808
That's called homework.
>>51227777
Checked.
Ah sry you talk about my problem.
Overall i know what i have to do and how to solve this problem. But when it comes to the programming part in java im clueless
>>51227772
Oh, I thought it was just some generic algorithm.
I guess that does have practical value
>>51227821
Thats why god invented documentation. https://search.oracle.com/search/search
>>51227816
So?
The OP says
>What are you working on, /g/?
Not
>What commercial software are you working on, /g/?
Go be a faggot somewhere else
>>51227832
*A faggot that can do their homework
>>51227832
Where does the OP say "pls help me google/look up docs questions here"?
>>51223561
vector?
has size() in it too, and dynamic, depending on your needs
Anyone using vim with rainbow parenthesis? I get some lag when I edit some cpp files but I have no idea why this is the case given c files work perfectly well with the same config.
I compared two versions >>51227650 and >>51227647 and found that branchless one is superior in performance :^)#include <time.h>
#include <stdio.h>
#define SIZE 10000
int mod() {
unsigned int foo = 0;
for (int i = 0; i < SIZE; ++i) {
for (int j = 0; j < SIZE; ++j) {
foo += i % 2 * (SIZE - 1) + j * (1 - i % 2 * 2);
}
}
return foo;
}
int branch() {
unsigned int foo = 0;
int even = 1;
for (int i = 0; i < SIZE; ++i) {
for (int j = 0; j < SIZE; ++j, even = !even) {
foo += even ? j : SIZE - 1 - j;
}
}
return foo;
}
void bench(int (*func)()) {
for (int i = 0; i < 100; ++i)
func(); // Warm up
double start = (double)clock() / CLOCKS_PER_SEC;
for (int i = 0; i < 100; ++i)
func();
printf("Time: %f s\n", (double)clock() / CLOCKS_PER_SEC - start);
}
int main(void) {
bench(mod);
bench(branch);
}$ cc -O2 -Wall branchtest.c -o branchtest
$ ./branchtest
Time: 0.001636 s
Time: 7.293253 s
Does anyone have those super beginner programing challenges image?
>>51222231
I'm trying to get protocol buffers(https://developers.google.com/protocol-buffers/) working on my system but I can't get the library working
Getting a shitload of undefined references when trying to compile an example.
>>51227889
False dichotomy. My even optimisation was still an improvement over the mod+branch implementation. Here:int neither() {
unsigned int foo = 0;
int odd = 0;
for (int i = 0; i < SIZE; ++i, odd = !odd) {
for (int j = 0; j < SIZE; ++j) {
foo += odd * (SIZE - 1) + j * (1 - i % 2 * 2);
}
}
return foo;
}$ ./test
Time: 0.009440 s # mod()
Time: 9.539466 s # branch()
Time: 0.002296 s # neither()
>>51224366
> Code::Blocks
>/g/ standard
In what fucking universe?
Codeblocks is such garbage (and also dead) that even in bizarro /g/, everyone shits on it.
>>51228001
Oh, I missed one of the mods. And when I reordered it, the results changed. Maybe some compiler optimisation.
So I'm writing a crypter which evades anti-virus software for educational purposes.
I did it as follows:
>encrypt the virus exe
>to execute it:
>decrypt it into a buffer
>create a suspended version of the process
>WriteProcessMemory the process with what represents the virus' virtual memory
The crypted infected virus is undetectable, so that's good. However, when I do the in-memory execution part (the suspend process and write its memory part), many antiviruses go off.
How to make the virus undetectable even when its loaded in virtual memory? Do I just fill the virus memory with junk and tons of NOPs to try to fuck up signature-based detection?
>trying to make the program wait and only continue until a user clicks their mouse
>doesn't work
what's wrong with this code?GEvent event = getNextEvent(MOUSE_EVENT);
while (event != NULL && getEventType(event) != MOUSE_CLICKED)
{
event = getNextEvent(MOUSE_EVENT);
}
>>51228153
AVs will scream at you if you rewrite executable memory
you can't get past that
most viruses decrypt an exe into the users temp directory and run that, which is less suss.
>>51228183
>AVs will scream at you if you rewrite executable memory
Not necessarily. If you create a process and suspend it, and then write its memory, it will go unnoticed as long as you don't write malicious instructions.
The problem is that the malicious instructions get detected by signature-based AV detection.
I guess that what needs to be done is to somehow obfuscate those instructions to make them radically different from the virus signatures anti-virus software has.
A month ago every thread had a F# shilling. Now I'm hooked and no one cares.
>>51228320
>she fell for the meme
>>51228320
>taking language suggestion from /dpt/
>>51228320
I'm a huge F# shill. But I only post about it when it's relevant.
What's the difference between dynamic analysis and debugging? Sorry if this question is stupid - I'm a retard.
>>51226601
Do you know that you can rewrite those printfs in one line#include <stdio.h>
main()
{
printf("hello, "); printf("world"); printf("\n");
}
total life hack. thank me later ;) :)
>>51228645
>tries saving space
>not putting the opening parenthesis after function name
RRREEEEEEEEEEE
>>51228645
ayyyy, real life hack brother
How come all systems development isn't done with X#?
>>51228710
To be even more compact you can write it all on one line.#include <stdio.h>
main(){printf("hello, ");printf("world");printf("\n")'}
Reading TLPI:
http://www.man7.org/tlpi/
So, so good.
>>51222231
W-what is she hugging OP?
>>51228173
p-plz respond
>>51229148
if you need to print a lot of statements (say, more than 5):#include <stdio.h>
int (*p)(const char *format, ...);
main(){p = printf;p("hello");p(",");p(" ");p("world");p("!");p("\n");}
>>51229300
Or you just write out the damn thing because doing this makes your code unreadable garbage.
What do you guys recommend for C++ GUI? I'd like something simple and small (so no Qt), works on at least Linux+Windows, but doesn't look like a Windows 98 program (so no wxWidgets).
Hi friends. Here's some syntax for your printf debugging fun.#lang racket/base
(require (for-syntax racket/base syntax/parse))
(provide print-let print-let*)
(define (let-printer-base names vals)
(for ((name names)
(val vals))
(printf "\t~a: ~s\n" name val))
(newline))
(define (let-printer-count loop-name)
(define count 0)
(λ(names vals)
(printf "Loop \"~a\" ~a\n" loop-name count)
(set! count (add1 count))
(let-printer-base names vals)))
(define let-printer (make-parameter let-printer-base))
(define-syntax (print-let* stx)
(syntax-parse stx
((_ ((name:id exp:expr) ...) body ...)
(syntax (let* ((name exp) ...)
((let-printer) (quote (name ...)) (list name ...))
(let () body ...))))))
(define-syntax (print-let stx)
(syntax-parse stx
((_ ((name:id exp:expr) ...) body ...)
(syntax (let ((name exp) ...)
((let-printer) (quote (name ...)) (list name ...))
(let () body ...))))
((_ loop:id ((name:id exp:expr) ...) body ...)
(syntax (parameterize ((let-printer (let-printer-count (quote loop))))
(let loop ((name exp) ...)
((let-printer) (quote (name ...)) (list name ...))
(let () body ...)))))))
Use example:Welcome to DrRacket, version 6.2 [3m].
Language: racket/base [custom]; memory limit: 1024 MB.
> (require (rename-in user/debug-lets
(print-let let)))
> (define (fib n)
(if (zero? n)
0
(let fib-iter ((a 0)
(b 1)
(n (sub1 n)))
(if (zero? n)
b
(fib-iter b (+ a b) (sub1 n))))))
> (fib 3)
Loop "fib-iter" 0
a: 0
b: 1
n: 2
Loop "fib-iter" 1
a: 1
b: 1
n: 1
Loop "fib-iter" 2
a: 1
b: 2
n: 0
2
>
>>51229300
a macro is shorter
>>51229220
He's hugging his dick.