コンピュータ計算のベースになっているのは論理演算,基本的な論理演算と関数型のプログラミングの考え方を知る。
入力がなんであれ,常に False を出力する(恒偽)
| # 1 ビット変換関数 | |
| to_bit = lambda c: '1' if c.isupper() else '0' | |
| apply = lambda fun, text : map(fun, text) | |
| to_matrix = lambda array: [array[i: i+ 8] for i in range(0, len(array), 8)] | |
| to_byte = lambda matrix: [''.join(array) for array in matrix] | |
| to_char = lambda byte: chr(int(byte, 2)) | |
| result = apply(to_char, ) | |
| text = 'tIvolFLgqDzvIUnifAwfnenAtJskbNBMpAAEIxUXpeFPJbnepKPWBcmBkAIzGAShjJdxkoynfXBDehUtiDVTLjeFaUnRQJCEjREfNWRwqRaGkAaHlKVrOOoGjpUJfBSygOLotGcJuMrHomUbpCJZGNaX' |
| const fn = value => { | |
| return value | |
| } | |
| // main function | |
| ;((stdin, stdout) => { | |
| // input | |
| const value = stdin('/etc/passwd').readStream() | |
| // call function | |
| const result = fn(value) |
| const identity = v => v | |
| const join = (sep = '\n') => array => array.join(sep) | |
| const split = (sep = ' ') => string => string.split(sep) | |
| const seq = (size, start) => [...Array(size)].map((_, i) => i + start) | |
| const inputs = (file = '/dev/stdin') => { | |
| const stream = require('fs').readFileSync(file, 'utf-8').trim() | |
| const toArray = sep => fn => iter => Array.from(split(sep)(iter), fn) | |
| return { | |
| readCols: (fn = identity) => toArray(' ')(fn)(stream), | |
| readRows: (fn = identity) => toArray('\n')(fn)(stream), |
| #!/bin/bash | |
| URI='https://shouronbun.com/report1.html' | |
| curl $URI | html2text -utf8 | sed '/^$/d' | sed 's/\*//' | |
| # version3 |
| import React, { useState, useEffect } from 'react' | |
| import fetchData from './api/fetchData' | |
| const URI = 'https://jsonplaceholder.typicode.com/users' | |
| const Main = props => { | |
| const [data, setData] = useState(null) | |
| useEffect(() => { | |
| const fetchAPI = async () => { | |
| const data = await fetchData(URI) | |
| import React, { useState, useEffect } from 'react'; | |
| import axios from 'axios'; | |
| const fetchData = async (url) => { | |
| try { | |
| const response = await axios.get(url); | |
| return response.data; | |
| } catch (error) { | |
| console.error(error); | |
| return error; |