標準入力は以下を使用
const stream = require('fs').readFileSync('/dev/stdin', 'utf8').trim()
// const cols = stream.split(' ')
// const lines = stream.split('\n')
// const matrix = stream.split('\n').map(line => line.split(' '))
const fileSync = file => { | |
const stream = require('fs').readFileSync(file, 'utf8').trim() | |
console.log(stream) | |
return stream | |
} | |
const fileAsync = file => { | |
const callback = (error, data) => data | |
const stream = require('fs').readFile(file, 'utf8', | |
callback |
const fun = array => n => array.map(v => v * n) | |
const array = [1, 2, 3] | |
console.log(JSON.stringify(array.map(v => fun(array)(v)))) |
// 1114.js | |
const arr = [0, 1, 12, 24, 36] | |
const start = 2 | |
const f1 = (arr, start) => { | |
const head = arr.slice(0, 2) | |
const tail = arr.slice(start + 2) | |
return [...head, 16, 25, ...tail] | |
} |
標準入力は以下を使用
const stream = require('fs').readFileSync('/dev/stdin', 'utf8').trim()
// const cols = stream.split(' ')
// const lines = stream.split('\n')
// const matrix = stream.split('\n').map(line => line.split(' '))
入力は以下のテンプレートを使用する
const stream = require('fs').readFileSync('/dev/stdin', 'utf8').trim()
const lines = stream.split('\n')
(() => {
// define function
const createInfo = (start, max) => { | |
const threads = GmailApp.getInboxThreads(start, max) | |
const matrix = threads.map(v => ( | |
[ | |
v.getId(), | |
v.getFirstMessageSubject(), | |
v.getMessageCount() | |
] | |
)) | |
return matrix |
#!/bin/sh | |
VERSION='90' | |
TUTOR_DIR="/usr/share/vim/vim$VERSION/tutor" | |
TUTOR_JA=$(tempfile -p 'ja') | |
TUTOR=$(tempfile -p 'en') | |
chmod +w $TUTOR | |
cp $TUTOR_DIR/tutor.ja.utf-8 $TUTOR_JA | |
cp $TUTOR_DIR/tutor $TUTOR |
import React, { useState, useEffect } from 'react' | |
const ViewForm = ({ text }) => <p>text: {text}</p> | |
const ActionForm = ({ fn }) => { | |
const [inputValue, setInputValue] = useState('') | |
const handleChange = (e) => { | |
setInputValue(e.target.value) | |
} | |
const handleClick = e => fn(inputValue) |