I have one file with a lot of numeric data... and I need to sum
all that data...
That is my actual code:
module main;
import std.stdio;
import std.file;
import std.conv : to;
int main(string[] args)
{
auto f = File(oi.txt);
auto r = f.byLine();
auto tot = 0;
O, real intresting the mode functional style!!!
Like linq!
hahah
Btw, it's work very well, thansk!!!
But, how I can insert an ',' comma to separe the decimal place ?
( the last 2 digits )
I can't find a insert instruction in std.string or std.array
On Thursday, 10 July 2014 at 15:01:52
I have a string X and I need to insert a char in that string...
auto X = 100;
And I need to inser a ',' in position 3 of this string..., I try
to use the array.insertInPlace, but, not work...
I try this:
auto X = 100;
auto N = X.insertInPlace(1,'0');
Sorry..
I mean:
auto X = 100;
auto N = X.insertInPlace(3,',');
On Thursday, 10 July 2014 at 16:05:51 UTC, Alexandre wrote:
I have a string X and I need to insert a char in that string...
auto X = 100;
And I need to inser a ',' in position 3 of this string..., I
try
I used that solution:
string InsertComma(string val)
{
return val[0 .. $-2] ~ , ~ val[$-2 .. $];
}
On Thursday, 10 July 2014 at 16:23:44 UTC, John Colvin wrote:
On Thursday, 10 July 2014 at 16:05:51 UTC, Alexandre wrote:
I have a string X and I need to insert a char in that string...
Oh, I used that letters in upper case, just for a simple sample...
On Thursday, 10 July 2014 at 16:32:53 UTC, Marc Schütz wrote:
On Thursday, 10 July 2014 at 16:20:29 UTC, Alexandre wrote:
Sorry..
I mean:
auto X = 100;
auto N = X.insertInPlace(3,',');
On Thursday, 10 July 2014 at
PS: that is my code:
import std.stdio, std.algorithm, std.range, std.conv;
string InsertComma(string val)
{
return val[0 .. $-2] ~ , ~ val[$-2 .. $];
}
int main(string[] argv)
{
auto x = oi.txt
.File
.byLine
.filter!(line =
Hi :)
I need to sum a list of numbers... but, when I calculate the sum
of this numbers, I got a simplify representation of sum:
2.97506e+,12
How I can make to get the correctly representation of this number
?
basically format
I read a cobol struct file...
From pos X to Y I have a money value... but, this value don't
have any format..
0041415
The 15 is the cents... bascally I need to put the ( comma ), we
use comma to separate the cents, here in Brazil...
On Thursday, 10 July 2014
I have this code in C++
//...
char image[0x800];
//...
auto dosh = reinterpret_castIMAGE_DOS_HEADER*(image[0]);
dosh-e_magic = *(WORD*)MZ;
dosh-e_cblp = 0x90;
dosh-e_cp = 3;
dosh-e_cparhdr = 4;
dosh-e_maxalloc = 0x;
dosh-e_sp = 0xb8;
dosh-e_lfarlc = 0x40;
Ok, thanks thanks!!!
Have a lot of thinks I need to learn
When I generate the exe file, something is wrong with this:
dosh.e_magic = cast(WORD)*MZ.ptr;
When the PE file is generate in EXE have just the M of MZ...
Oh, thanks a lot!!
With a little change all work!
look:
struct IMAGE_DOS_HEADER {
WORD e_magic,
e_cblp,
//...
void main() {
import std.stdio;
import std.file;
import core.stdc.string;
auto dosh = cast(PIMAGE_DOS_HEADER)image.ptr;
Look at line 114 of my code: http://dpaste.com/3B5WYGV
Have a more better way to make this conversion ?
*(DWORD*)PE\0\0 ?
And some other strange thing is, the generate struct in PE file
is wrong.. look at imagens...
As it should be...: http://i.imgur.com/4z1T3jF.png
And how is being generated...: http://i.imgur.com/Oysokuh.png
My actual source is that: http://dpaste.com/2TZKWF5
On Monday, 14 July 2014 at
I don't see much need for such aliases.
Ok, how I can reduce the number of aliaSs ?
I suggest to avoid magic constants like that 0x80, like I have
avoided it here:
memcpy(image[IMAGE_DOS_HEADER.sizeof],
Btw, I need to start that part of code in x80
Look, that is my C++ code base:
immutable ubyte[5] stub = xb8 01 4c cd 21.representation;
that is a Real-Mode Stub Program
On Monday, 14 July 2014 at 12:32:38 UTC, Andrea Fontana wrote:
Is there any counter-indication with this:
immutable ubyte[5] stub = xb8 01 4c cd 21.representation;
?
Is it a compile time value?
On
bearophile, Thanks for all help!
As I said, I'm coming from C # and C + +, I need to learn
tricks of D language...
'm reading this book: http://ddili.org/ders/d.en/
I have a struct with union...
struct IMAGE_SECTION_HEADER
{
BYTE[8] Name;
union Misc
{
Yes yes, I did it, I used the anonymous type
Look the complete code:
https://gist.github.com/bencz/3576dfc8a217a34c05a9
I know, has several things that can be improved
Soory, I not understand, why lose the optlink ?
Read the libs is simple, but, the linker do the brute force!
On Monday, 14 July 2014 at 15:17:06 UTC, Jason King wrote:
On Monday, 14 July 2014 at 14:50:36 UTC, Alexandre wrote:
Yes yes, I did it, I used the anonymous type
Look the complete
void InjectData(T)(ref T BaseSrc, string data)
{
memcpy(BaseSrc, data.ptr, data.length);
}
It's possible to improve this function ?
On Monday, 14 July 2014 at 15:45:19 UTC, bearophile wrote:
Alexandre:
Look the complete code:
https://gist.github.com/bencz/3576dfc8a217a34c05a9
I
Hi :)
I made this function to inverse the bytes in intger or T
(possible) type...
int reverseBytes(T)(T val)
{
int retVal = 0;
static if(is(T == string))
retVal = to!int(val);
return (retVal 0x00FF) 24 |
(retVal 0xFF00) 8
Thanks, but, when I convert I recive a 'c' in the front of my
number...
uint reverseBytes(uint val)
{
import core.bitop : bitswap;
return bitswap(val);
}
//...
writefln(%x, reverseBytes(0x00402030));
//...
// output: c040200
On Tuesday, 15 July 2014 at 12:16:26 UTC,
Something is wrong between our communication...
I am wanting to do something better to order the bytes, for this
my code...
https://gist.github.com/bencz/3576dfc8a217a34c05a9
For example, in that case:
injectData(image[0x207], x30204000);
It's more simple to use something like:
Strange..., why '@' ?
PS: Ali Çehreli, thanks for your book, your book is wonderful!!!
On Tuesday, 15 July 2014 at 13:49:51 UTC, Ali Çehreli wrote:
On 07/15/2014 04:56 AM, Alexandre wrote:
retVal = to!int(val);
std.conv.ConvException@C:\D\dmd2\src\phobos\std\conv.d(1968):
Oh!
I used the RefCounted because this:
The proposed C++ shared_ptr, which implements ref counting,
suffers from all these faults. I haven't seen a heads up
benchmark of shared_ptr vs mark/sweep, but I wouldn't be
surprised if shared_ptr turned out to be a significant loser in
terms of both
I have this struct:
enum AddrType { Abs, RVA, Rel };
struct Address
{
shared_ptrDWORD addr;
AddrType type;
Address(): type(Abs) {}
Address(DWORD addr, AddrType type):
addr(shared_ptrDWORD(new DWORD(addr))), type(type) {}
Address(shared_ptrDWORD addr, AddrType type):
Yes yes, I will use the ref... is more safer!
I will try to re-create my logic...
btw, how is the best way to reinterpret this ??:
mapstring, Address syms;
and:
vectorpairDWORD, Address values;
vectorpairDWORD, shared_ptrDWORD addrs;
On Tuesday, 15 July 2014 at 14:55:36 UTC, bearophile wrote:
Maybe this can be usefull for u
https://gist.github.com/bencz/3576dfc8a217a34c05a9
On Thursday, 17 July 2014 at 23:04:06 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
On Thu, Jul 17, 2014 at 09:01:35PM +, seany via
Digitalmars-d-learn wrote:
Data is a built in type? what includefile do
Read the BOM ?
module main;
import std.stdio;
enum Encoding
{
UTF7,
UTF8,
UTF32,
Unicode,
BigEndianUnicode,
ASCII
};
Encoding GetFileEncoding(string fileName)
{
import std.file;
auto bom = cast(ubyte[]) read(fileName, 4);
http://www.architectshack.com/TextFileEncodingDetector.ashx
On Tuesday, 22 July 2014 at 15:53:23 UTC, FreeSlave wrote:
Note that BOMs are optional and may be not presented in Unicode
file. Also presence of leading bytes which look BOM does not
necessarily mean that file is encoded in some kind
On Wednesday, 1 November 2017 at 20:56:22 UTC, Dr. Assembly wrote:
On Wednesday, 1 November 2017 at 20:53:44 UTC, Dr. Assembly
wrote:
Hey guys, if I were to get into dmd's source code to play a
little bit (just for fun, no commercial use at all), which
books/resources do you recommend to start
I have a project written in C++, that I'm thinking to migrating
to D, but, what is preventing me from migrating to D, is the part
of the system that works with images, where the system generates
the image of a payment receipt, currently in the system written
in C ++, there is an array with
On Friday, 2 August 2019 at 15:51:25 UTC, Russel Winder wrote:
On Fri, 2019-08-02 at 13:45 +, Alexandre via
Digitalmars-d-learn wrote:
[…]
Could you elaborate more about C being a burden? I have read
so many people saying C gives a great foundation and should be
everyone's first
On Friday, 2 August 2019 at 12:30:44 UTC, berni wrote:
On Wednesday, 31 July 2019 at 18:38:02 UTC, Alexandre wrote:
[...]
In my oppinion C should have been deprecated about 50 years ago
and it's not worth while to learn it if you are not interested
in the history of programming or you have
On Wednesday, 31 July 2019 at 22:16:42 UTC, bachmeier wrote:
On Wednesday, 31 July 2019 at 18:38:02 UTC, Alexandre wrote:
[...]
What is your goal? In my opinion, learning C is a waste of time
in 2019 unless you have something specific in mind related to a
job. C is mostly "fun with
On Wednesday, 31 July 2019 at 20:04:39 UTC, Ali Çehreli wrote:
n 07/31/2019 12:05 PM, Paul Backus wrote:
> I would not recommend D as a beginning language, both because
there are
> fewer beginner-oriented resources available for it than for C
and Python
> (the only one I know of is Ali
Hi everyone,
I would like an honest opinion.
I have a beginner level (able to do very small programs) in a few
languages such as python, go, C, guile(scheme) and common lisp.
I want to pick a language and go deep with it and focus on only
one for at least the next 2 years or so.
Should I
On Thursday, 1 August 2019 at 15:42:08 UTC, a11e99z wrote:
On Thursday, 1 August 2019 at 15:17:11 UTC, a11e99z wrote:
[...]
imo better choice is (with criteria to find best job)
- Qt:
C++ with any library that u need in one style
- C#:
web, graphics, mobiles, command tools with nice
38 matches
Mail list logo