Commit d0dd4845 authored by rokka's avatar rokka

ueb6 fast fertig

parent 70f793ae
In der Vorlesung haben Sie bereits Listen kennengelernt und gesehen, wie Sie damit arbeiten. In dieser Aufgabe sollen Sie eine nützliche Listenfunktionen implementieren.
Sie dürfen nur die eingebauten Funktionen empty?, cons, first, rest, cons? und equal? benutzen, sowie die eingebaute Konstante empty und die eingebauten check-* Funktionen. Ansonsten dürfen Sie nur selbst definierte Funktionen aufrufen.
(list-remove e l) entfernt alle Vorkommen von e aus der Liste l und liefert die resultierende Liste. Benutzen Sie für den Vergleich equal?.
\ No newline at end of file
xquery version "1.0";
import module namespace aa='https://plt.bitbucket.io/autoassess' at 'DrRacketFunctions.xqy';
declare variable $funName := "list-remove";
declare variable $funParameterTypes := ("X", "\(\s*list-of\s+X\s*\)");
declare variable $funReturnType := "\(\s*list-of\s+X\s*\)";
declare variable $funDecl := aa:funDecl($funName, count($funParameterTypes), true(), /drracket);
declare variable $allowed := ('empty?', 'cons', 'first', 'rest', 'cons?', 'equal?', 'define', 'cond', 'if', 'else', 'and', 'or', 'not', 'list',
'modname', 'read-case-sensitive', 'teachpacks', 'lib', 'htdp-settings', '#t', '#f',
//paren/terminal[@value="define"]/following-sibling::paren[1]/terminal[1]/attribute::value/string(),
//paren/terminal[@value="define"]/following-sibling::node()[1]/self::terminal[1]/attribute::value/string());
aa:assertPresent(
"Es ist nicht das korrekte Sprachniveau ('beginner' oder 'beginner with list abbreviations') eingestellt oder Teachpacks fehlen ('universe', 'image').",
(aa:studentLanguage("beginner-abbr", ('"image.rkt"', '"universe.rkt"'), /drracket),
aa:studentLanguage("beginner", ('"image.rkt"', '"universe.rkt"'), /drracket))),
aa:assertTrue(
"Eckige Klammern sind nur für die Fälle von cond-Ausdrücken erlaubt.",
aa:squareParensOnlyInCond(/drracket)),
aa:assertTrue("Geben Sie Fälle von cond-Ausdrücken in eckigen Klammern an",
aa:condCasesSquare(/drracket)),
aa:assertPresent(
concat("Die Funktion ", $funName, " mit zwei Parametern ist nicht definiert."),
$funDecl),
aa:assertTrue(
concat("Es sind keine ausreichenden Tests für die Function ", $funName, " definiert."),
count(aa:precedingTests($funDecl)) >= 2),
aa:assertPresent(
concat("Es ist kein Kommentar für die Funktion ", $funName, " angegeben"),
aa:functionComment($funDecl)),
aa:assertTrue(
concat("Für die Funktion ", $funName, " ist die Signatur nicht oder nicht korrekt dokumentiert. Bitte verwenden Sie als Namen für den Typparameter X."),
aa:funDocMatchesSignature2($funDecl,"\[\s*X\s*\]",
$funParameterTypes, $funReturnType)),
aa:assertTrue(
concat("Die Dokumentation für die Funktion ", $funName, " enthält keine Beschreibung für alle parameter."),
aa:funDocContainsParams($funDecl)),
for $call in //paren/child::node()[1]/self::terminal/attribute::value/string()
where not(exists(index-of($allowed, $call))) and not(starts-with($call, "check-")) and not(string-length($call) <= 2)
return <p>Die Verwendung der Funktion {$call} ist nicht erlaubt.</p>
\ No newline at end of file
module namespace aa='https://plt.bitbucket.io/autoassess';
declare function aa:assertPresent($msg as xs:string, $e as node()*)
{
if (fn:empty($e)) then (
<p>{$msg}</p>
)
else ()
};
declare function aa:assertNotPresent($msg as xs:string, $e as node()*)
{
if (fn:empty($e)) then ( )
else (
<p>{$msg}</p>
)
};
declare function aa:value-intersect( $arg1 as xs:anyAtomicType*, $arg2 as xs:anyAtomicType* ) as xs:anyAtomicType*
{
distinct-values($arg1[.=$arg2])
};
declare function aa:studentLanguage($level as xs:string, $reqTeachpacks as xs:string*, $r as element())
{
let $reader := $r/conf[@lang="#reader"]
let $lib := $reader/following-sibling::paren[1]/terminal[@value=concat('"htdp-', $level, '-reader.ss"')]
let $teachpacks := $lib/parent::node()/parent::node()/paren[2]//terminal[@value='teachpacks']/parent::node()
let $teachpacksSeq := aa:value-intersect($teachpacks/paren/paren/terminal[2]/attribute::value/string(), $reqTeachpacks)
let $teachpacksOrdered := for $item in $teachpacksSeq
order by $item
return $item
let $reqTeachpacksOrdered := for $item in $reqTeachpacks
order by $item
return $item
return if (deep-equal($teachpacksOrdered, $reqTeachpacksOrdered)) then (
$reader
)
else ()
};
declare function aa:funDecl($name as xs:string, $args as xs:integer, $onlyTopLevel as xs:boolean, $r as element()*)
{
let $functionNameDeclaration :=
if ($onlyTopLevel)
then ($r/paren/terminal[@value="define"]/following-sibling::paren/terminal[@value=$name])
else ($r//paren/terminal[@value="define"]/following-sibling::paren/terminal[@value=$name])
for $decl in $functionNameDeclaration
where (count($decl/following-sibling::terminal) = $args)
return $decl/parent::node()/parent::node()
};
declare function aa:funComment($funDecl as element()*)
{
$funDecl/preceding-sibling::*[1][self::comment]
};
declare function aa:funBody($funDecl as element()*)
{
$funDecl/paren[1]/following-sibling::*[not(self::comment)][1]
};
declare function aa:funCall($name as xs:string, $args as xs:integer, $r as element()*)
{
let $calls := $r//paren/terminal[@value=$name]
for $call in $calls
where (count($call/following-sibling::*[not(self::comment)]) = $args)
return $call/parent::node()
};
declare function aa:index-of-node($nodes as node()*, $nodeToFind as node()) as xs:integer*
{
for $seq in (1 to count($nodes))
return $seq[$nodes[$seq] is $nodeToFind]
};
declare function aa:precedingTests($progElemem as element()*) as element()*
{
let $test := $progElemem/preceding-sibling::*[1][self::paren]/terminal[starts-with(@value,"check-")]/parent::element()
return if (fn:empty($test)) then ()
else
((aa:precedingTests($test), $test))
};
declare function aa:functionComment($funDecl) as element()*
{
let $tests := aa:precedingTests($funDecl)
let $comment := if (fn:empty($tests))
then
($funDecl/preceding-sibling::*[1][self::comment])
else
(fn:head($tests)/preceding-sibling::*[1][self::comment])
return $comment
};
declare function aa:findFirstCall($name as xs:string, $progElem as element(), $includeSelf)
{
let $temp :=
if ($includeSelf)
then
(($progElem/descendant-or-self::paren/terminal[@value=$name])[1])
else
(($progElem/descendant::paren/terminal[@value=$name])[1])
return $temp/parent::paren
};
declare function aa:funDocMatchesSignature($funDecl as element()*, $parameterTypes as xs:string*, $returnType as xs:string) as xs:boolean
{
matches(aa:functionComment($funDecl)/text(),
concat(".*;\s*", string-join($parameterTypes, "\s*"), "\s*->\s*", $returnType, ".*"), "si")
};
declare function aa:funDocMatchesSignature2($funDecl as element()*, $typeParam as xs:string, $parameterTypes as xs:string*, $returnType as xs:string) as xs:boolean
{
matches(aa:functionComment($funDecl)/text(),
concat(".*;\s*", $typeParam, "\s*", string-join($parameterTypes, "\s*"), "\s*->\s*", $returnType, ".*"), "si")
};
declare function aa:funDocContainsParam($funDecl as element()*, $param as xs:string)
{
matches(aa:functionComment($funDecl)/text(),
concat("(^|[^\w*])", $param, "([^\w*]|$)"))
};
declare function aa:funDocContainsParams($funDecl as element()*)
{
let $undocumented :=
for $param in $funDecl/paren[1]/terminal[1]/following-sibling::terminal/@value
where not(aa:funDocContainsParam($funDecl, data($param)))
return $param
return empty($undocumented)
};
declare function aa:assertTrue($msg as xs:string, $pred)
{
if ($pred = true())
then ()
else (<p>{$msg}</p>)
};
declare function aa:squareParensOnlyInCond($r as element())
{
let $cond-cases := $r//paren/terminal[@value="cond"]/parent::paren/paren
let $square-parens := $r//paren[@type="square"]
let $violations :=
for $square-paren in $square-parens
return
if (empty(aa:index-of-node($cond-cases,$square-paren)))
then ($square-paren)
else ()
return empty($violations)
};
declare function aa:condCasesSquare($r as element())
{
let $cond-cases := $r//paren/terminal[@value="cond"]/parent::paren/paren
return
if (not(empty($cond-cases[@type="round"])))
then false()
else true()
};
declare function aa:enumTypeComment($r as node(), $typename as xs:string, $elements as xs:string*)
{
for $comment in ($r//comment/text())
where
matches($comment, concat(".*", $typename, ".*"))
and count($elements) = count(
for $keyword in $elements
where matches($comment, concat('.*;\s*-\s*', $keyword, '.*'))
return $keyword)
return $comment
};
declare function aa:enumTypeTests($funDecl as element()*, $elements as xs:string*)
{
let $tests := aa:precedingTests($funDecl)
return count($tests) >= count($elements)
and count($elements) = count(
for $element in $elements
where $tests//terminal[@value=$element]
return $element)
};
declare function aa:intervalTypeComment($r as node(), $typename as xs:string, $numOfIntervals, $constants as xs:string*)
{
for $comment in ($r//comment[contains(text(), $typename)])
let $cases := tokenize($comment, ".*;\s*-\s*")
return (count($cases) >= $numOfIntervals + 1)
and
count(for $const in $constants
where contains($comment, $const)
return $const) = count($constants)
};
declare function aa:intervalTypeTests($funDecl as element()*, $numOfTests, $constants as xs:string*)
{
let $tests := aa:precedingTests($funDecl)
return count($tests) >= $numOfTests
and count($constants) = count(
for $const in $constants
where $tests//terminal[@value=$const]
return $const)
};
declare function aa:sumTypeComment($r as node(), $typename as xs:string, $numOfIntervals, $constants as xs:string*)
{
for $comment in ($r//comment[contains(text(), $typename)])
let $cases := tokenize($comment, ".*;\s*-\s*")
return (count($cases) >= $numOfIntervals + 1)
and count($constants) = count(
for $const in $constants
where contains($comment, $const)
return $const)
};
(require "Test-Harness.rkt")
(assert/equal (list 3 7) (list-remove 5 (list 3 5 7)) "Entfernen von 5 aus (list 3 5 7)")
(assert/equal (list 5 7) (list-remove 3 (list 3 5 7)) "Entfernen von 3 aus (list 3 5 7)")
(assert/equal (list 3 5) (list-remove 7 (list 3 5 7)) "Entfernen von 7 aus (list 3 5 7)")
(assert/equal (list 3 5 7) (list-remove 0 (list 3 5 7)) "Entfernen von 0 aus (list 3 5 7)")
(assert/equal '() (list-remove 0 '()) "Entfernen von 0 aus der leeren Liste")
(tear-down)
\ No newline at end of file
(require "Test-Harness.rkt")
(define V01/aa (make-posn 0 1))
(define V10/aa (make-posn 1 0))
(define V34/aa (make-posn 3 4))
(define V34norm/aa (make-posn (/ 3 5) (/ 4 5)))
(assert/equal V10/aa (vec-norm V10/aa) "Normierter Vektor (1, 0)")
(assert/equal V01/aa (vec-norm V01/aa) "Normierter Vektor (0, 1)")
(assert/equal V34norm/aa (vec-norm V34/aa) "Normierter Vektor (3, 4)")
(tear-down)
\ No newline at end of file
60
\ No newline at end of file
In der Vorlesung haben Sie bereits Listen kennengelernt und gesehen, wie Sie damit arbeiten. In dieser Aufgabe sollen Sie eine nützliche Listenfunktionen implementieren.
Sie dürfen nur die eingebauten Funktionen empty?, cons, first, rest, cons? und equal? benutzen, sowie die eingebaute Konstante empty und die eingebauten check-* Funktionen. Ansonsten dürfen Sie nur selbst definierte Funktionen aufrufen.
(list-reverse l) dreht den Inhalt der Liste um. Sie dürfen zusätzlich die eingebaute Funktion append benutzen.
Beispiel:
(list-reverse (list 1 2 3)) ->* (list 3 2 1)
\ No newline at end of file
xquery version "1.0";
import module namespace aa='https://plt.bitbucket.io/autoassess' at 'DrRacketFunctions.xqy';
declare variable $funName := "list-reverse";
declare variable $funParameterTypes := ("\(\s*list-of\s+X\s*\)");
declare variable $funReturnType := "\(\s*list-of\s+X\s*\)";
declare variable $funDecl := aa:funDecl($funName, count($funParameterTypes), true(), /drracket);
declare variable $allowed := ('empty?', 'cons', 'first', 'rest', 'cons?', 'equal?', 'define', 'cond', 'if', 'else', 'and', 'or', 'not', 'list', 'append',
'modname', 'read-case-sensitive', 'teachpacks', 'lib', 'htdp-settings', '#t', '#f',
//paren/terminal[@value="define"]/following-sibling::paren[1]/terminal[1]/attribute::value/string(),
//paren/terminal[@value="define"]/following-sibling::node()[1]/self::terminal[1]/attribute::value/string());
aa:assertPresent(
"Es ist nicht das korrekte Sprachniveau ('beginner' oder 'beginner with list abbreviations') eingestellt oder Teachpacks fehlen ('universe', 'image').",
(aa:studentLanguage("beginner-abbr", ('"image.rkt"', '"universe.rkt"'), /drracket),
aa:studentLanguage("beginner", ('"image.rkt"', '"universe.rkt"'), /drracket))),
aa:assertTrue(
"Eckige Klammern sind nur für die Fälle von cond-Ausdrücken erlaubt.",
aa:squareParensOnlyInCond(/drracket)),
aa:assertTrue("Geben Sie Fälle von cond-Ausdrücken in eckigen Klammern an",
aa:condCasesSquare(/drracket)),
aa:assertPresent(
concat("Die Funktion ", $funName, " mit einem Parameter ist nicht definiert."),
$funDecl),
aa:assertTrue(
concat("Es sind keine ausreichenden Tests für die Function ", $funName, " definiert."),
count(aa:precedingTests($funDecl)) >= 2),
aa:assertPresent(
concat("Es ist kein Kommentar für die Funktion ", $funName, " angegeben"),
aa:functionComment($funDecl)),
aa:assertTrue(
concat("Für die Funktion ", $funName, " ist die Signatur nicht oder nicht korrekt dokumentiert. Bitte verwenden Sie als Namen für den Typparameter X."),
aa:funDocMatchesSignature2($funDecl,"\[\s*X\s*\]",
$funParameterTypes, $funReturnType)),
aa:assertTrue(
concat("Die Dokumentation für die Funktion ", $funName, " enthält keine Beschreibung für alle parameter."),
aa:funDocContainsParams($funDecl)),
for $call in //paren/child::node()[1]/self::terminal/attribute::value/string()
where not(exists(index-of($allowed, $call))) and not(starts-with($call, "check-")) and not(string-length($call) <= 2)
return <p>Die Verwendung der Funktion {$call} ist nicht erlaubt.</p>
\ No newline at end of file
module namespace aa='https://plt.bitbucket.io/autoassess';
declare function aa:assertPresent($msg as xs:string, $e as node()*)
{
if (fn:empty($e)) then (
<p>{$msg}</p>
)
else ()
};
declare function aa:assertNotPresent($msg as xs:string, $e as node()*)
{
if (fn:empty($e)) then ( )
else (
<p>{$msg}</p>
)
};
declare function aa:value-intersect( $arg1 as xs:anyAtomicType*, $arg2 as xs:anyAtomicType* ) as xs:anyAtomicType*
{
distinct-values($arg1[.=$arg2])
};
declare function aa:studentLanguage($level as xs:string, $reqTeachpacks as xs:string*, $r as element())
{
let $reader := $r/conf[@lang="#reader"]
let $lib := $reader/following-sibling::paren[1]/terminal[@value=concat('"htdp-', $level, '-reader.ss"')]
let $teachpacks := $lib/parent::node()/parent::node()/paren[2]//terminal[@value='teachpacks']/parent::node()
let $teachpacksSeq := aa:value-intersect($teachpacks/paren/paren/terminal[2]/attribute::value/string(), $reqTeachpacks)
let $teachpacksOrdered := for $item in $teachpacksSeq
order by $item
return $item
let $reqTeachpacksOrdered := for $item in $reqTeachpacks
order by $item
return $item
return if (deep-equal($teachpacksOrdered, $reqTeachpacksOrdered)) then (
$reader
)
else ()
};
declare function aa:funDecl($name as xs:string, $args as xs:integer, $onlyTopLevel as xs:boolean, $r as element()*)
{
let $functionNameDeclaration :=
if ($onlyTopLevel)
then ($r/paren/terminal[@value="define"]/following-sibling::paren/terminal[@value=$name])
else ($r//paren/terminal[@value="define"]/following-sibling::paren/terminal[@value=$name])
for $decl in $functionNameDeclaration
where (count($decl/following-sibling::terminal) = $args)
return $decl/parent::node()/parent::node()
};
declare function aa:funComment($funDecl as element()*)
{
$funDecl/preceding-sibling::*[1][self::comment]
};
declare function aa:funBody($funDecl as element()*)
{
$funDecl/paren[1]/following-sibling::*[not(self::comment)][1]
};
declare function aa:funCall($name as xs:string, $args as xs:integer, $r as element()*)
{
let $calls := $r//paren/terminal[@value=$name]
for $call in $calls
where (count($call/following-sibling::*[not(self::comment)]) = $args)
return $call/parent::node()
};
declare function aa:index-of-node($nodes as node()*, $nodeToFind as node()) as xs:integer*
{
for $seq in (1 to count($nodes))
return $seq[$nodes[$seq] is $nodeToFind]
};
declare function aa:precedingTests($progElemem as element()*) as element()*
{
let $test := $progElemem/preceding-sibling::*[1][self::paren]/terminal[starts-with(@value,"check-")]/parent::element()
return if (fn:empty($test)) then ()
else
((aa:precedingTests($test), $test))
};
declare function aa:functionComment($funDecl) as element()*
{
let $tests := aa:precedingTests($funDecl)
let $comment := if (fn:empty($tests))
then
($funDecl/preceding-sibling::*[1][self::comment])
else
(fn:head($tests)/preceding-sibling::*[1][self::comment])
return $comment
};
declare function aa:findFirstCall($name as xs:string, $progElem as element(), $includeSelf)
{
let $temp :=
if ($includeSelf)
then
(($progElem/descendant-or-self::paren/terminal[@value=$name])[1])
else
(($progElem/descendant::paren/terminal[@value=$name])[1])
return $temp/parent::paren
};
declare function aa:funDocMatchesSignature($funDecl as element()*, $parameterTypes as xs:string*, $returnType as xs:string) as xs:boolean
{
matches(aa:functionComment($funDecl)/text(),
concat(".*;\s*", string-join($parameterTypes, "\s*"), "\s*->\s*", $returnType, ".*"), "si")
};
declare function aa:funDocMatchesSignature2($funDecl as element()*, $typeParam as xs:string, $parameterTypes as xs:string*, $returnType as xs:string) as xs:boolean
{
matches(aa:functionComment($funDecl)/text(),
concat(".*;\s*", $typeParam, "\s*", string-join($parameterTypes, "\s*"), "\s*->\s*", $returnType, ".*"), "si")
};
declare function aa:funDocContainsParam($funDecl as element()*, $param as xs:string)
{
matches(aa:functionComment($funDecl)/text(),
concat("(^|[^\w*])", $param, "([^\w*]|$)"))
};
declare function aa:funDocContainsParams($funDecl as element()*)
{
let $undocumented :=
for $param in $funDecl/paren[1]/terminal[1]/following-sibling::terminal/@value
where not(aa:funDocContainsParam($funDecl, data($param)))
return $param
return empty($undocumented)
};
declare function aa:assertTrue($msg as xs:string, $pred)
{
if ($pred = true())
then ()
else (<p>{$msg}</p>)
};
declare function aa:squareParensOnlyInCond($r as element())
{
let $cond-cases := $r//paren/terminal[@value="cond"]/parent::paren/paren
let $square-parens := $r//paren[@type="square"]
let $violations :=
for $square-paren in $square-parens
return
if (empty(aa:index-of-node($cond-cases,$square-paren)))
then ($square-paren)
else ()
return empty($violations)
};
declare function aa:condCasesSquare($r as element())
{
let $cond-cases := $r//paren/terminal[@value="cond"]/parent::paren/paren
return
if (not(empty($cond-cases[@type="round"])))
then false()
else true()
};
declare function aa:enumTypeComment($r as node(), $typename as xs:string, $elements as xs:string*)
{
for $comment in ($r//comment/text())
where
matches($comment, concat(".*", $typename, ".*"))
and count($elements) = count(
for $keyword in $elements
where matches($comment, concat('.*;\s*-\s*', $keyword, '.*'))
return $keyword)
return $comment
};
declare function aa:enumTypeTests($funDecl as element()*, $elements as xs:string*)
{
let $tests := aa:precedingTests($funDecl)
return count($tests) >= count($elements)
and count($elements) = count(
for $element in $elements
where $tests//terminal[@value=$element]
return $element)
};
declare function aa:intervalTypeComment($r as node(), $typename as xs:string, $numOfIntervals, $constants as xs:string*)
{
for $comment in ($r//comment[contains(text(), $typename)])
let $cases := tokenize($comment, ".*;\s*-\s*")
return (count($cases) >= $numOfIntervals + 1)
and
count(for $const in $constants
where contains($comment, $const)
return $const) = count($constants)
};
declare function aa:intervalTypeTests($funDecl as element()*, $numOfTests, $constants as xs:string*)
{
let $tests := aa:precedingTests($funDecl)
return count($tests) >= $numOfTests
and count($constants) = count(
for $const in $constants
where $tests//terminal[@value=$const]
return $const)
};
declare function aa:sumTypeComment($r as node(), $typename as xs:string, $numOfIntervals, $constants as xs:string*)
{
for $comment in ($r//comment[contains(text(), $typename)])
let $cases := tokenize($comment, ".*;\s*-\s*")
return (count($cases) >= $numOfIntervals + 1)
and count($constants) = count(
for $const in $constants
where contains($comment, $const)
return $const)
};
(require "Test-Harness.rkt")
(assert/equal (list 7 5 3) (list-reverse (list 3 5 7)) "Umdrehen der Liste (list 3 5 7)")
(assert/equal (list 5 3) (list-reverse (list 3 5)) "Umdrehen der Liste (list 3 5)")
(assert/equal (list 3) (list-reverse (list 3)) "Umdrehen der Liste (list 3)")
(assert/equal '() (list-reverse '()) "Umdrehen der leeren Liste ")
(assert/equal (list false true) (list-reverse (list true false)) "Umdrehen der Liste (list true false)")
(tear-down)
\ No newline at end of file
(require "Test-Harness.rkt")
(define V01/aa (make-posn 0 1))
(define V10/aa (make-posn 1 0))
(define V34/aa (make-posn 3 4))
(define V34norm/aa (make-posn (/ 3 5) (/ 4 5)))
(assert/equal V10/aa (vec-norm V10/aa) "Normierter Vektor (1, 0)")
(assert/equal V01/aa (vec-norm V01/aa) "Normierter Vektor (0, 1)")
(assert/equal V34norm/aa (vec-norm V34/aa) "Normierter Vektor (3, 4)")
(tear-down)
\ No newline at end of file
60
\ No newline at end of file
In der Vorlesung haben Sie bereits Listen kennengelernt und gesehen, wie Sie damit arbeiten. In dieser Aufgabe sollen Sie eine nützliche Listenfunktionen implementieren.
Sie dürfen nur die eingebauten Funktionen empty?, cons, first, rest, cons? und equal? benutzen, sowie die eingebaute Konstante empty und die eingebauten check-* Funktionen. Ansonsten dürfen Sie nur selbst definierte Funktionen aufrufen.
(list-flat l) klopft die Liste l flach. Sie dürfen zusätzlich die eingebaute Funktion append benutzen.
Verwenden Sie als Typ des Funktionsparameters:
; [X] Nested-List-of X is one of:
; - X
; - (list-of (Nested-List-of X))
Beispiel:
(list-flat (list (list 1) 2 (list (list 3 4) 5) (list (list empty)))) ->* (list 1 2 3 4 5)
\ No newline at end of file
xquery version "1.0";
import module namespace aa='https://plt.bitbucket.io/autoassess' at 'DrRacketFunctions.xqy';
declare variable $funName := "list-flat";
declare variable $funParameterTypes := ("\(\s*nested-list-of\s+X\s*\)");
declare variable $funReturnType := "\(\s*list-of\s+X\s*\)";
declare variable $funDecl := aa:funDecl($funName, count($funParameterTypes), true(), /drracket);
declare variable $allowed := ('empty?', 'cons', 'first', 'rest', 'cons?', 'equal?', 'define', 'cond', 'if', 'else', 'and', 'or', 'not', 'list', 'append',
'modname', 'read-case-sensitive', 'teachpacks', 'lib', 'htdp-settings', '#t', '#f',
//paren/terminal[@value="define"]/following-sibling::paren[1]/terminal[1]/attribute::value/string(),
//paren/terminal[@value="define"]/following-sibling::node()[1]/self::terminal[1]/attribute::value/string());
aa:assertPresent(
"Es ist nicht das korrekte Sprachniveau ('beginner' oder 'beginner with list abbreviations') eingestellt oder Teachpacks fehlen ('universe', 'image').",
(aa:studentLanguage("beginner-abbr", ('"image.rkt"', '"universe.rkt"'), /drracket),
aa:studentLanguage("beginner", ('"image.rkt"', '"universe.rkt"'), /drracket))),
aa:assertTrue(
"Eckige Klammern sind nur für die Fälle von cond-Ausdrücken erlaubt.",
aa:squareParensOnlyInCond(/drracket)),
aa:assertTrue("Geben Sie Fälle von cond-Ausdrücken in eckigen Klammern an",
aa:condCasesSquare(/drracket)),