let

Can I Transpile for ES6-ES5 without npm, VS, Node, etc. and just the JS code itself somehow?

放肆的年华 提交于 2019-12-03 16:27:44
I am trying to get Firefox to run a Promise in ES6 but run into the 'let' keyword triggering an error; SyntaxError: let is a reserved identifier Changing the script tag to include; type="application/javascript;version=1.7" did not work, so I am seeking to Transpile the code. My situation is that there is nothing being used except a text editor. No NPM, not Node or Angular, no Visual Studio, nothing. So when I investigated the Compilers, I saw no option to let me Transpile this code without any of these other tools/editors/etc. Is there an option where I do not have to learn, use, install,

Redefining a let'd variable in Clojure loop

人走茶凉 提交于 2019-12-03 05:30:24
问题 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 128 over and over. Clearly my intended side effect isn't working. So how am I supposed to redefine the value of x in a loop like this? I realize this may not be Lisp like (I could use

Redefining a let'd variable in Clojure loop

痞子三分冷 提交于 2019-12-02 18:47:50
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 128 over and over. Clearly my intended side effect isn't working. So how am I supposed to redefine the value of x in a loop like this? I realize this may not be Lisp like (I could use an anonymous function that recurses on it's self, perhaps), but if I don't figure out how to set

Haskell: let statement, copy data type to itself with/without modification not working

我与影子孤独终老i 提交于 2019-12-01 12:19:53
I want to update a record syntax with a change in one field so i did something like: let rec = rec{field = 1} But I've noticed that i can't print rec anymore, means the compiler seems to get into an infinite loop when i try. so i have tried doing: let a = 1 -- prints OK let a = a -- now i can't print a (also stuck in a loop) So i can't do let a = a with any type, but i don't understand why, and how should i resolve this issue. BTW: while doing: let b = a {...record changes..} let a = b works, but seems redundant. The issue you're running into is that all let and where bindings in Haskell are

Is there a better way of coping with Swift's nested “if let” “pyramid of doom?”

一曲冷凌霜 提交于 2019-12-01 06:04:13
Is there a better way of dealing with a chain of optional properties than nested if let statements? I have been advised to use if lets when examining optional properties, which makes sense as it deals with them at compile time rather than run time, but it looks like utter madness! Is there is a better way? Here is the current "pyramid of doom" I have ended up with, as an example: ( users: [ JSONValue ]? ) in if let jsonValue: JSONValue = users?[ 0 ] { if let json: Dictionary< String, JSONValue > = jsonValue.object { if let userIDValue: JSONValue = json[ "id" ] { let userID: String = String(

Is there a better way of coping with Swift's nested “if let” “pyramid of doom?”

北城余情 提交于 2019-12-01 03:26:10
问题 Is there a better way of dealing with a chain of optional properties than nested if let statements? I have been advised to use if lets when examining optional properties, which makes sense as it deals with them at compile time rather than run time, but it looks like utter madness! Is there is a better way? Here is the current "pyramid of doom" I have ended up with, as an example: ( users: [ JSONValue ]? ) in if let jsonValue: JSONValue = users?[ 0 ] { if let json: Dictionary< String,

Use if else to declare a `let` or `const` to use after the if/else?

我怕爱的太早我们不能终老 提交于 2019-12-01 02:08:52
I'm not sure why but it seems that I can't call the let or const variables if I declare them in an if/else statement. if (withBorder) { const classes = `${styles.circularBorder} ${styles.dimensions} ${styles.circularPadding} row flex-items-xs-middle flex-items-xs-center`; } else { const classes = `${styles.dimensions} ${styles.circularPadding} row flex-items-xs-middle flex-items-xs-center`; } return ( <div className={classes}> {renderedResult} </div> ); If I use this code it says that classes is not defined . But if I change the const to var classes is defined but I get a warning about classes

Why are parentheses needed on this F# function?

[亡魂溺海] 提交于 2019-11-30 20:08:06
Why are parentheses needed on read_rest_of_csv below? let read_rest_of_csv() = csv_data.Add(csv_fileH.ReadFields()) |> ignore not csv_fileH.EndOfData while read_rest_of_csv() do ignore None Without the parentheses, the loop will not terminate. open System open System.Threading open System.Collections.Generic open System.Linq open System.Text open System.Threading.Tasks open System.IO open Microsoft.VisualBasic.FileIO [<EntryPoint>] let main argv = let csv_fileH = new TextFieldParser("test1.csv") csv_fileH.TextFieldType = FieldType.Delimited |> ignore let x = csv_fileH.SetDelimiters(",") let

Using a `let` binding to increase a values lifetime

给你一囗甜甜゛ 提交于 2019-11-30 18:36:46
I wrote the following code to read an array of integers from stdin : use std::io::{self, BufRead}; fn main() { let stdin = io::stdin(); for line in stdin.lock().lines() { let xs: Vec<i32> = line.unwrap() .trim() .split(' ') .map(|s| s.parse().unwrap()) .collect(); println!("{:?}", xs); } } This worked fine, however, I felt the let xs line was a bit long, so I split it into two: use std::io::{self, BufRead}; fn main() { let stdin = io::stdin(); for line in stdin.lock().lines() { let ss = line.unwrap().trim().split(' '); let xs: Vec<i32> = ss.map(|s| s.parse().unwrap()).collect(); println!("{:?}

Is there a Python equivalent of the Haskell 'let'

Deadly 提交于 2019-11-30 11:17:24
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 work that well with list comprehensions, though. huon You could use a temporary list comprehension [