DEV Community

LG
LG

Posted on • Edited on

1

TypeScript for prototyping: bijective function example with generics' notation

Bijective function (one-to-one correspondence) function in layman's terms with TypeScript generic notation:

function bijective<input, output>(arg1: input, arg2: output): void /* <= instead of "return;" do "void" */ {
   console.log(`${arg1}=>${arg2}`);
   /* return; */
}

bijective<number,boolean>(0, false) // #  "0=>false" 
bijective<number,boolean>(1, true) // # "1=>true" 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay