comment block demo

This commit is contained in:
Mark Canlas 2022-12-04 14:28:36 -05:00
parent 10e6eea846
commit a731672efa
3 changed files with 29 additions and 2 deletions

6
data/annotated-snake.asm Normal file
View File

@ -0,0 +1,6 @@
; ___ _ __ ___ __ ___
; / __|_ _ __ _| |_____ / /| __|/ \_ )
; \__ \ ' \/ _` | / / -_) _ \__ \ () / /
; |___/_||_\__,_|_\_\___\___/___/\__/___|
; Change direction: W A S D

View File

@ -0,0 +1,10 @@
package com.htmlism.firepower.demo
case class CommentBlock(xs: List[String])
object CommentBlock:
def toParagraph(cb: CommentBlock): Paragraph =
Paragraph(cb.xs.map("; " + _))
def fromMultiline(s: String): CommentBlock =
CommentBlock(s.split("\\n").toList)

View File

@ -18,10 +18,21 @@ object PrintPrograms extends ZIOAppDefault:
.apply(List("foo", "bar")),
"two-paragraphs.txt" -> (Line.mkString _)
.compose(Paragraph.mkLines)
.apply(List(Paragraph("foo", "bar"), Paragraph("alpha", "bravo"))),
.apply(
List(
Paragraph(List("foo", "bar")),
Paragraph(List("alpha", "bravo"))
)
),
"annotated-snake.asm" -> (Line.mkString _)
.compose(Paragraph.mkLines)
.apply(List(Paragraph(asciiArt), Paragraph("Change direction: W A S D")))
.compose((xs: List[CommentBlock]) => xs.map(CommentBlock.toParagraph))
.apply(
List(
CommentBlock.fromMultiline(asciiArt),
CommentBlock(List("Change direction: W A S D"))
)
)
)
lazy val asciiArt =