Scala
def factorial(n: Int) = {
def tailFactorial(n: Int, acc: Int): Int =
if (n == 0) acc else tailFactorial(n - 1, acc * n)
tailFactorial(n, 1)| const CONSONANTS = ['q', 'w', 'r', 't', 'y', 'p', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm']; | |
| const VOCALS = ['a', 'e', 'i', 'o', 'u']; | |
| const buildPair = (cons, vocal) => | |
| cons | |
| .reduce((res, e) => { | |
| const pair = VOCALS.map(v => e + v); | |
| res.push(pair); | |
| import { omit, pipe, assoc } from 'ramda'; | |
| const stringifyJson = e => JSON.stringify(e, null, '\t'); | |
| const parsedJson = e => JSON.parse(e.replace('\t', '')); | |
| const moduleDefinitionInput = pipe(omit(['staticDisplayName']), stringifyJson); | |
| const moduleDefinitionOutput = pipe(parsedJson, assoc('staticDisplayName', staticDisplayName)); | |
| moduleDefinitionInput(content); | |
| moduleDefinitionOutput(content); |
| export function * fetchAllWorker (action) { | |
| yield put(actions.fetchAll.start()) | |
| const { types } = action.payload | |
| for (let i = 0; i < types.length; i++) { | |
| const { res, error } = yield call(get, `js_helpers/${types[i]}`) | |
| if (res.status > 201 || error) { | |
| return put(actions.fetchAll.failure({ error })) |
| import { when, equals, always, __ } from 'ramda' | |
| //* Return a value when a certain value is provided | |
| const parseTitleRamda = value => ( | |
| when(equals('workflow', __), always('endpoints'))(value), | |
| when(equals('integration', __), always('connections'))(value) | |
| ) | |
| const parseTitle = title => { | |
| if (title === 'workflow') return 'endpoints'; |
| const d = document; | |
| //* Basic setup | |
| const first = d.createElement('a'); | |
| first.innerText = 'Holi Primero'; | |
| first.setAttribute('href', '#/first') | |
| const second = d.createElement('a'); | |
| second.innerText = 'Holi Segundo'; | |
| second.setAttribute('href', '#/second') |
| var refreshButton = document.querySelector('.refresh') | |
| var refreshClickStream = Rx.Observable | |
| .fromEvent(refreshButton, 'click') | |
| var startupRequest = Rx.Observable | |
| .just('https://api.github.com/users') | |
| var reqOnRefreshStream = refreshClickStream | |
| .map(event => { |
| function extractEndpointNames (json) { | |
| function recurExtract (json, result) { | |
| for (let key in json[0]) { | |
| if (Array.isArray(json[0][key])) { | |
| recurExtract( | |
| json[0][key], | |
| result | |
| ) | |
| } else { | |
| if (key === 'args') { |
| const buildObject = actions => { | |
| const buildObjectRecursive = (actions, result) => { | |
| for (let key in actions) { | |
| if (actions[key].activity !== 'branch') { | |
| result[actions[key].name] = { | |
| ...actions[key] | |
| }; | |
| } | |
| for (let k in actions[key]) { |
| // defaults/index.js | |
| import development from './development'; | |
| import production from './production'; | |
| export default { | |
| development, | |
| production | |
| }[process.env.NODE_ENV || 'development']; | |