I'm making anagrams. According to the nextPermutation() docs, I
need to 'sort by less' to get all permutations. ... Except the
doc page doesn't mention how to do that, nor does
std.algorithm.sort show how to sort a string. ... and the google
results on the dlang forums from 2017 don't work.
On Friday, 1 May 2020 at 07:38:53 UTC, Chris Katko wrote:
I'm making anagrams. According to the nextPermutation() docs, I
need to 'sort by less' to get all permutations. ... Except the
doc page doesn't mention how to do that, nor does
std.algorithm.sort show how to sort a string. ... and the
On Friday, 1 May 2020 at 08:17:33 UTC, norm wrote:
On Friday, 1 May 2020 at 07:38:53 UTC, Chris Katko wrote:
[...]
You need to convert the sort output to dchar[], e.g.
---
dchar[] line3 = sort(line2.to!(dchar[])).to!(dchar[]);
---
Cheers,
Norm
That works, thanks!
01.05.2020 10:38, Chris Katko пишет:
I'm making anagrams. According to the nextPermutation() docs, I need to
'sort by less' to get all permutations. ... Except the doc page doesn't
mention how to do that, nor does std.algorithm.sort show how to sort a
string. ... and the google results on the
Hi,
I am looking for cross product function in libmir or lubeck. But
I couldn't find it.
Does anyone know if it exists or not?
Erdem
On Friday, 1 May 2020 at 11:31:29 UTC, Erdem wrote:
As can be seen in the link below :
http://mir-algorithm.libmir.org/mir_algorithm_iteration.html
Libmir provides almost the same function as std. Why is benefit
of doing that? Wouldn't it be better to not duplicate std stuff?
Erdem
I
01.05.2020 15:29, Steven Schveighoffer пишет:
Don't do this, use to!(dchar[]) as you have above. This will create
incorrect dchars for non-ascii text.
-Steve
Argh, as always you're right. Funny that I never did that and sadly that
I posted wrong code. Thank you, Steven, for correction of
On Friday, 1 May 2020 at 11:31:29 UTC, Erdem wrote:
As can be seen in the link below :
http://mir-algorithm.libmir.org/mir_algorithm_iteration.html
Libmir provides almost the same function as std. Why is benefit
of doing that? Wouldn't it be better to not duplicate std stuff?
Erdem
Some
As can be seen in the link below :
http://mir-algorithm.libmir.org/mir_algorithm_iteration.html
Libmir provides almost the same function as std. Why is benefit
of doing that? Wouldn't it be better to not duplicate std stuff?
Erdem
On 5/1/20 4:12 AM, drug wrote:
01.05.2020 10:38, Chris Katko пишет:
I'm making anagrams. According to the nextPermutation() docs, I need
to 'sort by less' to get all permutations. ... Except the doc page
doesn't mention how to do that, nor does std.algorithm.sort show how
to sort a string.
01.05.2020 18:04, notna пишет:
hmmm, whích results in:
Error: cannot use [] operator on expression of type dchar
try this:
```D
import std;
void main()
{
string word = "Привет";
dchar[] line3 = to!(dchar[])(word.dup) // make a copy to get a
range of mutable char
On Friday, 1 May 2020 at 15:04:01 UTC, notna wrote:
On Friday, 1 May 2020 at 12:29:26 UTC, Steven Schveighoffer
wrote:
dchar[] line3 = sort(line2.to!(dchar[]));
dchar[] line3 = sort(line2.to!dchar[]).release;
https://dlang.org/phobos/std_range.html#.SortedRange.release
hmmm,
There is a Python eval() equivalent in Dlang working in Runtime?
On Friday, 1 May 2020 at 15:15:29 UTC, bachmeier wrote:
On Friday, 1 May 2020 at 15:04:01 UTC, notna wrote:
On Friday, 1 May 2020 at 12:29:26 UTC, Steven Schveighoffer
wrote:
dchar[] line3 = sort(line2.to!(dchar[]));
dchar[] line3 = sort(line2.to!dchar[]).release;
On Friday, 1 May 2020 at 15:17:53 UTC, drug wrote:
01.05.2020 18:04, notna пишет:
hmmm, whích results in:
Error: cannot use [] operator on expression of type dchar
try this:
```D
import std;
void main()
{
string word = "Привет";
dchar[] line3 = to!(dchar[])(word.dup) // make a
On Friday, 1 May 2020 at 11:29:55 UTC, Erdem wrote:
Hi,
I am looking for cross product function in libmir or lubeck.
But I couldn't find it.
Does anyone know if it exists or not?
Erdem
Hi,
Libmir doesn't provide cross-product function.
Ilya
On Friday, 1 May 2020 at 12:29:26 UTC, Steven Schveighoffer wrote:
dchar[] line3 = sort(line2.to!(dchar[]));
dchar[] line3 = sort(line2.to!dchar[]).release;
https://dlang.org/phobos/std_range.html#.SortedRange.release
hmmm, whích results in:
Error: cannot use [] operator on
I'm looking for a function something like writeln or write, but
instead of writing to stdout, it writes to a string and returns
the string.
So i would like something like:
import std.stdio;
import std.conv;
string write_to_string(T...)(T values ) {
string s;
foreach ( value; values ) s
On Sat, May 02, 2020 at 02:22:42AM +, dan via Digitalmars-d-learn wrote:
> I'm looking for a function something like writeln or write, but instead of
> writing to stdout, it writes to a string and returns the string.
[...]
import std.format : format;
string str = format("%s %s
On Saturday, 2 May 2020 at 02:29:43 UTC, H. S. Teoh wrote:
On Sat, May 02, 2020 at 02:22:42AM +, dan via
Digitalmars-d-learn wrote:
I'm looking for a function something like writeln or write,
but instead of writing to stdout, it writes to a string and
returns the string.
[...]
On Saturday, 2 May 2020 at 02:49:04 UTC, Steven Schveighoffer
wrote:
On 5/1/20 10:40 PM, dan wrote:
On Saturday, 2 May 2020 at 02:29:43 UTC, H. S. Teoh wrote:
On Sat, May 02, 2020 at 02:22:42AM +, dan via
Digitalmars-d-learn wrote:
[...]
[...]
import std.format : format;
string
On 5/1/20 11:17 AM, drug wrote:
01.05.2020 18:04, notna пишет:
hmmm, whích results in:
Error: cannot use [] operator on expression of type dchar
try this:
```D
import std;
void main()
{
string word = "Привет";
dchar[] line3 = to!(dchar[])(word.dup) // make a copy to get a
range
On 5/1/20 10:40 PM, dan wrote:
On Saturday, 2 May 2020 at 02:29:43 UTC, H. S. Teoh wrote:
On Sat, May 02, 2020 at 02:22:42AM +, dan via Digitalmars-d-learn
wrote:
I'm looking for a function something like writeln or write, but
instead of writing to stdout, it writes to a string and returns
On Friday, 1 May 2020 at 15:42:54 UTC, Baby Beaker wrote:
There is a Python eval() equivalent in Dlang working in Runtime?
You might find arsd's script.d interesting [1], but it's more
like a blend between D and javascript.
Is it possible, inside a function template, to create an alias to
the instantiated function? IOW the equivalent of __FUNCTION__,
but yielding an alias?
The closest I came is:
import std.string;
import std.traits;
void foo(T)(lazy T)
{
mixin(
"alias thisFunction = ",
On 5/1/20 4:28 PM, Jean-Louis Leroy wrote:
Something I have overlooked? Any ideas?
This trick works. No idea who came up with it:
alias thisFunction = __traits(parent, {});
-Steve
On Friday, 1 May 2020 at 21:05:17 UTC, Adam D. Ruppe wrote:
On Friday, 1 May 2020 at 20:28:58 UTC, Jean-Louis Leroy wrote:
Something I have overlooked? Any ideas?
There's an old rule, that I can't find in the spec anymore but
I'm still pretty sure it is there, where taking the address of
a
On Fri, May 01, 2020 at 06:37:41PM +, tsbockman via Digitalmars-d-learn
wrote:
> On Friday, 1 May 2020 at 18:07:54 UTC, H. S. Teoh wrote:
[...]
> > Actually, if you're willing to ship a working copy of dmd with your
> > program, you *could* compile D code on-the-fly and dynamically load
> >
On Fri, May 01, 2020 at 05:44:27PM +, tsbockman via Digitalmars-d-learn
wrote:
> On Friday, 1 May 2020 at 15:42:54 UTC, Baby Beaker wrote:
> > There is a Python eval() equivalent in Dlang working in Runtime?
>
> No, and there almost certainly never will be due to fundamental
> differences
On Friday, 1 May 2020 at 18:07:54 UTC, H. S. Teoh wrote:
On Fri, May 01, 2020 at 05:44:27PM +, tsbockman via
Digitalmars-d-learn wrote:
On Friday, 1 May 2020 at 15:42:54 UTC, Baby Beaker wrote:
> There is a Python eval() equivalent in Dlang working in
> Runtime?
No, and there almost
On Friday, 1 May 2020 at 20:43:05 UTC, Steven Schveighoffer wrote:
On 5/1/20 4:28 PM, Jean-Louis Leroy wrote:
Something I have overlooked? Any ideas?
This trick works. No idea who came up with it:
alias thisFunction = __traits(parent, {});
-Steve
I think I get the idea. Alas it doesn't
On Friday, 1 May 2020 at 20:28:58 UTC, Jean-Louis Leroy wrote:
Something I have overlooked? Any ideas?
There's an old rule, that I can't find in the spec anymore but
I'm still pretty sure it is there, where taking the address of a
template inside a template yields the current instantiation.
I saw docs for std.experimental.allocator and also had found
automem library(https://code.dlang.org/packages/automem) for c++
style memory management via smartpointers.
From GC documentation std.experimental.allocator can not be used
for:
NewExpression
Array appending
Array
On Friday, 1 May 2020 at 20:28:58 UTC, Jean-Louis Leroy wrote:
Is it possible, inside a function template, to create an alias
to the instantiated function? IOW the equivalent of
__FUNCTION__, but yielding an alias?
The closest I came is:
import std.string;
import std.traits;
void
On Friday, 1 November 2019 at 08:54:31 UTC, johnsmith101 wrote:
On Wednesday, 30 October 2019 at 19:11:00 UTC, Adam D. Ruppe
wrote:
On Saturday, 26 October 2019 at 19:48:33 UTC, Murilo wrote:
I play a sound the program never ends, the terminal continues
to run the program and I have to end it
On Friday, 1 May 2020 at 15:42:54 UTC, Baby Beaker wrote:
There is a Python eval() equivalent in Dlang working in Runtime?
No, and there almost certainly never will be due to fundamental
differences between the languages. Depending on your goal, the
closest alternatives are using the string
36 matches
Mail list logo