syntax

awk embedded script issue (unexpected character '\')

时光总嘲笑我的痴心妄想 提交于 2020-01-15 13:02:16
问题 I use an embedded awk code in a shell script: I have some variable assignments at the BEGIN part of it: \ BEGIN { FS=","; OFS=","; service_not="false"; end_of_line="\n"; is_setup_gps="false"; \ \ a=6378137.0 ; \ b=6356752.3142 ; \ f=(a-b)/a ; \ e=sqrt(f*(2-f)) ; \ } \ \ So I need '\' at the end of each line (to have an entire awk script embedded in .sh). BUT: for the lines: a=...; b=...; f=...; the '\' causing errors...: mawk: 57: unexpected character '\' Why? UPD: Embedding of awk in the

What is the difference node *node1 vs node* node1? [duplicate]

血红的双手。 提交于 2020-01-15 11:15:10
问题 This question already has answers here : Placement of the asterisk in pointer declarations (13 answers) Closed 2 years ago . I have 1 node: struct node { int key; struct node *left, *right; }; What is the difference between node *node1 vs node* node1 ? 回答1: Without a typedef , both the declarations are illegal. With a typedef like typedef struct node node; in place, there's no difference. Both the statements declare a variable node1 of type pointer to node . ( Note: You'll still be needing

Method call with assignment syntax

房东的猫 提交于 2020-01-15 09:13:56
问题 Recently I have encountered the following code: var l = List("a") l :+= "b" The second line, quite intuitively (similar to += increment), gets compiled to a method call and assignment: l = l :+ "b" As I can see, it is not limited to library classes. For example, this compiles: trait CustomList[+A] { def :+[B >: A](item: B): CustomList[B] } var a: CustomList[String] = ... a :+= "a" But it is obviously limited to only symbolic method names: trait CustomList[+A] { def add[B >: A](item: B):

Method call with assignment syntax

一笑奈何 提交于 2020-01-15 09:13:00
问题 Recently I have encountered the following code: var l = List("a") l :+= "b" The second line, quite intuitively (similar to += increment), gets compiled to a method call and assignment: l = l :+ "b" As I can see, it is not limited to library classes. For example, this compiles: trait CustomList[+A] { def :+[B >: A](item: B): CustomList[B] } var a: CustomList[String] = ... a :+= "a" But it is obviously limited to only symbolic method names: trait CustomList[+A] { def add[B >: A](item: B):

Strange constructor

*爱你&永不变心* 提交于 2020-01-15 05:06:40
问题 Well, I'm gonna be pretty straightforward here, I just have a piece of code in c++ which I'm not sure I really understand and need some help with. Ok, to simplify lets just say I have a class that is defined like this: (the real class is a little bit more complicated, but this is what matters) class myClass : public Runnable { Semaphore *m_pMySemaphore; __Queue<Requests> *m_pQueue; Request m_Request; VetorSlotBuffer *m_vetorSlotBuffer; } Up to here nothing is wrong, myClass is just a regular

How ought I run the annotate function in gui-debugger/annotator on a datum?

China☆狼群 提交于 2020-01-15 03:08:19
问题 I am trying to learn how to use the DrRacket debugger's annotate function. My ultimate aim is to build a REPL that you can execute from within a closure and have access to everything that's in scope. (see my previous question on that topic and Greg Hendershott's well-researched answer) For the time being, I'm just trying to explore how the annotate function works. You can see my first exploratory attempt at using it, and the results, here. The error, which is happing inside of the annotator,

Are there any essential reasons to use isset() over @ in php

柔情痞子 提交于 2020-01-14 14:47:22
问题 So I'm working on cleanup of a horrible codebase, and I'm slowly moving to full error reporting. It's an arduous process, with hundreds of notices along the lines of: Notice: Undefined index: incoming in /path/to/code/somescript.php on line 18 due to uses of variables assuming undefined variables will just process as false, like: if($_SESSION['incoming']){ // do something } The goal is to be able to know when a incorrectly undefined variable introduced, the ability to use strict error/notice

Determine whether a string contains valid javascript code

依然范特西╮ 提交于 2020-01-14 13:27:19
问题 I'm looking for a C# function which returns true if a string contains valid javascript syntax. For instance: IsValidJavascript("alert('hello');"); would return true , but IsValidJavascript("alertXXhelloZ);"); would return false . 回答1: You'll need to use an interpreter . You can try Jint which is a Javascript interpreter for .NET . 来源: https://stackoverflow.com/questions/14135783/determine-whether-a-string-contains-valid-javascript-code

What determines if a JavaScript function is a named anonymous function versus a, um, regular function?

霸气de小男生 提交于 2020-01-14 13:25:28
问题 Reading "A re-introduction to JavaScript" I noticed something interesting about functions: The name provided to an anonymous function as above is(or at least should be) only available to the function's own scope. Entering some things based on the code in the tutorial at the nodejs prompt I was able to verify that node agrees with the author: function add(foo, bar) { return foo + bar; } add(1, 2); gets me 3, and: var five = (function plus(foo, bar) { return foo + bar; })(2, 3); plus(2, 3);

What determines if a JavaScript function is a named anonymous function versus a, um, regular function?

半腔热情 提交于 2020-01-14 13:24:31
问题 Reading "A re-introduction to JavaScript" I noticed something interesting about functions: The name provided to an anonymous function as above is(or at least should be) only available to the function's own scope. Entering some things based on the code in the tutorial at the nodejs prompt I was able to verify that node agrees with the author: function add(foo, bar) { return foo + bar; } add(1, 2); gets me 3, and: var five = (function plus(foo, bar) { return foo + bar; })(2, 3); plus(2, 3);