Skip to main content
Shorter, fix issue with empty sections, explain
Source Link
Adám
  • 31.1k
  • 3
  • 124
  • 287

Dyalog APL 16.0APL (Dyalog Unicode), 43 37 bytes28 bytes

Full program. Prompts for comment charactercode, then for codecomment character.

↑(↓↑((-(⍸'|'∘=),≢)↑¨'|'∘≠⊆⊢⍤1⍨⎕FMT⎕TC[2]@('|'∘=)⍞),¨⊂¯2↑⍞' '

Try it online!

⍞,' ' append a space the to prompted-for code

⎕TC[2]@() place the 2nd Terminal Control character (Line Feed) at the positions indicated by:

'|'∘= the mask indicating where the pipe symbol is equal to the characters

⎕FMT ForMaT as a character matrix, evaluating terminal control characters (Line Feed moves the "cursor" down one line)

⍞,⍤1⍨ prompt for comment character and append it to each line (lit. to each 1D sub-array)

Dyalog APL 16.0, 43 37 bytes

Prompts for comment character, then for code.

↑(↓↑((-(⍸'|'∘=),≢)↑¨'|'∘≠⊆⊢)⍞),¨⊂¯2↑⍞

APL (Dyalog Unicode), 28 bytes

Full program. Prompts for code, then for comment character.

,⍤1⍨⎕FMT⎕TC[2]@('|'∘=)⍞,' '

Try it online!

⍞,' ' append a space the to prompted-for code

⎕TC[2]@() place the 2nd Terminal Control character (Line Feed) at the positions indicated by:

'|'∘= the mask indicating where the pipe symbol is equal to the characters

⎕FMT ForMaT as a character matrix, evaluating terminal control characters (Line Feed moves the "cursor" down one line)

⍞,⍤1⍨ prompt for comment character and append it to each line (lit. to each 1D sub-array)

deleted 77 characters in body
Source Link
emanresu A
  • 44.3k
  • 5
  • 100
  • 240

Dyalog APL 16.0 (non-competing), 43 37 bytes

Prompts for comment character, then for code.

↑(↓↑((-(⍸'|'∘=),≢)↑¨'|'∘≠⊆⊢)⍞),¨⊂¯2↑⍞

Non-competing because version 16.0's is newer than this challenge.

Dyalog APL 16.0 (non-competing), 43 37 bytes

Prompts for comment character, then for code.

↑(↓↑((-(⍸'|'∘=),≢)↑¨'|'∘≠⊆⊢)⍞),¨⊂¯2↑⍞

Non-competing because version 16.0's is newer than this challenge.

Dyalog APL 16.0, 43 37 bytes

Prompts for comment character, then for code.

↑(↓↑((-(⍸'|'∘=),≢)↑¨'|'∘≠⊆⊢)⍞),¨⊂¯2↑⍞
Commonmark migration
Source Link

#Dyalog APL 16.0 (non-competing), 43 37 bytes

Dyalog APL 16.0 (non-competing), 43 37 bytes

Prompts for comment character, then for code.

↑(↓↑((-(⍸'|'∘=),≢)↑¨'|'∘≠⊆⊢)⍞),¨⊂¯2↑⍞

Non-competing because version 16.0's is newer than this challenge.

#Dyalog APL 16.0 (non-competing), 43 37 bytes

Prompts for comment character, then for code.

↑(↓↑((-(⍸'|'∘=),≢)↑¨'|'∘≠⊆⊢)⍞),¨⊂¯2↑⍞

Non-competing because version 16.0's is newer than this challenge.

Dyalog APL 16.0 (non-competing), 43 37 bytes

Prompts for comment character, then for code.

↑(↓↑((-(⍸'|'∘=),≢)↑¨'|'∘≠⊆⊢)⍞),¨⊂¯2↑⍞

Non-competing because version 16.0's is newer than this challenge.

replaced http://meta.codegolf.stackexchange.com/ with https://codegolf.meta.stackexchange.com/
Source Link
Loading
replaced http://meta.codegolf.stackexchange.com/ with https://codegolf.meta.stackexchange.com/
Source Link
Loading
replaced http://meta.codegolf.stackexchange.com/ with https://codegolf.meta.stackexchange.com/
Source Link
Loading
typo
Source Link
Adám
  • 31.1k
  • 3
  • 124
  • 287
Loading
-6
Source Link
Adám
  • 31.1k
  • 3
  • 124
  • 287
Loading
Source Link
Adám
  • 31.1k
  • 3
  • 124
  • 287
Loading