ramda#join TypeScript Examples

The following examples show how to use ramda#join. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: L5-ast.ts    From interpreters with MIT License 6 votes vote down vote up
unparse = (e: Parsed): Result<string> =>
    // NumExp | StrExp | BoolExp | PrimOp | VarRef
    isNumExp(e) ? makeOk(`${e.val}`) :
    isStrExp(e) ? makeOk(`"${e.val}"`) :
    isBoolExp(e) ? makeOk(e.val ? "#t" : "#f") :
    isPrimOp(e) ? makeOk(e.op) :
    isVarRef(e) ? makeOk(e.var) :
    // AppExp | IfExp | ProcExp | LetExp | LitExp | LetrecExp | SetExp
    isAppExp(e) ? bind(unparse(e.rator), (rator: string) =>
                    mapv(mapResult(unparse, e.rands), (rands: string[]) =>
                        `(${rator} ${join(" ", rands)})`)) :
    isIfExp(e) ? bind(unparse(e.test), (test: string) =>
                    bind(unparse(e.then), (then: string) =>
                        mapv(unparse(e.alt), (alt: string) => 
                            `(if ${test} ${then} ${alt})`))) :
    isLetExp(e) ? unparseLetExp(e) :
    isLetrecExp(e) ? unparseLetrecExp(e) :
    isProcExp(e) ? unparseProcExp(e) :
    isLitExp(e) ? makeOk(unparseLitExp(e)) :
    isSetExp(e) ? unparseSetExp(e) :
    // DefineExp | Program
    isDefineExp(e) ? bind(unparseVarDecl(e.var), (vd: string) =>
                        mapv(unparse(e.val), (val: string) =>
                            `(define ${vd} ${val})`)) :
    isProgram(e) ? mapv(unparseLExps(e.exps), (exps: string) => `(L5 ${exps})`) :
    e
Example #2
Source File: vaccinationQRHelper.ts    From back-home-safe with GNU General Public License v3.0 6 votes vote down vote up
parseQRCode1 = (type: schemaVersionType, input: string[]) => {
  const [
    prefix1,
    prefix2,
    formatVersion,
    refId,
    docType,
    iNum,
    specimenCollectionDate,
    specimenType,
    testingPlatform,
    testResult,
    reportDate,
  ] = input;

  return {
    prefix1,
    prefix2,
    formatVersion,
    refId,
    docType,
    iNum,
    specimenCollectionDate,
    specimenType,
    testingPlatform,
    testResult,
    reportDate,
    downloadDate: type === schemaVersionType.EVT1 ? null : input[11],
    digitalSignature: type === schemaVersionType.EVT1 ? input[11] : input[12],
    stringToBeSigned: join("|", init(input)) + "|",
    schemaVersion: type,
  };
}
Example #3
Source File: L5-ast.ts    From interpreters with MIT License 5 votes vote down vote up
unparseBindings = (bindings: Binding[]): Result<string> =>
    mapv(mapResult(bdg => bind(unparseVarDecl(bdg.var), (vd: string) =>
                            mapv(unparse(bdg.val), (val: string) => `(${vd} ${val})`)),
                   bindings), (bdgs: string[]) => 
            join(" ", bdgs))
Example #4
Source File: L5-ast.ts    From interpreters with MIT License 5 votes vote down vote up
unparseLExps = (les: Exp[]): Result<string> =>
    mapv(mapResult(unparse, les), (les: string[]) => join(" ", les))
Example #5
Source File: L5-ast.ts    From interpreters with MIT License 5 votes vote down vote up
unparseProcExp = (pe: ProcExp): Result<string> =>
    bind(mapResult(unparseVarDecl, pe.args), (vds: string[]) =>
        bind(unparseReturn(pe.returnTE), (ret: string) =>
            mapv(unparseLExps(pe.body), (body: string) =>
            `(lambda (${join(" ", vds)})${ret} ${body})`)))
Example #6
Source File: L5-value.ts    From interpreters with MIT License 5 votes vote down vote up
compoundSExpToString = (cs: CompoundSExp, css = compoundSExpToArray(cs, [])): string => 
    isArray(css) ? `(${join(' ', css)})` :
    `(${css.s1.join(' ')} . ${css.s2})`
Example #7
Source File: L7c-eval.ts    From interpreters with MIT License 5 votes vote down vote up
pes = (es: Exp[]): string =>
    `[${join(", ", map(up, es))}]`
Example #8
Source File: L7c-eval.ts    From interpreters with MIT License 5 votes vote down vote up
pvs = (vs: Result<Value[]> | undefined): string =>
    vs ? either(vs, values => `[${join(", ", map(pv, map(makeOk, values)))}]`, identity) : "undefined"
Example #9
Source File: vaccinationQRHelper.ts    From back-home-safe with GNU General Public License v3.0 5 votes vote down vote up
parseQRCode2 = (type: schemaVersionType, input: string[]) => {
  const [
    prefix1,
    prefix2,
    qrCodeVersion,
    keyVersion,
    vacRef,
    iNum,
    label1,
    firstDoseDate,
    firstVaccineName,
    firstVaccineNameTc,
    firstBrandName,
    firstBrandNameTc,
    secondDoseDate,
    secondVaccineName,
    secondVaccineNameTc,
    secondBrandName,
    secondBrandNameTc,
    downloadDate,
    digitalSignature,
  ] = input;

  return {
    prefix1,
    prefix2,
    qrCodeVersion,
    keyVersion,
    vacRef,
    iNum,
    label1,
    firstDoseDate,
    firstVaccineName,
    firstVaccineNameTc,
    firstBrandName,
    firstBrandNameTc,
    secondDoseDate,
    secondVaccineName,
    secondVaccineNameTc,
    secondBrandName,
    secondBrandNameTc,
    downloadDate,
    digitalSignature,
    stringToBeSigned: join("|", init(input)) + "|",
    schemaVersion: type,
  };
}