-
Notifications
You must be signed in to change notification settings - Fork 0
/
loopy2-md-untemplate.scala
65 lines (54 loc) · 3.08 KB
/
loopy2-md-untemplate.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// DO NOT HAND EDIT -- Autogenerated from 'loopy2.md.untemplate' at 2024-06-18T04:02:12.851870Z
package untemplatedoc
import java.io.{Writer,StringWriter}
import scala.collection.{immutable,mutable}
val Untemplate_loopy2_md = new untemplate.Untemplate[immutable.Map[String,Any],Nothing]:
val UntemplateFunction : untemplate.Untemplate[immutable.Map[String,Any],Nothing] = this
val UntemplateName : String = "loopy2_md"
val UntemplatePackage : String = "untemplatedoc"
val UntemplateInputName : String = "input"
val UntemplateInputTypeDeclared : String = "immutable.Map[String,Any]"
val UntemplateInputTypeCanonical : Option[String] = untemplate.Macro.nonEmptyStringOption( untemplate.Macro.recursiveCanonicalName[immutable.Map[String,Any]] )
val UntemplateInputDefaultArgument : Option[immutable.Map[String,Any]] = Some(immutable.Map.empty)
val UntemplateOutputMetadataTypeDeclared : String = "Nothing"
val UntemplateOutputMetadataTypeCanonical : Option[String] = untemplate.Macro.nonEmptyStringOption( untemplate.Macro.recursiveCanonicalName[Nothing] )
val UntemplateHeaderNote : String = ""
val UntemplateLastModified : Option[Long] = Some(1673166579000L)
val UntemplateSynthetic : Boolean = false
val UntemplateAttributes : immutable.Map[String,Any] = immutable.Map.empty
def apply(input : immutable.Map[String,Any] = immutable.Map.empty) : untemplate.Result[Nothing] =
val writer : StringWriter = new StringWriter(6210)
val attrs : immutable.Map[String,Any] = UntemplateAttributes
var mbMetadata : Option[Nothing] = None
var outputTransformer : Function1[untemplate.Result[Nothing],untemplate.Result[Nothing]] = identity
val num = math.round(math.random * 10).toInt
// comments in code blocks are fine!
// here is one way to turn text blocks into functions
val block0 = new Function0[String]:
def apply() : String =
"# Loopy\n"
def loopy() = block0()
for (i <- 0 until num)
writer.write(loopy()) // you have a java.io.Writer, called writer, to send output to
// below is another, perhaps even simpler way to turn blocks into functions
//
// the indent of the if and else clauses must be lined up,
// the statement that prints becomes indented from that level!
def reportCard() : Unit =
if (num >= 5)
val block1 = new Function0[String]:
def apply() : String =
"\nAnd we're a winner! (num = " + (num) +
")\n"
writer.write(block1())
else
val block2 = new Function0[String]:
def apply() : String =
"\nIt sucks to be us. (num = " + (num) +
")\n"
writer.write(block2())
reportCard()
outputTransformer( untemplate.Result( mbMetadata, writer.toString ) )
end apply
end Untemplate_loopy2_md
def loopy2_md(input : immutable.Map[String,Any] = immutable.Map.empty) : untemplate.Result[Nothing] = Untemplate_loopy2_md( input )