function parseINI(string) {
  // Start with an object to hold the top-level fields
  let result = {};
  let section = result;
  string.split(/\r?\n/).forEach(line => {
    let match;
    if (match = line.match(/^(\w+)=(.*)$/)) {
      section[match[1]] = match[2];
    } else if (match = line.match(/^\[(.*)\]$/)) {
      section = result[match[1]] = {};
    } else if (!/^\s*(;.*)?$/.test(line)) {
      throw new Error("Line '" + line + "' is not valid.");
    }
  });
  return result;
}

console.log(parseINI(`
name=Vasilis
[address]
city=Tessaloniki`));

(https://eloquentjavascript.net/code/#9)

//Abstracting array traversal
function forEach ( array , action ) {
for ( var i = 0; i < array . length ; i ++)
action ( array [ i ]) ;
}
forEach ([" Wampeter " , " Foma " , " Granfalloon "] , console . log ) ;

see, function repeat

https://eloquentjavascript.net/05_higher_order.html


function multiplier(factor) {
  return number => number * factor;
}

let twice = multiplier(2);
console.log(twice(5));
// → 10

https://eloquentjavascript.net/03_functions.html




from math import ceil

def chunk(lst, size):
  return list(
    map(lambda x: lst[x * size:x * size + size],
      list(range(0, ceil(len(lst) / size)))))
#chunk([1, 2, 3, 4, 5], 2) # [[1,2],[3,4],[5]]
print (chunk([1, 2, 3, 4, 5], 2)) # [[1,2],[3,4],[5]]

(https://www.30secondsofcode.org/python/s/chunk)


sas, macro

카테고리 없음 2020. 8. 26. 14:28

 https://support.sas.com/documentation/onlinedoc/91pdf/sasdoc_91/base_macro_6997.pdf
 https://wikidocs.net/32176


postgres=# CREATE USER wikijs WITH PASSWORD 'wikijsrocks';
CREATE ROLE
postgres=# CREATE DATABASE  wiki OWNER wikijs;
CREATE DATABASE