diff --git a/collects/honu/core/main.rkt b/collects/honu/core/main.rkt index db6134d2f9..0e680c7f95 100644 --- a/collects/honu/core/main.rkt +++ b/collects/honu/core/main.rkt @@ -37,6 +37,7 @@ [honu-map map] [honu-flow \|] [honu-dot |.|] + [honu-string=? string_equal] [honu-cons ::] [honu-and and] [honu-and &&] [honu-or or] [honu-or \|\|] diff --git a/collects/honu/core/private/honu2.rkt b/collects/honu/core/private/honu2.rkt index 4de4baac2f..db0bc67d00 100644 --- a/collects/honu/core/private/honu2.rkt +++ b/collects/honu/core/private/honu2.rkt @@ -170,6 +170,7 @@ (define-binary-operator honu-or 0.5 'left or) (define-binary-operator honu-cons 0.1 'right cons) (define-binary-operator honu-map 0.09 'left map) +(define-binary-operator honu-string=? 1 'left string=?) (define-unary-operator honu-not 0.7 'left not) diff --git a/collects/honu/main.rkt b/collects/honu/main.rkt index d0575841c7..90eb301507 100644 --- a/collects/honu/main.rkt +++ b/collects/honu/main.rkt @@ -22,8 +22,10 @@ null null? length + substring (rename-out [honu-cond cond] [null empty] + [string-length string_length] [racket:empty? empty?] [racket:first first] [racket:rest rest])) diff --git a/collects/tests/honu/linq.honu b/collects/tests/honu/linq.honu index 35624b7db2..efd4c50991 100644 --- a/collects/tests/honu/linq.honu +++ b/collects/tests/honu/linq.honu @@ -30,6 +30,10 @@ loadXml(file){ } } +starts_with(start, what){ + substring(what, 0, string_length(start)) string_equal start +} + var xml = loadXml("test.xml"); printf("xml ~a\n", xml); printf("data: ~a\n", xml.getData()); @@ -48,3 +52,11 @@ printf("addresses ~a\n", addresses); for add in addresses do { printf("name ~a address ~a\n", add.name, add.address); } + +printf("+++\n"); +for xs in linq from foo in xml.Descendants("Table1") + where starts_with("x", foo.Element("familyName").Value()) + select foo.Element("familyName").Value() do { + printf("only x: ~a\n", xs) +} +// printf("---\n"); diff --git a/collects/tests/honu/test.xml b/collects/tests/honu/test.xml new file mode 100644 index 0000000000..7ff696b3d1 --- /dev/null +++ b/collects/tests/honu/test.xml @@ -0,0 +1,22 @@ + + + 3 + x1 +
xa
+
+ + 4 + y1 +
ya
+
+ + 5 + hub +
away
+
+ + 5 + xeno +
banana
+
+