Re: lambda recursion
On 11/27/20 9:01 AM, ddcovery wrote: On Friday, 27 November 2020 at 16:40:43 UTC, ddcovery wrote: ... * Can the lambda be transformed to a template (using T instead "int") but avoiding function/return syntax? This is an example using function template qs(T){ T[] qs( T[] items ){ return items.length==0 ? items : chain( qs(items[1..$].filter!(i=> i i >= items[0]).array) ).array; } } I mean... transform this into a lambda expression: T[] qs(T)( T[] items ){ return items.length==0 ? items : chain( qs(items[1..$].filter!(i=> i i >= items[0]).array) ).array; } This has been done with the Y-combinator, where the lambda refers to itself as 'self': https://github.com/gecko0307/atrium/blob/master/dlib/functional/combinators.d There has been been other discussions on it on these forums. Ali
Re: How to unit-test a phobos module?
On Friday, 27 November 2020 at 04:08:33 UTC, Q. Schroll wrote: On Thursday, 26 November 2020 at 05:29:16 UTC, Mike Parker wrote: Tomorrow, I'll try setting up a dual boot and give it a shot there. (Not the dub experience but following https://wiki.dlang.org/Building_under_Posix) Have you heard about WSL...WSL2? You don't need dual boot anymore. Read https://docs.microsoft.com/en-us/windows/wsl/about
Re: Automatic update system
On Friday, 27 November 2020 at 20:00:22 UTC, aberba wrote: On Thursday, 26 November 2020 at 12:13:59 UTC, vnr wrote: On Linux, both Flatpak and Snap all provide suck functionality. Such* was what I meant . On Flatpak, it's not really a pure auto-update...but users get to up update from the store. Cus some folks are skeptical about auto-updates. 1. https://docs.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-packaging-dot-net#:~:text=%20Setup%20the%20Windows%20Application%20Packaging%20Project%20in,make%20sure%20to%20set%20the%20Minimum...%20More%20
Re: Automatic update system
On Thursday, 26 November 2020 at 12:13:59 UTC, vnr wrote: Hello, I have a program written in D which is open-source on GitHub. I would appreciate it if, when I release a new version, users would be notified by the program and that it offers an automatic update, i.e. the user doesn't have to reinstall the whole repository himself, but that it is updated automatically. I haven't found any packages that directly meet my needs, but in the meantime I imagine that I will have to use the GitHub API, as well as Curl to make such a system. Do you have any resources or suggestions as to how I could implement this? Thank you! Auto-updates of an installed app (.ie. if that's what you want) is done from the app's installation side of things... App Store (with a few exceptions of course). On Windows, Microsoft's new packaging stack supports that [1]. You can even set it up with your CI/CD pipelines...e.g. GitHub Actions. On Linux, both Flatpak and Snap all provide suck functionality. 1. https://docs.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-packaging-dot-net#:~:text=%20Setup%20the%20Windows%20Application%20Packaging%20Project%20in,make%20sure%20to%20set%20the%20Minimum...%20More%20
Re: Questions about D
On 11/27/20 2:56 PM, Walter wrote: On Friday, 27 November 2020 at 19:46:52 UTC, Ola Fosheim Grostad wrote: Why not? What are you looking for? I'm looking for a general purpose which I can use everywhere Depends on how you define "everywhere". If you mean can it be used in all manner of purposes, yes, it can. It is used in video games, in web development, in command line tools, high performance computing, server software, etc. If you mean can it be used on all the platforms you want to use, it depends on the platform. In general, if gcc or llvm supports your platform, you can probably get it to work. Some platforms are not as mature in D as others, or may require more effort. So it's hard to definitively answer your question. -Steve
Re: Questions about D
On Friday, 27 November 2020 at 19:56:38 UTC, Walter wrote: On Friday, 27 November 2020 at 19:46:52 UTC, Ola Fosheim Grostad wrote: Why not? What are you looking for? I'm looking for a general purpose which I can use everywhere It is fairly general, but I don't think it is the best option for targeting 16 bit or 8 bit cpus. In that case C would probably be better.
Re: Questions about D
On Friday, 27 November 2020 at 19:46:52 UTC, Ola Fosheim Grostad wrote: Why not? What are you looking for? I'm looking for a general purpose which I can use everywhere
Re: Questions about D
On Friday, 27 November 2020 at 19:34:41 UTC, Walter wrote: Hi, I have some questions to ask regarding D: 1) Should I learn D ? Why not? What are you looking for? 2) Can I cross-compile D programs? You should be able to with ldc/gdc if you have some experience. 3) Is it a low-level language? Lower than high, higher than low. It is if you want it to be. 4) Which type of applications is D most used in? Good question. I would assume command line applications, batch. Like C++. 5) Is it fast and not bloated with useless features? It is fast, but I think you'll find one or two useless features if you go looking for it.
Questions about D
Hi, I have some questions to ask regarding D: 1) Should I learn D ? 2) Can I cross-compile D programs? 3) Is it a low-level language? 4) Which type of applications is D most used in? 5) Is it fast and not bloated with useless features?
Re: vibe.d and my first web service
On 8/12/20 9:46 AM, James Blachly wrote: On 7/18/20 8:16 AM, Andre Pany wrote: On Saturday, 18 July 2020 at 09:10:04 UTC, Mr. Backup wrote: >> ... I started the program with "dub" command and everything worked as I expected. Except that there were a lot "deprecation" warnings and long time to compile.But when I exit the service by ctrl + c and start again the program cannot start again with error message: ... I assume you are using vibe.d 0.8.4 or older. Please check whether adding this to dub.json solves your problem: "versions": [ "VibeHighEventPriority" ] (Restart your pc) Vibe.d 0.9 0 will be released soon. I hope it will work out of the box there. Unfortunately the problem still occurs with Vibe.d 0.9.0 IMO **this is the single most important problem to fix** for vibe.d -- if the most basic of examples (indeed, supplied by dub itself) fails so spectacularly, the casual new user will not spend the time to find out why this is happening, but instead move on. The ctrl-C non-termination bug has existed since at least 2015 from what I can tell from the forums. Tangent: Does Sönke have a Patreon or the project an OpenCollective etc. ? I would be willing to support fixing of some of these bugs. Alternatively, could we vote on whether a web framework is worthy of foundation support? Having an ergonomic, workable web framework is absolutely essential to surviving as a language in 2020 (notable exception being 800# gorilla incumbents C/C++). FYI, this bug was just fixed (eventcore version 0.9.11). I tested it and it works. Thanks Sönke for fixing this! -Steve https://github.com/vibe-d/vibe-core/issues/205
Re: lambda recursion
On Friday, 27 November 2020 at 16:40:43 UTC, ddcovery wrote: ... * Can the lambda be transformed to a template (using T instead "int") but avoiding function/return syntax? This is an example using function template qs(T){ T[] qs( T[] items ){ return items.length==0 ? items : chain( qs(items[1..$].filter!(i=> i i >= items[0]).array) ).array; } } I mean... transform this into a lambda expression: T[] qs(T)( T[] items ){ return items.length==0 ? items : chain( qs(items[1..$].filter!(i=> i i >= items[0]).array) ).array; }
lambda recursion
I want to express in D the known Haskell qsort 3 lines code (it is not a quick sort, but an example of how functional programming is expressive). This is the "javascript" version I use as reference: const sorted = ( [pivot, …others] ) => pivot===void 0 ? [ ] : [ … sorted( others.filter( n=> n n>=pivot ) ) ]; This is a possible D implementation: void main() { import std.stdio, std.algorithm, std.range; int[] delegate(int[]) qs; qs = (int[] items) => items.length==0 ? items : chain( qs(items[1..$].filter!(i=> i i >= items[0]).array) ).array; auto result = qs([10,9,5,4,8,7,-20]); assert( result.equal([-20,4,5,7,8,9,10]) ); writeln("Result:", result ); } First problem I found is "qs" must be splitted in 2 expressions: declaration and assignation, because declaration is not "effective" until all expression is compiled (compiler says qs doesn't exist when compiling the lambda body) . * Is there any way to reduce the code(using lambdas) to one expression only? int[] delegate(int[]) qs = (int[] items) => items.length==0 . Or better auto qs = (int[] items) => items.length==0 ? ... * Can the lambda be transformed to a template (using T instead "int") but avoiding function/return syntax? This is an example using function template qs(T){ T[] qs( T[] items ){ return items.length==0 ? items : chain( qs(items[1..$].filter!(i=> i i >= items[0]).array) ).array; } } * I'm trying to use "ranges" to avoid the "array" conversion. Do you figure out a way to express the lambda params and return as a Range to avoid converting to array?
Re: How to unit-test a phobos module?
On Friday, 27 November 2020 at 04:08:33 UTC, Q. Schroll wrote: I think using digger in principle works and I assume the problems I got aren't Digger's fault, but ae's. Building DMD + DRuntime failed. Sorry about this. It was caused by a breaking change in Druntime's build script: https://github.com/dlang/druntime/pull/3026 I pushed a new version of Digger which includes a fix.