Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
30
Task/XML-Input/Lasso/xml-input-1.lasso
Normal file
30
Task/XML-Input/Lasso/xml-input-1.lasso
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// makes extracting attribute values easier
|
||||
define xml_attrmap(in::xml_namedNodeMap_attr) => {
|
||||
local(out = map)
|
||||
with attr in #in
|
||||
do #out->insert(#attr->name = #attr->value)
|
||||
return #out
|
||||
}
|
||||
|
||||
local(
|
||||
text = '<Students>
|
||||
<Student Name="April" Gender="F" DateOfBirth="1989-01-02" />
|
||||
<Student Name="Bob" Gender="M" DateOfBirth="1990-03-04" />
|
||||
<Student Name="Chad" Gender="M" DateOfBirth="1991-05-06" />
|
||||
<Student Name="Dave" Gender="M" DateOfBirth="1992-07-08">
|
||||
<Pet Type="dog" Name="Rover" />
|
||||
</Student>
|
||||
<Student DateOfBirth="1993-09-10" Gender="F" Name="Émily" />
|
||||
</Students>
|
||||
',
|
||||
xml = xml(#text)
|
||||
)
|
||||
|
||||
local(
|
||||
students = #xml -> extract('//Student'),
|
||||
names = array
|
||||
)
|
||||
with student in #students do {
|
||||
#names -> insert(xml_attrmap(#student -> attributes) -> find('Name'))
|
||||
}
|
||||
#names -> join('<br />')
|
||||
11
Task/XML-Input/Lasso/xml-input-2.lasso
Normal file
11
Task/XML-Input/Lasso/xml-input-2.lasso
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// not using XML or Xpath
|
||||
'<hr />'
|
||||
local(
|
||||
regexp = regexp(-find = `<Student.*?Name="(.*?)"`, -input = #text, -ignoreCase),
|
||||
names = array
|
||||
)
|
||||
|
||||
while( #regexp -> find) => {
|
||||
#names -> insert(#regexp -> matchstring(1))
|
||||
}
|
||||
#names -> join('<br />')
|
||||
Loading…
Add table
Add a link
Reference in a new issue