let

Lisp DO variable syntax reasoning

In Peter Seibel's Practical Common Lisp, he gives this example: (do ((nums nil) (i 1 (1+ i))) ((> i 10) (nreverse nums)) (push i nums)) I can see how it works, using nums inside the loop but not giving it a step-form. Why would you put nums in the variable-definition rather than do this: (let (nums) (do ((i 1 (+ i 1))) ...

Avoid expansion of * in bash builtin function let

Hi all, I have a problem with a bash script. I have to use the operator * to multiplicate. Instead the script bugs me with expansion and using as operator the name of the script itself. I tried with single quotes but it doesn't work :( Here's the code #!/bin/bash -x # Bash script that calculates an arithmetic expression # NO PRECEDENCE...

let vs def in clojure

I want to make a local instance of a Java Scanner class in a clojure program. Why does this not work: ;gives me: count not supported on this type: Symbol (let s (new Scanner "a b c")) but it will let me create a global instance like this: (def s (new Scanner "a b c")) I was under the impression that the only difference was scope...

Semantics of F# let statement with comma

I'm learning F#. I started by looking over the F# samples from Microsoft. I ran across this statement: let line1,line2 = use sr = System.IO.File.OpenText @"test.txt" let line1 = sr.ReadLine() let line2 = sr.ReadLine() (line1,line2) Can anyone explain this statement to me? What type is being defined here? A functio...

Redefining a let'd variable in Clojure loop

OK. I've been tinkering with Clojure and I continually run into the same problem. Let's take this little fragment of code: (let [x 128] (while (> x 1) (do (println x) (def x (/ x 2))))) Now I expect this to print out a sequence starting with 128 as so: 128 64 32 16 8 4 2 Instead, it's an infinite loop, printing 12...

Binding multiple related variables in Clojure without nested let

I want to use the value of a variable to compute the value of another variable in the same let statement. Is there a way to do this in Clojure without using nested lets? Nested let solution: (let [x 3] (let [y (+ 1 x)] y)) = 4 Desired solution: (let [x 3 y (+ 1 x)] y) = 4 ...

Let vs. Binding in Clojure

I understand that they're different since one works for setting *compile-path* and one doesn't. However, I need help with why they're different. let creates a new scope with the given bindings, but binding...? Thanks! ...

Nested LINQ Method throwing a `Not Supported...` Exception

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 ...

Lisp simple question

Hi! I have some not understanding actions from gnu clisp Suppose, I have some code like (let ((x "Hi!"))(print x)). If I execute it from console (like, clisp fileName.lisp) I see Hi! But, when I execute it from interpreter, I see this text twice. Why? Help me, please. ...

Confused by "let" in Clojure

I just started playing with Clojure, and I wrote a small script to help me understand some of the functions. It begins like this: (def *exprs-to-test* [ "(filter #(< % 3) '(1 2 3 4 3 2 1))" "(remove #(< % 3) '(1 2 3 4 3 2 1))" "(distinct '(1 2 3 4 3 2 1))" ]) Then it goes through *exprs-to-test*, evaluates them all, and ...

What's the point of lambda in scheme?

I am learning scheme. I know how to use both lambda and let expressions. However I'm struggling to figure out what the point is of using lambda. Can't you do everything with let that you can with lambda? It would be especially helpful to see an example of a situation where a lambda expression is a better choice than let. One other thi...

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

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 f...

linq2sql: how to modify not-mapped entity member in query?

How to modidy entity in query? I have code like this: var res = from p in dc.Folders group p by p.FolderId into gr let DDate = gr.Where(a =>a.status ==5).Max(g=>g.MDate) from c in gr select c; Folder class has extra member not mapped to db called DDDate, just for example. How I can set this memb...

Why does let require a vector?

I never really thought about this until I was explaining some clojure code to a coworker who wasn't familiar with clojure. I was explaining let to him when he asked why you use a vector to declare the bindings rather than a list. I didn't really have an answer for him. But the language does restrict you from using lists: => (let (x 1...