Re: "Error: function expected before (), not module *module* of type void

2018-09-22 Thread ag0aep6g via Digitalmars-d-learn

On 09/22/2018 04:51 AM, Samir wrote:
Thanks for your help, Adam!  Right after posting my question, I started 
reading this site:

https://www.tutorialspoint.com/d_programming/d_programming_modules.htm


Better read the original:

http://ddili.org/ders/d.en/modules.html


Re: Converting a character to upper case in string

2018-09-22 Thread bauss via Digitalmars-d-learn
On Saturday, 22 September 2018 at 06:01:20 UTC, Vladimir 
Panteleev wrote:

On Friday, 21 September 2018 at 12:15:52 UTC, NX wrote:
How can I properly convert a character, say, first one to 
upper case in a unicode correct manner?


That would depend on how you'd define correctness. If your 
application needs to support "all" languages, then (depending 
how you interpret it) the task may not be meaningful, as some 
languages don't have the notion of "upper-case" or even 
"character" (as an individual glyph). Some languages do have 
those notions, but they serve a specific purpose that doesn't 
align with the one in English (e.g. Lojban).


In which code level I should be working on? Grapheme? Or maybe 
code point is sufficient?


Using graphemes is necessary if you need to support e.g. 
combining marks (e.g. ̏◌ + S = ̏S).


Uppercase and Lowercase gets even more funky with Turkish.


Re: Converting a character to upper case in string

2018-09-22 Thread Patrick Schluter via Digitalmars-d-learn
On Saturday, 22 September 2018 at 06:01:20 UTC, Vladimir 
Panteleev wrote:

On Friday, 21 September 2018 at 12:15:52 UTC, NX wrote:
How can I properly convert a character, say, first one to 
upper case in a unicode correct manner?


That would depend on how you'd define correctness. If your 
application needs to support "all" languages, then (depending 
how you interpret it) the task may not be meaningful, as some 
languages don't have the notion of "upper-case" or even 
"character" (as an individual glyph). Some languages do have 
those notions, but they serve a specific purpose that doesn't 
align with the one in English (e.g. Lojban).


There are other traps in the question of uppercase/lowercase 
which makes is indeed very difficult to handle correctly if we 
don't define what correctly means.

Examples:
- It may be necessary to know the locale, i.e. the language of 
the string to uppercase. In Turkish uppercase of i is not I but İ 
and lowercase of I is ı (that was a reason for the calamitous low 
performance of toUpper/toLower in Java for example.
- Some uppercases depend on what they are used for. German ß 
shouldbe uppercased as SS (note also btw that 1 codepoint becomes 
2 in uppercase) in normal text, but for calligraphic work, road 
signs and other usages it can be capital ẞ.
- Greek has 2 lowercase forms for Σ but two lowercase forms σ and 
ς depending on the word position.
- While it becomes less and less relevant Serbo-croatian may use 
digraphs when transcoding the script from Cyrillic (Serbian) to 
Latin (Croatian), these digraphs have 2 uppercase forms 
(title-case and all capital):

  - dž -> DŽ or Dž
  - lj -> LJ or Lj
  - NJ -> Nj or nj
Normalization would normally take care of that case.
- Some languages may modify or remove diacritical signs when 
uppercasing. It is quite usual in French to not put accents on 
capitals.


It is also clear that the operation of uppercasing is not 
symetric with lowercasing.




In which code level I should be working on? Grapheme? Or maybe 
code point is sufficient?


Using graphemes is necessary if you need to support e.g. 
combining marks (e.g. ̏◌ + S = ̏S).





Re: transposed with enforceNotJagged not throwing?

2018-09-22 Thread berni via Digitalmars-d-learn
On Saturday, 22 September 2018 at 12:52:45 UTC, Steven 
Schveighoffer wrote:
It was suggested when transposed was fixed to include opIndex, 
but never implemented.


Maybe I'm too naive, but isn't it easy to implement it just the 
same way, it is done with transverse? That is: putting the 
"static if"-part from the constructor there in the constructor of 
Transposed?




Re: transposed with enforceNotJagged not throwing?

2018-09-22 Thread Steven Schveighoffer via Digitalmars-d-learn

On 9/22/18 4:10 AM, Vladimir Panteleev wrote:

On Saturday, 22 September 2018 at 06:16:41 UTC, berni wrote:

Is it a bug or is it me who's doing something wrong?


Looking at the implementation, it looks like enforceNotJagged was just 
never implemented for transposed (only transversed).




It was suggested when transposed was fixed to include opIndex, but never 
implemented.


https://github.com/dlang/phobos/pull/5805#discussion_r148251621

-Steve


Re: transposed with enforceNotJagged not throwing?

2018-09-22 Thread Vladimir Panteleev via Digitalmars-d-learn

On Saturday, 22 September 2018 at 06:16:41 UTC, berni wrote:

Is it a bug or is it me who's doing something wrong?


Looking at the implementation, it looks like enforceNotJagged was 
just never implemented for transposed (only transversed).




transposed with enforceNotJagged not throwing?

2018-09-22 Thread berni via Digitalmars-d-learn

I expect this small program to throw an Exception:


import std.stdio;
import std.range;

void main()
{
auto a = [[1,2],
  [4,5,3]];

a.transposed!(TransverseOptions.enforceNotJagged).writeln;
}


But it just outputs:


[[1, 4], [2, 5], [3]]


Is it a bug or is it me who's doing something wrong?


Re: Converting a character to upper case in string

2018-09-22 Thread Vladimir Panteleev via Digitalmars-d-learn

On Friday, 21 September 2018 at 12:15:52 UTC, NX wrote:
How can I properly convert a character, say, first one to upper 
case in a unicode correct manner?


That would depend on how you'd define correctness. If your 
application needs to support "all" languages, then (depending how 
you interpret it) the task may not be meaningful, as some 
languages don't have the notion of "upper-case" or even 
"character" (as an individual glyph). Some languages do have 
those notions, but they serve a specific purpose that doesn't 
align with the one in English (e.g. Lojban).


In which code level I should be working on? Grapheme? Or maybe 
code point is sufficient?


Using graphemes is necessary if you need to support e.g. 
combining marks (e.g. ̏◌ + S = ̏S).




Re: SerialPort

2018-09-22 Thread Vladimir Panteleev via Digitalmars-d-learn

On Thursday, 20 September 2018 at 10:51:52 UTC, braboar wrote:

Can anybody give me a guide of using serial port?


Here's a program I wrote (after lots of trial-and-error) to 
control my monitor through an USB serial-port adapter:


https://github.com/CyberShadow/misc/blob/master/pq321q.d

Hope this helps.