output

Lua: Executing a string and storing the output of the command in a variable

余生长醉 提交于 2019-12-02 10:10:53
问题 I've got a Lua script that receives a function call in a string. I need to execute that call and retrieve the output as a string in a variable so I can later send it somewhere. For example, I will receive the string "json.encode('{1:1, 2:3, 5:8}')" . I'd like to execute it and get a variable with the value ret = json.encode('{1:1, 2:3, 5:8}') . I've tried using loadstring in a bunch of different ways, including a way I found in the docs, but I can't get it to work as I want: > s = "json

`Error: Output is not defined` when passing value outside a directive to parent directive

帅比萌擦擦* 提交于 2019-12-02 09:29:51
I have an root-app component which is defined like this in the template. template: ` <dev-table (complete)="onSelect(developer)"></dev-table> <dev-details [selectedDeveloper]="selectedDeveloper"></dev-details> ` directives: [DevDetailsComponent, DevTableComponent], providers: [DevValueService, provide(DevService, {useClass: DevService})] is a list and on selection of one of the internal list it should send the value of the list (developer) which is passed into as selected developer. @Input is defined right and is taken into correctly. But the @output is giving an error Error: Output is not

Strange output when printing the value 0x89 (-119)

自古美人都是妖i 提交于 2019-12-02 09:28:28
As the title says, I get a "weird" result when running the following code: #include <stdio.h> int main() { char buff[4] = {0x17, 0x89, 0x39, 0x40}; unsigned int* ptr = (unsigned int*)buff; char a = (char)((*ptr << (0*8)) >> (3*8)); char b = (char)((*ptr << (1*8)) >> (3*8)); char c = (char)((*ptr << (2*8)) >> (3*8)); char d = (char)((*ptr << (3*8)) >> (3*8)); printf("0x%x\n", *ptr); printf("0x%x\n", a); printf("0x%x\n", b); printf("0x%x\n", c); printf("0x%x\n", d); return 0; } Output: 0x40398917 0x40 0x39 0xffffff89 0x17 Why am I not getting 0x89 ? It's because your char variables are signed

How to redirect Matlab output of a command to a file? [duplicate]

坚强是说给别人听的谎言 提交于 2019-12-02 09:27:00
问题 This question already has answers here : Print A Matlab Struct to a Text File (3 answers) Closed 5 years ago . I want to redirect or copy the output of a Matlab command to a file. How can I do that? In my case, I have two large structs that I want to compare using the UNIX tool diff . Example: I can do this in Matlab: >> s1 s1 = a: 32 abc: 'example' >> and want a file containing approx: s1 = a: 32 abc: 'example' These solutions are not viable: Copy-pase: can't automate (comfortably). save

Problem with chaining operator<< and operator++

做~自己de王妃 提交于 2019-12-02 08:10:35
问题 I'm learning C++ and I have this problem: #include <iostream> using namespace std; class test { public: test(){}; test(int i):var{i}{}; test& operator++(){++var; return this;} test operator++(int dummy){test tmp =*this;var++;return tmp;} friend ostream& operator<<(ostream&, const test&); private: int var; }; ostream& operator<<(ostream& o, const test& obj) { o<<obj.var; return o; } int main() { test obj{2}; cout << obj << endl; obj++; cout << obj << endl; cout << obj <<' '<< ++obj<<endl;

How to generate binary variable according to the conditions of other variables?

只愿长相守 提交于 2019-12-02 07:52:05
Once again, I apologize for asking this type of question, but the R world is so large that sometime I feel lost, even if I have read some of the best book related with R. I have the following DB ID=rep((1:3),3) x<-as.Date("2013-1-1") y<-as.Date("2013-1-2") z<-as.Date("2013-1-3") DATE<-c(x,x,x,y,x,y,z,z,z) TRAP<-c(1,1,1,3,2,3,2,1,3) IN<-data.frame(ID,DATE,TRAP) and I would like to produce a binary variable (RESULT) according to the following conditions: if the DATE and the TRAP is the same for the different ID, then RESULT>y otherwise RESULT>n, like this RESULT<-c("y","y","y","y","n","y","n","n

Debugging code in C

ε祈祈猫儿з 提交于 2019-12-02 07:43:51
Can someone tell me what is wrong with my code and why it is producing this output. Code: int main(){ unsigned num; char response; do{ printf("Please enter a positive integer greater than 1 and less than 2000: "); scanf("%d", &num); if (num > 1 && num < 2000){ printf("All the prime factors of %d are given below: \n", num); printPrimeFactors(num); printf("\n\nThe distinct prime factors of %d are given below: \n", num); printDistinctPrimeFactors(num); } else{ printf("\nSorry that number does not fall between 1 and 2000.\n"); } printf("\n\nDo you want to try another number? Say Y(es) or N(o): ");

RSA block by block encryption produces blank output for files larger than 1kb

谁说胖子不能爱 提交于 2019-12-02 06:49:42
I'm not opening this thread for AES or other encryptions because this is what I'm going to use to encrypt the keys of AES and other encryptions. I've gathered several codes from StackOverflow and a few other sites and edited it to fit my program however while trying to do a block by block encryption using RSA problem is I can only encrypt small text files of size 1 kilobyte. Encryption and Decryption of text files are working fine. However, encrypting pictures and ANY files larger than 1 kilobyte will produce a blank encrypted file. I would like to ask help if anyone can help me point out

is System.out.printf() statement asynchronous?

。_饼干妹妹 提交于 2019-12-02 06:47:50
问题 I am printing information to test Threads using Reentrant locks. I am creating fair locks using statement new ReentrantLock(true). In one of the object method where I am using lock, I am using method e.g. method() { for (int n = 0; n < 3; n++) { System.out.printf("%s: processing data \n", Thread.currentThread().getName(), data.get()); TimeUnit.SECONDS.sleep(1); } } I am creating 10 threads and all threads should executing same statement 3 times where this console print statement is executed.

Problem with chaining operator<< and operator++

穿精又带淫゛_ 提交于 2019-12-02 06:19:39
I'm learning C++ and I have this problem: #include <iostream> using namespace std; class test { public: test(){}; test(int i):var{i}{}; test& operator++(){++var; return this;} test operator++(int dummy){test tmp =*this;var++;return tmp;} friend ostream& operator<<(ostream&, const test&); private: int var; }; ostream& operator<<(ostream& o, const test& obj) { o<<obj.var; return o; } int main() { test obj{2}; cout << obj << endl; obj++; cout << obj << endl; cout << obj <<' '<< ++obj<<endl; return 0; } the output i expected was: 2 3 3 4 instead i have: 2 3 4 4 if i replace the last increment +