Re: "readln" after "readf"

2023-09-21 Thread pascal111 via Digitalmars-d-learn
On Thursday, 21 September 2023 at 11:30:02 UTC, Steven Schveighoffer wrote: On Thursday, 21 September 2023 at 09:14:14 UTC, pascal111 wrote: [...] Your readfs are not consuming the newline at the end. Add `\n` to the end of the format text. -Steve It works fine now, thanks!

"readln" after "readf"

2023-09-21 Thread pascal111 via Digitalmars-d-learn
I've a problem when I'm using "readln" after "readf" that I couldn't see my program rest and the lines of the execution ran fast: module main; import std.stdio; import std.string; import std.conv; int main(string[] args) { char[] yy; int x,y,z; writef("Enter a

Re: A GtkD issue

2022-08-18 Thread pascal111 via Digitalmars-d-learn
On Monday, 15 August 2022 at 17:33:25 UTC, frame wrote: On Saturday, 13 August 2022 at 01:14:09 UTC, pascal111 wrote: I was following instructions from this link https://gtkdcoding.com/2019/01/11/-introduction-to-gtkDcoding.html to setup GtkD, and tried to run the example with VSCode and

A GtkD issue

2022-08-12 Thread pascal111 via Digitalmars-d-learn
I was following instructions from this link https://gtkdcoding.com/2019/01/11/-introduction-to-gtkDcoding.html to setup GtkD, and tried to run the example with VSCode and found these errors: "a virtual call inside a constructor may lead to unexpected results in the derived classes" in

Re: My programs issues

2022-08-12 Thread pascal111 via Digitalmars-d-learn
On Friday, 12 August 2022 at 19:18:38 UTC, frame wrote: On Friday, 12 August 2022 at 18:43:14 UTC, pascal111 wrote: On Friday, 12 August 2022 at 16:06:09 UTC, frame wrote: On Thursday, 11 August 2022 at 20:30:54 UTC, pascal111 wrote: https://github.com/pascal111-fra/D/blob/main/proj08.d

Re: My programs issues

2022-08-12 Thread pascal111 via Digitalmars-d-learn
On Friday, 12 August 2022 at 19:18:38 UTC, frame wrote: On Friday, 12 August 2022 at 18:43:14 UTC, pascal111 wrote: On Friday, 12 August 2022 at 16:06:09 UTC, frame wrote: On Thursday, 11 August 2022 at 20:30:54 UTC, pascal111 wrote: https://github.com/pascal111-fra/D/blob/main/proj08.d

Re: My programs issues

2022-08-12 Thread pascal111 via Digitalmars-d-learn
On Friday, 12 August 2022 at 16:06:09 UTC, frame wrote: On Thursday, 11 August 2022 at 20:30:54 UTC, pascal111 wrote: https://github.com/pascal111-fra/D/blob/main/proj08.d btw letters :D Please use ` (ASCII: 0x60) instead of ' (0x27) for the markdown format header, eg.: ```D ...```

Re: My programs issues

2022-08-12 Thread pascal111 via Digitalmars-d-learn
On Friday, 12 August 2022 at 07:02:32 UTC, Antonio wrote: On Wednesday, 10 August 2022 at 13:13:20 UTC, Adam D Ruppe wrote: On Wednesday, 10 August 2022 at 12:36:42 UTC, pascal111 wrote: 1) I used "exit()" from "core.stdc.stdlib;" module, but someone can say this isn't the D way to exit the

Re: My programs issues

2022-08-11 Thread pascal111 via Digitalmars-d-learn
This is a program for duplicating files, I made some changes on it, and liked to share it may that I get a new advice on it: '''D module main; // D programming language import std.stdio; import std.string; import std.algorithm; import dcollect; int main(string[] args) { string s; //char[]

Re: My programs issues

2022-08-11 Thread pascal111 via Digitalmars-d-learn
Next code receiving an input from the user and reprint it in capital letters with a separator between each letter, but I think that there is more to add or to modify the way this program working with: '''D module main; import std.stdio; import std.uni; import std.string; import

Re: My programs issues

2022-08-10 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 10 August 2022 at 14:45:05 UTC, Andrey Zherikov wrote: On Wednesday, 10 August 2022 at 14:08:59 UTC, pascal111 wrote: This version has modern features, it's 1) functional 2) goto-less. There is nothing modern ;-D Take a look in this linear programming and you will know what's

Re: My programs issues

2022-08-10 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 10 August 2022 at 14:03:53 UTC, Andrey Zherikov wrote: On Wednesday, 10 August 2022 at 13:34:53 UTC, pascal111 wrote: So, the program will be like this: Is this clearer? ```d import std.stdio; import std.algorithm; import std.range; double getNumber() { double x;

Re: My programs issues

2022-08-10 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 10 August 2022 at 13:22:03 UTC, rikki cattermole wrote: On 11/08/2022 12:36 AM, pascal111 wrote: 2) I used "goto", I heard from someone before that using "goto" isn't good programming feature. This is mostly a historical debate at this point. Back 40 years ago, goto wasn't

Re: My programs issues

2022-08-10 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 10 August 2022 at 13:13:20 UTC, Adam D Ruppe wrote: On Wednesday, 10 August 2022 at 12:36:42 UTC, pascal111 wrote: 1) I used "exit()" from "core.stdc.stdlib;" module, but someone can say this isn't the D way to exit the program. It is better to simply return a value from main

My programs issues

2022-08-10 Thread pascal111 via Digitalmars-d-learn
In next program 1) I used "exit()" from "core.stdc.stdlib;" module, but someone can say this isn't the D way to exit the program. 2) I used "goto", I heard from someone before that using "goto" isn't good programming feature. '''D module proj07; import std.stdio; import std.algorithm;

Re: "min" and "max"

2022-08-09 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 10 August 2022 at 00:32:02 UTC, Ali Çehreli wrote: On 8/9/22 17:03, pascal111 wrote: > as a beginner how can I guess what "NaNs" > means or if it refers to ranges?! You can use the index: ;) http://ddili.org/ders/d.en/ix.html There are a couple of entries for 'nan' there.

Re: "min" and "max"

2022-08-09 Thread pascal111 via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 23:56:53 UTC, Paul Backus wrote: On Tuesday, 9 August 2022 at 23:35:23 UTC, pascal111 wrote: "min" and "max" in "std.algorithm" can be used with single values to pick up the min and max values, but it didn't mention how they can be used with ranges in the

"min" and "max"

2022-08-09 Thread pascal111 via Digitalmars-d-learn
"min" and "max" in "std.algorithm" can be used with single values to pick up the min and max values, but it didn't mention how they can be used with ranges in the documentation: https://dlang.org/phobos/std_algorithm_comparison.html#.min

Re: Fix template parameter

2022-08-09 Thread pascal111 via Digitalmars-d-learn
On Monday, 8 August 2022 at 14:48:27 UTC, Dom Disc wrote: On Monday, 8 August 2022 at 12:46:48 UTC, bauss wrote: On Monday, 8 August 2022 at 12:02:02 UTC, Dom Disc wrote: ```D pure @nogc @safe BigInt opAssign(T : BigInt)(T x); ``` This will only be included in the object file if used.

Re: Copying and array into another

2022-08-09 Thread pascal111 via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 18:41:52 UTC, Paul Backus wrote: On Tuesday, 9 August 2022 at 18:33:04 UTC, pascal111 wrote: I tried to copy an array into another without affecting in the original array when I try to change the value of any element of the new array, but I failed except with this

Re: Copying and array into another

2022-08-09 Thread pascal111 via Digitalmars-d-learn
Edit "Copying an array into another" in the title.

Copying and array into another

2022-08-09 Thread pascal111 via Digitalmars-d-learn
I tried to copy an array into another without affecting in the original array when I try to change the value of any element of the new array, but I failed except with this way in the next code: '''D int[] x=[1,2,3]; int[] y=x.filter!("a==a").array; y[1]=800; x.writeln;

Re: A look inside "filter" function defintion

2022-08-09 Thread pascal111 via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 18:23:04 UTC, Ali Çehreli wrote: On 8/2/22 05:39, pascal111 wrote: > I'm still stuck. Do you have a > down-to-earth example for beginners to understand this concept? I will refer to my explanation because down-to-earth has always been my goal. I hope i succeeded:

Re: Breaking ";" rule with lambda functions

2022-08-09 Thread pascal111 via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 18:10:25 UTC, Ali Çehreli wrote: On 8/2/22 09:40, pascal111 wrote: > [...] in C++, so > [...] Lambdas are a common feature of many programming languages. C++ got lambdas in their C++11 release, many years after D and many other languages had them. (It is not

Re: "chain" vs "~"

2022-08-08 Thread pascal111 via Digitalmars-d-learn
On Monday, 8 August 2022 at 18:49:26 UTC, Ali Çehreli wrote: On 8/6/22 18:22, pascal111 wrote: > [...] To add to what has already mentioned, - chain can be used on ranges that are of different element types [...] Thanks for explanation!

Re: "chain" vs "~"

2022-08-08 Thread pascal111 via Digitalmars-d-learn
On Monday, 8 August 2022 at 13:26:49 UTC, frame wrote: On Monday, 8 August 2022 at 01:05:40 UTC, pascal111 wrote: In next program, I used "insertInPlace", not "~" nor "chain", should I use "~" or it's the same as "insertInPlace"? https://github.com/pascal111-fra/D/blob/main/coco.d As you

Re: Supporting Arabic in GUI

2022-08-08 Thread pascal111 via Digitalmars-d-learn
On Monday, 8 August 2022 at 19:47:35 UTC, Sergey wrote: On Sunday, 7 August 2022 at 23:48:22 UTC, pascal111 wrote: [...] I think it is possible to find framework to solve the issues in D.. my guess is based on information from the project ArabiaWeather https://dlang.org/orgs-using-d.html

"only" vs "[]"

2022-08-08 Thread pascal111 via Digitalmars-d-learn
The output of next code is the same to extent that we feel that there's no difference between "only" and "[]", so what "only" added here?: '''D [1,2,3].writeln; only(1,2,3).writeln; ''' output: [1, 2, 3] [1, 2, 3]

Re: "chain" vs "~"

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 03:55:50 UTC, Emanuele Torre wrote: On Sunday, 7 August 2022 at 01:22:18 UTC, pascal111 wrote: [...] They are quite different: * `chain` gives you "range" (iterator) that starts from the first element of `x` and ends at the last element of `y` (like e.g. `zip` in

Re: Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Monday, 8 August 2022 at 00:18:12 UTC, Emanuele Torre wrote: On Monday, 8 August 2022 at 00:11:33 UTC, pascal111 wrote: [...] You are just sounding like a troll now... "troll" :) I like it! That makes no sense: "I assume that there are some special tasks D can do, while Python can't

Re: Supporting Arabic in GUI

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Monday, 8 August 2022 at 00:20:53 UTC, pascal111 wrote: On Monday, 8 August 2022 at 00:12:07 UTC, Emanuele Torre wrote: On Sunday, 7 August 2022 at 23:48:22 UTC, pascal111 wrote: [...] I am very confused by this question. That has nothing to do with the programming language: it has all

Re: Supporting Arabic in GUI

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Monday, 8 August 2022 at 00:12:07 UTC, Emanuele Torre wrote: On Sunday, 7 August 2022 at 23:48:22 UTC, pascal111 wrote: I have no idea about GUI or Rad programming in D; it's not its time, but I'm curious to know if D is fine supporting for Arabic language in the GUI applications or we will

Re: Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 23:44:26 UTC, Emanuele Torre wrote: On Sunday, 7 August 2022 at 23:31:45 UTC, pascal111 wrote: On Sunday, 7 August 2022 at 22:16:55 UTC, Emanuele Torre wrote: [...] It seems complex, I didn't get it yet, I wished I didn't ask about it :) It's really trivial.

Re: Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 23:53:36 UTC, Emanuele Torre wrote: On Sunday, 7 August 2022 at 16:01:08 UTC, pascal111 wrote: It's clear by working with D that it has the same bad point like Pascal language; the "verbosity". Is there any plans in future to make some shorthanded techniques that

Supporting Arabic in GUI

2022-08-07 Thread pascal111 via Digitalmars-d-learn
I have no idea about GUI or Rad programming in D; it's not its time, but I'm curious to know if D is fine supporting for Arabic language in the GUI applications or we will have some issues like I met - in my experience - in Free Pascal. This is a topic where we trying to make a custom message

Re: Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 22:16:55 UTC, Emanuele Torre wrote: On Sunday, 7 August 2022 at 20:15:05 UTC, pascal111 wrote: What destructuring binds? I didn't hear about that before. ```C++ #include struct Point { int x, y; }; Point add_points(const Point& a, const Point& b) {

Re: Ranges

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 21:57:50 UTC, Ali Çehreli wrote: On 8/7/22 08:34, pascal111 wrote: > but after that in advanced level in programming, we should > use pointers to do same tasks we were doing with slices (the easy way of > beginners). That is an old thought. Today, we see that no

Re: Ranges

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 19:53:06 UTC, ag0aep6g wrote: On Sunday, 7 August 2022 at 15:34:19 UTC, pascal111 wrote: Everyone knows that slices are not pointers that pointers are real work, but slices are like a simple un-deep technique that is appropriate for beginners, but after that in

Re: Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 16:45:15 UTC, jfondren wrote: On Sunday, 7 August 2022 at 16:01:08 UTC, pascal111 wrote: It's clear by working with D that it has the same bad point like Pascal language; the "verbosity". Is there any plans in future to make some shorthanded techniques that clean

Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn
It's clear by working with D that it has the same bad point like Pascal language; the "verbosity". Is there any plans in future to make some shorthanded techniques that clean verbosity from D? Quote: "In terms of functionality, Pascal is pretty much exactly the same as C, except with some

Re: Ranges

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 05:12:38 UTC, Ali Çehreli wrote: On 8/6/22 14:10, pascal111 wrote: > a powerful point in the account of C. I missed how you made that connection. Everyone knows that slices are not pointers that pointers are real work, but slices are like a simple un-deep

Re: "chain" vs "~"

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 03:55:50 UTC, Emanuele Torre wrote: On Sunday, 7 August 2022 at 01:22:18 UTC, pascal111 wrote: [...] They are quite different: * `chain` gives you "range" (iterator) that starts from the first element of `x` and ends at the last element of `y` (like e.g. `zip` in

"chain" vs "~"

2022-08-06 Thread pascal111 via Digitalmars-d-learn
Why we use "chain" while we have "~": '''D int[] x=[1,2,3]; int[] y=[4,5,6]; auto z=chain(x,y); auto j=x~y; '''

Re: Ranges

2022-08-06 Thread pascal111 via Digitalmars-d-learn
On Saturday, 6 August 2022 at 15:54:57 UTC, H. S. Teoh wrote: On Sat, Aug 06, 2022 at 03:37:32PM +, pascal111 via Digitalmars-d-learn wrote: On Friday, 5 August 2022 at 04:05:08 UTC, Salih Dincer wrote: > On Thursday, 4 August 2022 at 22:54:42 UTC, pascal111 wrote: > > [...] &g

Re: Ranges

2022-08-06 Thread pascal111 via Digitalmars-d-learn
On Friday, 5 August 2022 at 04:05:08 UTC, Salih Dincer wrote: On Thursday, 4 August 2022 at 22:54:42 UTC, pascal111 wrote: I didn't notice that all what we needs to pop a range forward is just a slice, yes, we don't need variable here. Ranges and Slices are not the same thing. Slicing an

Re: Hacking C code vs D code

2022-08-05 Thread pascal111 via Digitalmars-d-learn
On Friday, 5 August 2022 at 01:46:35 UTC, Paul Backus wrote: On Thursday, 4 August 2022 at 23:11:36 UTC, pascal111 wrote: One of problems faced me in C programming is hacking data with C code that some hackers do with C code which make me needs more tools to protect my C code, but I don't have

Re: curses/ncurses liberary in D

2022-08-05 Thread pascal111 via Digitalmars-d-learn
On Friday, 5 August 2022 at 12:02:27 UTC, Adam D Ruppe wrote: On Friday, 5 August 2022 at 04:14:22 UTC, H. S. Teoh wrote: including cursorX, cursorY Worth noting these are not initialized in linear mode, only in fullscreen/cellular. I might change that soon, it is on my todo list.

Re: curses/ncurses liberary in D

2022-08-05 Thread pascal111 via Digitalmars-d-learn
On Friday, 5 August 2022 at 04:14:22 UTC, H. S. Teoh wrote: On Thu, Aug 04, 2022 at 11:52:48PM +, pascal111 via Digitalmars-d-learn wrote: On Thursday, 4 August 2022 at 21:35:37 UTC, Adam D Ruppe wrote: > On Thursday, 4 August 2022 at 21:15:39 UTC, pascal111 wrote: > > > https:

Re: curses/ncurses liberary in D

2022-08-04 Thread pascal111 via Digitalmars-d-learn
On Thursday, 4 August 2022 at 21:35:37 UTC, Adam D Ruppe wrote: On Thursday, 4 August 2022 at 21:15:39 UTC, pascal111 wrote: https://github.com/adamdruppe/arsd/blob/master/terminal.d How can I use this terminal module? Is there a document for it?

Hacking C code vs D code

2022-08-04 Thread pascal111 via Digitalmars-d-learn
One of problems faced me in C programming is hacking data with C code that some hackers do with C code which make me needs more tools to protect my C code, but I don't have good resources in my current time, while I noticed that D code is more secure than C code by mean it will be more useful

Re: CMake and D

2022-08-04 Thread pascal111 via Digitalmars-d-learn
On Thursday, 4 August 2022 at 20:59:50 UTC, Johan wrote: On Thursday, 4 August 2022 at 20:29:30 UTC, Jan Allersma wrote: So something goes wrong with linking, but I dont know what. Execute `dmd -v` on some test program. It will output the linker line at the end of the output, the line

Re: Ranges

2022-08-04 Thread pascal111 via Digitalmars-d-learn
On Thursday, 4 August 2022 at 22:14:26 UTC, Ali Çehreli wrote: On 8/4/22 11:05, frame wrote: > `popFront()` The function was this: void popFront() { students = students[1 .. $]; } > copies all > elements except the first one into the variable (and overwrites it), so >

curses/ncurses liberary in D

2022-08-04 Thread pascal111 via Digitalmars-d-learn
https://forum.dlang.org/post/bjldcmojboremdrok...@forum.dlang.org On Wednesday, 3 November 2021 at 05:43:05 UTC, harakim wrote: On Wednesday, 3 November 2021 at 01:39:02 UTC, H. S. Teoh wrote: On Wed, Nov 03, 2021 at 01:33:28AM +, dangbinghoo via Digitalmars-d-learn wrote: On Wednesday, 3

Ranges

2022-08-04 Thread pascal111 via Digitalmars-d-learn
In next code from "https://www.tutorialspoint.com/d_programming/d_programming_ranges.htm;, we have two issues: 1) Why the programmer needs to program "empty()", "front()", and "popFront()" functions for ranges while they exist in the language library? it seems there's no need to exert efforts

Re: Obsecure problem 2

2022-08-04 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 21:35:29 UTC, Ruby The Roobster wrote: On Wednesday, 3 August 2022 at 19:11:51 UTC, pascal111 wrote: [...] No need for a code. See, there is a keyword called `ref`, that can be used both in function parameters and in foreach loops, and it is the equivalent of

Re: Obsecure problem 2

2022-08-04 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 21:37:50 UTC, jfondren wrote: On Wednesday, 3 August 2022 at 19:11:51 UTC, pascal111 wrote: [...] I agree to the extent that I wanted to do so, and might still have if a delivery hadn't interrupted by post. But one way to encourage others to put in more effort

Re: Obsecure problem 2

2022-08-03 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 18:53:35 UTC, jfondren wrote: On Wednesday, 3 August 2022 at 18:33:37 UTC, pascal111 wrote: I changed it to "x=notfunny(x);" and has the same result. Now you are changing the value of the temporary loop variable that is still immediately discarded afterwards.

Re: Obsecure problem 2

2022-08-03 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 18:25:50 UTC, jfondren wrote: On Wednesday, 3 August 2022 at 17:33:40 UTC, pascal111 wrote: On Wednesday, 3 August 2022 at 17:09:11 UTC, jfondren wrote: On Wednesday, 3 August 2022 at 16:59:53 UTC, pascal111 wrote: I tried to make a template that receive lambda

Re: Obsecure problem 2

2022-08-03 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 17:09:11 UTC, jfondren wrote: On Wednesday, 3 August 2022 at 16:59:53 UTC, pascal111 wrote: I tried to make a template that receive lambda expression to apply it on a given range the user specifies, but I found non-understood problem: Compare with: ```D auto

Obsecure problem 2

2022-08-03 Thread pascal111 via Digitalmars-d-learn
I tried to make a template that receive lambda expression to apply it on a given range the user specifies, but I found non-understood problem: '''D module main; import std.stdio; import std.functional; template foo(alias predicate) if (is(typeof(unaryFun!predicate))) {

Re: Breaking ";" rule with lambda functions

2022-08-02 Thread pascal111 via Digitalmars-d-learn
On Tuesday, 2 August 2022 at 11:27:05 UTC, Andrey Zherikov wrote: On Monday, 1 August 2022 at 14:15:31 UTC, pascal111 wrote: [...] TBH I don't find lambda syntax strange - it's pretty nice and there are two forms (unlike in C++): short one (`a => a > 0`) and long one (`(a) { return a > 0;

Re: A look inside "filter" function defintion

2022-08-02 Thread pascal111 via Digitalmars-d-learn
On Tuesday, 2 August 2022 at 14:24:50 UTC, frame wrote: On Tuesday, 2 August 2022 at 12:39:41 UTC, pascal111 wrote: Instantiation seems some complicated to me. I read "If a template contains members whose name is the same as the template identifier then these members are assumed to be

Re: A look inside "filter" function defintion

2022-08-02 Thread pascal111 via Digitalmars-d-learn
On Tuesday, 2 August 2022 at 04:06:30 UTC, frame wrote: On Monday, 1 August 2022 at 23:35:13 UTC, pascal111 wrote: This is the definition of "filter" function, and I think it called itself within its definition. I'm guessing how it works? It's a template that defines the function called

Re: How to check if a class has a specific overload for member x?

2022-08-01 Thread pascal111 via Digitalmars-d-learn
On Monday, 1 August 2022 at 00:23:21 UTC, Hipreme wrote: On Sunday, 31 July 2022 at 19:25:51 UTC, Hipreme wrote: [...] Seems that is how it should be checked: ```d enum hasOverload(T, string member, FuncType)() { bool ret; static foreach(overload;

A look inside "filter" function defintion

2022-08-01 Thread pascal111 via Digitalmars-d-learn
This is the definition of "filter" function, and I think it called itself within its definition. I'm guessing how it works? '''D template filter(alias predicate) if (is(typeof(unaryFun!predicate))) { /** Params: range = An $(REF_ALTTEXT input range, isInputRange,

Re: Breaking ";" rule with lambda functions

2022-08-01 Thread pascal111 via Digitalmars-d-learn
On Monday, 1 August 2022 at 21:35:19 UTC, Ivan Kazmenko wrote: On Monday, 1 August 2022 at 20:36:12 UTC, pascal111 wrote: My complaint is about that a function is not a same as an expression that functions return values, but expressions being evaluated to provide values. An analogy. With a

Re: Breaking ";" rule with lambda functions

2022-08-01 Thread pascal111 via Digitalmars-d-learn
On Monday, 1 August 2022 at 19:32:41 UTC, Paul Backus wrote: On Monday, 1 August 2022 at 14:52:03 UTC, pascal111 wrote: [...] From [the relevant section of the language spec:][1] [...] In other words, a function literal is an expression that evaluates to either a delegate or a function

Re: Breaking ";" rule with lambda functions

2022-08-01 Thread pascal111 via Digitalmars-d-learn
On Monday, 1 August 2022 at 17:01:33 UTC, frame wrote: On Monday, 1 August 2022 at 14:15:31 UTC, pascal111 wrote: [...] In C ";" is a termination character, in D is more like to separate statements. The lexer wouldn't need ";" for most cases like JavaScript and the expression syntax

Re: Breaking ";" rule with lambda functions

2022-08-01 Thread pascal111 via Digitalmars-d-learn
On Monday, 1 August 2022 at 16:00:50 UTC, ag0aep6g wrote: On Monday, 1 August 2022 at 15:52:34 UTC, pascal111 wrote: But how can we accept that both are functions and expressions at the same time and we know that expressions can be used to build functions themselves?!! I think they are not the

Re: Breaking ";" rule with lambda functions

2022-08-01 Thread pascal111 via Digitalmars-d-learn
On Monday, 1 August 2022 at 15:39:06 UTC, ag0aep6g wrote: On Monday, 1 August 2022 at 15:31:51 UTC, pascal111 wrote: Surely, because it seems that you are real man, your word must be taken. Isn't `(foo) { return bar; }` an anonymous function or am I a wrong?!! It IS a function, not an

Re: Breaking ";" rule with lambda functions

2022-08-01 Thread pascal111 via Digitalmars-d-learn
On Monday, 1 August 2022 at 15:08:04 UTC, ag0aep6g wrote: On Monday, 1 August 2022 at 14:52:03 UTC, pascal111 wrote: If `foo => bar` == `(foo) { return bar; }`, then `foo => bar` is a function. "=>" is not an operator, it's a special symbol for lambda "function". If A == B, so A's types is

Re: Breaking ";" rule with lambda functions

2022-08-01 Thread pascal111 via Digitalmars-d-learn
On Monday, 1 August 2022 at 14:46:33 UTC, ag0aep6g wrote: On Monday, 1 August 2022 at 14:39:17 UTC, pascal111 wrote: On Monday, 1 August 2022 at 14:34:45 UTC, ag0aep6g wrote: [...] `a => a > 0` is not a statement. It's an expression. But it is still a "function", and functions make

Re: Breaking ";" rule with lambda functions

2022-08-01 Thread pascal111 via Digitalmars-d-learn
On Monday, 1 August 2022 at 14:34:45 UTC, ag0aep6g wrote: On Monday, 1 August 2022 at 14:15:31 UTC, pascal111 wrote: Many of D rules are taken from C, we know that, so a general basic rule is to put ";" after each statement, so the previous statement of filter should be "auto r = chain(a,

Breaking ";" rule with lambda functions

2022-08-01 Thread pascal111 via Digitalmars-d-learn
We all know the strange syntax of lambda function within filter algorithm like "auto r = chain(a, b).filter!(a => a > 0);". My note is, don't we break D rules by leaving ";" after lambda function syntax?! Many of D rules are taken from C, we know that, so a general basic rule is to put ";"

Re: Exclamation symbol "!" within functions syntax

2022-08-01 Thread pascal111 via Digitalmars-d-learn
On Monday, 1 August 2022 at 12:58:27 UTC, Paul Backus wrote: On Monday, 1 August 2022 at 11:35:25 UTC, pascal111 wrote: I noticed that filter is using the concept of templates but this time it's with a lambda function, not with a data type, how can we explain this? isn't supposed to use a data

Re: Exclamation symbol "!" within functions syntax

2022-08-01 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 27 July 2022 at 11:09:19 UTC, Ali Çehreli wrote: On 7/27/22 04:00, pascal111 wrote: I noticed more than once that the exclamation "!" is used within functions typing, and it seems like an operator with new use, for example "to!int()", ".tee!(l => sum += l.length)",

Re: Obsecure problem 1

2022-07-31 Thread pascal111 via Digitalmars-d-learn
On Sunday, 31 July 2022 at 17:03:59 UTC, Salih Dincer wrote: On Sunday, 31 July 2022 at 15:01:21 UTC, pascal111 wrote: I don't know how "assert" works, if you explained it I'll be able to get the idea of your suggestion to apply the appropriate changes on my code. **// This code runs

Re: Obsecure problem 1

2022-07-31 Thread pascal111 via Digitalmars-d-learn
On Sunday, 31 July 2022 at 07:43:06 UTC, Salih Dincer wrote: On Sunday, 31 July 2022 at 00:58:47 UTC, pascal111 wrote: Another version of the program: https://github.com/pascal111-fra/D/blob/main/proj04.d I have a few more suggestions for you; Among them the first is on the following

Re: Obsecure problem 1

2022-07-30 Thread pascal111 via Digitalmars-d-learn
Another version of the program: https://github.com/pascal111-fra/D/blob/main/proj04.d

Re: Obsecure problem 1

2022-07-30 Thread pascal111 via Digitalmars-d-learn
On Saturday, 30 July 2022 at 22:45:14 UTC, Salih Dincer wrote: On Saturday, 30 July 2022 at 22:17:10 UTC, pascal111 wrote: The program works fine now: https://i.postimg.cc/3wkgXmVs/Screenshot-from-2022-07-31-00-04-23.png I have a suggestion for you. Use modern possibilities instead of

Re: Obsecure problem 1

2022-07-30 Thread pascal111 via Digitalmars-d-learn
On Saturday, 30 July 2022 at 22:28:52 UTC, frame wrote: On Saturday, 30 July 2022 at 22:13:55 UTC, pascal111 wrote: Because copying the running window contents is not allowed, I couldn't do it in Code::Blocks. Not allowed? o.O Did you try to select the text and insert it via middle mouse

Re: Obsecure problem 1

2022-07-30 Thread pascal111 via Digitalmars-d-learn
On Saturday, 30 July 2022 at 21:48:35 UTC, rikki cattermole wrote: It is a pretty straight forward. You tried to access memory out of bounds of the slice. https://github.com/pascal111-fra/D/blob/main/dcollect.d#L34 That for loop is problematic in a number of ways. You should not use int, or

Re: Obsecure problem 1

2022-07-30 Thread pascal111 via Digitalmars-d-learn
On Saturday, 30 July 2022 at 21:52:42 UTC, frame wrote: On Saturday, 30 July 2022 at 21:24:50 UTC, pascal111 wrote: I've typed a code to enjoy with my library "dcollect", and found non-understandable error: ... Running screen says:

Obsecure problem 1

2022-07-30 Thread pascal111 via Digitalmars-d-learn
I've typed a code to enjoy with my library "dcollect", and found non-understandable error: module main; import std.stdio; import dcollect; import std.string; import std.conv; int main(string[] args) { string sentence_x, sent_result, token2; string[] sentence_tokens;

Re: Some user-made C functions and their D equivalents

2022-07-30 Thread pascal111 via Digitalmars-d-learn
On Thursday, 28 July 2022 at 23:08:15 UTC, frame wrote: On Thursday, 28 July 2022 at 20:20:27 UTC, pascal111 wrote: I retyped again some function of C library I made before, but with D code: It's a start but you need to learn. Thanks! I made the equivalent of my C library "collect":

Re: A converting problem in using "among" with arrays

2022-07-29 Thread pascal111 via Digitalmars-d-learn
On Friday, 29 July 2022 at 22:12:54 UTC, Andrey Zherikov wrote: On Friday, 29 July 2022 at 22:09:47 UTC, pascal111 wrote: I next code, we have a data type problem "54.among(to!uint[10](y)).writeln;": module main; import std.stdio; import std.string; import std.conv; import dcollect; import

A converting problem in using "among" with arrays

2022-07-29 Thread pascal111 via Digitalmars-d-learn
I next code, we have a data type problem "54.among(to!uint[10](y)).writeln;": module main; import std.stdio; import std.string; import std.conv; import dcollect; import std.math; import std.algorithm; int main(string[] args) { int[] x=[23, 34,-88, 54, -90, -34]; auto

Re: "strstr" D equivalent

2022-07-29 Thread pascal111 via Digitalmars-d-learn
On Friday, 29 July 2022 at 15:39:16 UTC, Salih Dincer wrote: On Friday, 29 July 2022 at 14:14:54 UTC, pascal111 wrote: we won't find that there is a definition for it with just two parameters, so from where you got this new definition of this function?! This thread is about

Re: "strstr" D equivalent

2022-07-29 Thread pascal111 via Digitalmars-d-learn
On Friday, 29 July 2022 at 13:44:47 UTC, Salih Dincer wrote: **Short version:** ```d import std.string; import std.stdio; void find (string str, string substr) { if(auto pos = str.indexOf(substr)) { writefln("found the string '%s' in '%s' at position: %s", substr, str, pos);

"strstr" D equivalent

2022-07-29 Thread pascal111 via Digitalmars-d-learn
Is there an equivalent in D for C function "strstr" that return the first occurrence of a given string within another string? https://en.cppreference.com/w/c/string/byte/strstr

Re: "strtok" D equivalent

2022-07-28 Thread pascal111 via Digitalmars-d-learn
On Thursday, 28 July 2022 at 23:16:15 UTC, Paul Backus wrote: On Thursday, 28 July 2022 at 21:52:28 UTC, pascal111 wrote: On Thursday, 28 July 2022 at 20:36:31 UTC, Paul Backus wrote: ```d import std.algorithm: filter; import std.range: empty; import std.functional: not; // ... auto

Re: "strtok" D equivalent

2022-07-28 Thread pascal111 via Digitalmars-d-learn
On Thursday, 28 July 2022 at 23:16:15 UTC, Paul Backus wrote: On Thursday, 28 July 2022 at 21:52:28 UTC, pascal111 wrote: On Thursday, 28 July 2022 at 20:36:31 UTC, Paul Backus wrote: ```d import std.algorithm: filter; import std.range: empty; import std.functional: not; // ... auto

Re: "strtok" D equivalent

2022-07-28 Thread pascal111 via Digitalmars-d-learn
On Thursday, 28 July 2022 at 20:36:31 UTC, Paul Backus wrote: On Thursday, 28 July 2022 at 19:17:26 UTC, pascal111 wrote: What's the "strtok" - C function - D equivalent? https://en.cppreference.com/w/cpp/string/byte/strtok Closest thing is probably `std.algorithm.splitter` with a

Re: "strtok" D equivalent

2022-07-28 Thread pascal111 via Digitalmars-d-learn
On Thursday, 28 July 2022 at 19:37:31 UTC, rikki cattermole wrote: I don't know of a D version, although it should be pretty easy to write up yourself. But you can always use strtok itself.

Re: Some user-made C functions and their D equivalents

2022-07-28 Thread pascal111 via Digitalmars-d-learn
On Thursday, 28 July 2022 at 17:46:49 UTC, frame wrote: On Thursday, 28 July 2022 at 16:45:55 UTC, pascal111 wrote: Aha! "In theory, someone could inject bad code", you admit my theory. The code would need to work and pass merge tests too. The merge reason must match in review. If someone

"strtok" D equivalent

2022-07-28 Thread pascal111 via Digitalmars-d-learn
What's the "strtok" - C function - D equivalent? https://en.cppreference.com/w/cpp/string/byte/strtok

Re: Some user-made C functions and their D equivalents

2022-07-28 Thread pascal111 via Digitalmars-d-learn
On Thursday, 28 July 2022 at 17:21:57 UTC, H. S. Teoh wrote: On Thu, Jul 28, 2022 at 04:45:55PM +, pascal111 via Digitalmars-d-learn wrote: [...] In theory, Ken Thompson's compromised compiler hack could be at work[1]. [...] I think you say advanced technical information. My

Re: Some user-made C functions and their D equivalents

2022-07-28 Thread pascal111 via Digitalmars-d-learn
On Thursday, 28 July 2022 at 16:37:35 UTC, frame wrote: On Thursday, 28 July 2022 at 16:17:16 UTC, pascal111 wrote: My friend, there is a wide deep secret world for hackers. We have no any idea about that world. Look, there is nothing called a 100% fact in our world. Believe me, what we see

Re: BASIC "sgn" function equivalent

2022-07-28 Thread pascal111 via Digitalmars-d-learn
On Thursday, 28 July 2022 at 15:38:18 UTC, H. S. Teoh wrote: On Thu, Jul 28, 2022 at 03:10:19PM +, pascal111 via Digitalmars-d-learn wrote: > [...] [...] [...] AFAIK, all D compilers ship with full Phobos source code. On my installation, it's in /usr/lib/gcc/x86_64-linux-gnu

Re: Some user-made C functions and their D equivalents

2022-07-28 Thread pascal111 via Digitalmars-d-learn
On Thursday, 28 July 2022 at 16:13:17 UTC, frame wrote: On Thursday, 28 July 2022 at 14:57:36 UTC, pascal111 wrote: well between US and some other countries like "Russia", and they are using US products like C compilers, so with some way we have a doubt that US developed compilers with a way

  1   2   >