Skip to content

Commit

Permalink
conscript: add for/study
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdanp committed Feb 5, 2024
1 parent 9c1780b commit b3da005
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion congame-core/components/for-study.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

(require (for-syntax racket/base
syntax/for-body
syntax/parse)
syntax/parse/pre)
congame/components/study)

(provide
Expand Down
30 changes: 30 additions & 0 deletions congame-example-study/conscript-for-study.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#lang conscript

(provide
conscript-for-study-example)

(defvar n i-swear-this-is-unique)

(defstep (start)
(define (set-n #:n the-n)
(set! n the-n))
@md{# Start

@form[#:action set-n]{
@input-number[#:n #:min 1 #:max 5]{How many steps?}
@submit-button
}})

(defstep (say-hi i)
@md{# Hello

This is step @number->string[i].

@button{Continue}})

(define (make-substudy)
(for/study ([i (in-range n)])
(say-hi i)))

(defstudy conscript-for-study-example
[start --> [s (make-step/study 's make-substudy)] --> start])
1 change: 1 addition & 0 deletions congame-example-study/info.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'((congame-example-study/conscript conscript-example)
(congame-example-study/conscript-bot conscript-bot-example)
(congame-example-study/conscript-defvar conscript-defvar-example)
(congame-example-study/conscript-for-study conscript-for-study-example)
(congame-example-study/conscript-form conscript-form-example)
(congame-example-study/conscript-form-inline conscript-form-inline-example)
(congame-example-study/conscript-markdown conscript-markdown-example)
Expand Down
6 changes: 4 additions & 2 deletions conscript/base.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
(prefix-in congame: congame/components/struct)
(prefix-in congame: congame/components/study)
(except-in congame/components/study button form)
congame/components/for-study
congame/components/transition-graph
racket/format
racket/lazy-require
Expand Down Expand Up @@ -42,6 +43,7 @@
;; Racket Runtime
lambda λ
void sleep
for for/list in-range in-inclusive-range in-list
list list? list* null null? cons pair? car cdr map for-each shuffle
display displayln print println printf eprintf write writeln
+ - * / modulo quotient remainder add1 sub1 abs max min round floor ceiling
Expand All @@ -51,7 +53,7 @@
format ~a number->string symbol->string

;; Congame Syntax
--> goto
--> goto for/study

;; Congame Runtime
(all-from-out
Expand Down Expand Up @@ -146,7 +148,7 @@
{pattern step:id
#:with (tg-e ...) #'(step)
#:with ((step-id step-e) ...) #'((step step))}
{pattern [step:id step-expr:id]
{pattern [step:id step-expr:expr]
#:with (tg-e ...) #'(step)
#:with ((step-id step-e) ...) #'((step step-expr))}
{pattern {~seq lhs:transition-arrow ~! --> rhs:transition-arrow}
Expand Down

0 comments on commit b3da005

Please sign in to comment.