digitalmars.D.learn - function with is own lamda expression
- bioinfornatics (10/10) Nov 30 2013 I write a function with Lambda expression + safe + pure wich do
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (14/23) Dec 01 2013 The obvious problem in the code is the fact that although the intent and...
- bioinfornatics (3/34) Dec 01 2013 Thanks Ali,
I write a function with Lambda expression + safe + pure wich do same (close) as countUntil http://www.dpaste.dzfl.pl/63d03540 but i fail to use lambda expression into my function. I try by two way - alias this pred … (to get a default lambda) - function(…) pred both way i fail, could you take a look to code please. Goal is to get a pure and safe function thanks
Nov 30 2013
On 11/30/2013 05:53 PM, bioinfornatics wrote:I write a function with Lambda expression + safe + pure wich do same (close) as countUntil http://www.dpaste.dzfl.pl/63d03540 but i fail to use lambda expression into my function. I try by two way - alias this pred … (to get a default lambda) - function(…) pred both way i fail, could you take a look to code please. Goal is to get a pure and safe function thanksThe obvious problem in the code is the fact that although the intent and the lambda expression itself is written to take two parameters, the lambda is called without any arguments: 1) The default lambda takes two parameters: auto search( alias pred = (a,b) => a == b, R,T,S=T)( const ref R toSearch, in T toMatch ) pure 2) and the provided lambda takes two parameters: assert( arrStruct.search!( (a,b) => a.id == b )( 8uL ) == 7 ); 3) However, the call itself takes no arguments: if( pred() ){ So, I would start with that call to debug and pass the two arguments that are appropriate (toSearch.front and toMatch, perhaps?) Ali
Dec 01 2013
On Sunday, 1 December 2013 at 08:22:41 UTC, Ali Çehreli wrote:On 11/30/2013 05:53 PM, bioinfornatics wrote:Thanks Ali, that works now, i was close. http://www.dpaste.dzfl.pl/63d03540I write a function with Lambda expression + safe + pure wichdo same(close) as countUntil http://www.dpaste.dzfl.pl/63d03540 but i fail to use lambda expression into my function. I tryby two way- alias this pred … (to get a default lambda) - function(…) pred both way i fail, could you take a look to code please. Goal is to get a pure and safe function thanksThe obvious problem in the code is the fact that although the intent and the lambda expression itself is written to take two parameters, the lambda is called without any arguments: 1) The default lambda takes two parameters: auto search( alias pred = (a,b) => a == b, R,T,S=T)( const ref R toSearch, in T toMatch ) pure 2) and the provided lambda takes two parameters: assert( arrStruct.search!( (a,b) => a.id == b )( 8uL ) == 7 ); 3) However, the call itself takes no arguments: if( pred() ){ So, I would start with that call to debug and pass the two arguments that are appropriate (toSearch.front and toMatch, perhaps?) Ali
Dec 01 2013