let

I need help converting between the let form and unnamed procedure form

|▌冷眼眸甩不掉的悲伤 提交于 2020-02-05 04:54:58
问题 im trying to convert from a let-form to an unamed procedure form and i just can't get the hang of it. the let procedure is this. (define max-recursive (lambda (lst) (if (null? (cdr lst)) (car lst) (let ((m0 (car lst)) (m1 (max-recursive (cdr lst)))) (if (> m0 m1) m0 m1 ) ) ))) and what i've done so far is this (define max-recursive (lambda (lst) (if (null? (cdr lst)) (car lst) ((lambda (m0 m1) (if (> m0 m1) m0 m1 ) ) car lst (max-recursive (cdr lst))) ))) any help would be appreciated thank

(self self) call inside the let statement, in strict language

十年热恋 提交于 2020-01-25 00:48:11
问题 I am currently, going through this article on Y-combinator by Mike Vanier. Along the way of Y-combinator derivation, this code: (define (part-factorial self) (lambda (n) (if (= n 0) 1 (* n ((self self) (- n 1)))))) ((part-factorial part-factorial) 5) ==> 120 (define factorial (part-factorial part-factorial)) (factorial 5) ==> 120 is worked out to: (define (part-factorial self) (let ((f (self self))) (lambda (n) (if (= n 0) 1 (* n (f (- n 1))))))) (define factorial (part-factorial part

How to use let declarations as expressions?

霸气de小男生 提交于 2020-01-17 07:21:41
问题 I want to use let expressions, but the following code doesn't work: true ? (let x=1, let y=2, x+y) : (let x=3, let y=4, x-y); // SyntaxError How am I supposed to do this? 回答1: Unfortunately, Javascript lacks lisp-style let expressions. However, since there are default parameters and arrow functions we can mimic them: const let_ = f => f(); console.log( true ? let_((x = 1, y = 2) => x + y) : let_((x = 3, y = 4) => x - y) // 3 ); To be honest, this is a bit tedious and the code is pretty

keyword - FFL: Where vs. Let

徘徊边缘 提交于 2020-01-15 06:37:10
问题 I was trying to understand the following code: def() ->commands if(deferred_passive_abilities != [], let [{ability: class passive_ability, creature: class creature}] items = []; let found = false; map(deferred_passive_abilities, if(cmd = null, add(items, [value]), [cmd, set(found, true)]) where cmd = value.ability.static_effect(me, value.creature)); if(found, set(deferred_passive_abilities, items); evaluate_deferred_passive_abilities(), set(deferred_passive_abilities, [])) ) Haskell appears

Why won't `let` work for naming internal recursive procedures?

Deadly 提交于 2020-01-14 14:16:27
问题 Consider the following implementation of a function to compute factorial: [1] (define fac-tail (lambda (n) (define fac-tail-helper (lambda (n ac) (if (= 0 n) ac (fac-tail-helper (- n 1) (* n ac))))) (fac-tail-helper n 1))) I attempted to rewrite using let for the inner define: (define fac-tail-2 (lambda (n) (let ((fac-tail-helper-2 (lambda (n ac) (if (= 0 n) ac (fac-tail-helper-2 (- n 1) (* n ac)))))) (fac-tail-helper-2 n 1)))) There is no error at define time, but execution results in: #;>

Nested LINQ Method throwing a `Not Supported…` Exception

落爺英雄遲暮 提交于 2020-01-04 06:47:05
问题 This is a follow up from here -->multiple-sorting-on-linq-nested-method . Basically, on let memberName = ... it is throwing this exception Method 'System.String MemberName(Int32)' has no supported translation to SQL. and I am not figuring out the solution. Also, BLLCmo and BLLConnect actually use TWO different DataBases . The original app(not mine) uses 4 Seperate DB's so I am trying to make due. BLLCmo.cs public static DataTable GetAllMembers(Guid workerID) { var AllEnrollees = from

Nested LINQ Method throwing a `Not Supported…` Exception

时光总嘲笑我的痴心妄想 提交于 2020-01-04 06:45:27
问题 This is a follow up from here -->multiple-sorting-on-linq-nested-method . Basically, on let memberName = ... it is throwing this exception Method 'System.String MemberName(Int32)' has no supported translation to SQL. and I am not figuring out the solution. Also, BLLCmo and BLLConnect actually use TWO different DataBases . The original app(not mine) uses 4 Seperate DB's so I am trying to make due. BLLCmo.cs public static DataTable GetAllMembers(Guid workerID) { var AllEnrollees = from

Swift - Lazy Var vs. Let when creating views programmatically (saving memory)

廉价感情. 提交于 2020-01-02 02:14:28
问题 I'm a beginner and I sort of understand Lazy Var vs. Let. I've noticed that it saves a ton of memory usage when using Lazy Var especially with ImageViews. But the tutorials and guides I've seen so far don't use Lazy Var very often, so I'm feeling suspicious that it is bad practice and that I'm overlooking something. I did a little research and learned that Lazy isn't "thread safe," but I don't understand what this means. I've seen a lot of pros and cons, but I can't draw any conclusions

Chrome console: difference between 'let' and 'var'?

ⅰ亾dé卋堺 提交于 2020-01-01 09:42:11
问题 I've attached an animated gif to illustrate this weird behavior. Essentially, my question is does Chrome console treat var and let differently when used in the same scope? You'll notice that after declaring / assigning a variable, if you try to type that variable's name into the console, Chrome will autocomplete it for you, showing a dropdown list containing what your typing. When using let s, this is not the case. Is this a bug, feature, or is there something I'm missing about var and let in

Is there a Python equivalent of the Haskell 'let'

僤鯓⒐⒋嵵緔 提交于 2019-12-30 02:42:06
问题 Is there a Python equivalent of the Haskell 'let' expression that would allow me to write something like: list2 = [let (name,size)=lookup(productId) in (barcode(productId),metric(size)) for productId in list] If not, what would be the most readable alternative? Added for clarification of the let syntax: x = let (name,size)=lookup(productId) in (barcode(productId),metric(size)) is equivalent to (name,size) = lookup(productId) x = (barcode(productId),metric(size)) The second version doesn't