Skip to main content
Commonmark migration
Source Link

##LOGO, 33 bytes##

LOGO, 33 bytes

[cascade ?2 "bf cascade ?3 "bl ?]

Try it on FMSLogo.

This is a template-list in LOGO, which is the equivalent of lambda (anonymous) function in many other languages.

Where:

  • cascade outputs the result of applying a template repeatedly, in this case is ?2 times bf and ?3 times bl.
  • bf and bl stands for ButFirst and ButLast respectively.
  • ? is used to access parameters. So ?2 is the second parameter, ?3 is the third parameter, etc.

Test:

show apply [cascade ?2 "bf cascade ?3 "bl ?] [[1 2 3 4 5 6] 2 1]

print [3 4 5].

##LOGO, 33 bytes##

[cascade ?2 "bf cascade ?3 "bl ?]

Try it on FMSLogo.

This is a template-list in LOGO, which is the equivalent of lambda (anonymous) function in many other languages.

Where:

  • cascade outputs the result of applying a template repeatedly, in this case is ?2 times bf and ?3 times bl.
  • bf and bl stands for ButFirst and ButLast respectively.
  • ? is used to access parameters. So ?2 is the second parameter, ?3 is the third parameter, etc.

Test:

show apply [cascade ?2 "bf cascade ?3 "bl ?] [[1 2 3 4 5 6] 2 1]

print [3 4 5].

LOGO, 33 bytes

[cascade ?2 "bf cascade ?3 "bl ?]

Try it on FMSLogo.

This is a template-list in LOGO, which is the equivalent of lambda (anonymous) function in many other languages.

Where:

  • cascade outputs the result of applying a template repeatedly, in this case is ?2 times bf and ?3 times bl.
  • bf and bl stands for ButFirst and ButLast respectively.
  • ? is used to access parameters. So ?2 is the second parameter, ?3 is the third parameter, etc.

Test:

show apply [cascade ?2 "bf cascade ?3 "bl ?] [[1 2 3 4 5 6] 2 1]

print [3 4 5].

Source Link
user202729
  • 17.6k
  • 2
  • 39
  • 71

##LOGO, 33 bytes##

[cascade ?2 "bf cascade ?3 "bl ?]

Try it on FMSLogo.

This is a template-list in LOGO, which is the equivalent of lambda (anonymous) function in many other languages.

Where:

  • cascade outputs the result of applying a template repeatedly, in this case is ?2 times bf and ?3 times bl.
  • bf and bl stands for ButFirst and ButLast respectively.
  • ? is used to access parameters. So ?2 is the second parameter, ?3 is the third parameter, etc.

Test:

show apply [cascade ?2 "bf cascade ?3 "bl ?] [[1 2 3 4 5 6] 2 1]

print [3 4 5].