In C, why can’t I assign a string to a char array after it’s declared?

Arrays are second-class citizens in C, they do not support assignment. char x[] = “This is initialization, not assignment, thus ok.”; This does not work: x = “Compilation-error here, tried to assign to an array.”; Use library-functions or manually copy every element for itself: #include <string.h> strcpy(x, “The library-solution to string-assignment.”);

setq and defvar in Lisp

There are several ways to introduce variables. DEFVAR and DEFPARAMETER introduce global dynamic variables. DEFVAR optionally sets it to some value, unless it is already defined. DEFPARAMETER sets it always to the provided value. SETQ does not introduce a variable. (defparameter *number-of-processes* 10) (defvar *world* (make-world)) ; the world is made only once. Notice that … Read more

Assign multiple new variables on LHS in a single line

There is a great answer on the Struggling Through Problems Blog This is taken from there, with very minor modifications. USING THE FOLLOWING THREE FUNCTIONS (Plus one for allowing for lists of different sizes) # Generic form ‘%=%’ = function(l, r, …) UseMethod(‘%=%’) # Binary Operator ‘%=%.lbunch’ = function(l, r, …) { Envir = as.environment(-1) … Read more