Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Create an Anonymous Function | Anonymous Functions in R
Functions and Functional Programming in R

bookChallenge: Create an Anonymous Function

Oppgave

Swipe to start coding

Write three anonymous functions in R and assign them to variables as described below:

  • Create an anonymous function that adds 3 to its input and assign it to the variable add_three.
  • Create an anonymous function that returns TRUE if a number is even, and assign it to the variable is_even.
  • Create an anonymous function that concatenates two strings (with no separator), and assign it to the variable concat_strings.

Each function should be assigned to the specified variable name. Do not use named function definitions for this task.

Løsning

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 2
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

Suggested prompts:

Can you explain this in simpler terms?

What are the main points I should remember?

Can you give me an example?

close

bookChallenge: Create an Anonymous Function

Sveip for å vise menyen

Oppgave

Swipe to start coding

Write three anonymous functions in R and assign them to variables as described below:

  • Create an anonymous function that adds 3 to its input and assign it to the variable add_three.
  • Create an anonymous function that returns TRUE if a number is even, and assign it to the variable is_even.
  • Create an anonymous function that concatenates two strings (with no separator), and assign it to the variable concat_strings.

Each function should be assigned to the specified variable name. Do not use named function definitions for this task.

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 2
single

single

some-alt