Re: Challenge: Make a data type for holding one of 8 directions allowing increment and overflow

2024-03-12 Thread Salih Dincer via Digitalmars-d-learn
On Tuesday, 12 March 2024 at 05:38:03 UTC, Liam McGillivray wrote: Perhaps this would be a good programming challenge for someone more experienced than me. Make a data type (probably a struct) for holding one of 8 directional values using 3 bits. It should accept the use of increment operators

Re: Challenge: Make a data type for holding one of 8 directions allowing increment and overflow

2024-03-12 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 13/03/2024 11:00 AM, Liam McGillivray wrote: I'm not familiar with the syntax of the line |value &= 7;|. Is it equivalent to writing |value = value % 7;|? & is a bitwise and. LSB 123456789 MSB & 7 LSB 12300 MSB Anyway, you used an int, but I used an array of 3 bools. I'm guessing

Re: Challenge: Make a data type for holding one of 8 directions allowing increment and overflow

2024-03-12 Thread Liam McGillivray via Digitalmars-d-learn
On Tuesday, 12 March 2024 at 06:38:28 UTC, Richard (Rikki) Andrew Cattermole wrote: By taking advantage of integer wrapping and a bitwise and, its quite a simple problem to solve! Challenge for the reader: add support for binary operations and toString support.

Re: Disable wrilten buf in docker

2024-03-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 12 March 2024 at 06:36:09 UTC, zoujiaqing wrote: Hi, my application use writeln in docker don't display. Python add -u disable it. https://stackoverflow.com/questions/29663459/why-doesnt-python-app-print-anything-when-run-in-a-detached-docker-container Use setvbuf to switch to

Re: Disable wrilten buf in docker

2024-03-12 Thread john rath via Digitalmars-d-learn
I'm glad you find it helpful! If you have any more questions, whether it's about fashion or anything else, feel free to ask. I'm here to assist you with any information or insights you might need.https://vjackets.com/

Re: Disable wrilten buf in docker

2024-03-12 Thread zoujiaqing via Digitalmars-d-learn
On Tuesday, 12 March 2024 at 06:39:40 UTC, Richard (Rikki) Andrew Cattermole wrote: On D's side you can use ``stdout.flush;`` to force it to flush. I don't think there is a way to force flushing via CLI. OK, thank you! Problem solved! Use code: ```D std.stdio.stdout.flush(); ```

Re: Disable wrilten buf in docker

2024-03-12 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On D's side you can use ``stdout.flush;`` to force it to flush. I don't think there is a way to force flushing via CLI.

Re: Challenge: Make a data type for holding one of 8 directions allowing increment and overflow

2024-03-12 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
By taking advantage of integer wrapping and a bitwise and, its quite a simple problem to solve! Challenge for the reader: add support for binary operations and toString support. https://dlang.org/spec/operatoroverloading.html ```d struct Direction { private int value; Direction

Disable wrilten buf in docker

2024-03-12 Thread zoujiaqing via Digitalmars-d-learn
Hi, my application use writeln in docker don't display. Python add -u disable it. https://stackoverflow.com/questions/29663459/why-doesnt-python-app-print-anything-when-run-in-a-detached-docker-container