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

bookChallenge: Create an Anonymous Function

Uppgift

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

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 2
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

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

Svep för att visa menyn

Uppgift

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 desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 2
single

single

some-alt