Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Alternative lookup syntax" #5

Open
joewiz opened this issue Aug 5, 2017 · 1 comment
Open

"Alternative lookup syntax" #5

joewiz opened this issue Aug 5, 2017 · 1 comment

Comments

@joewiz
Copy link
Collaborator

joewiz commented Aug 5, 2017

Hi Cliff,

In 03, around line 470, there's this paragraph:

The extra work of finding the size of the array and iterating through its members is actually not necessary when we use the alternative lookup syntax. Can you rewrite this example with the lookup syntax?

I wasn't exactly sure what you meant by "alternative lookup syntax." Did you mean the ? lookup operator? Are you asking the student to write out a more verbose path rather than use map:find()?

Joe

@CliffordAnderson
Copy link
Owner

Hi Joe,

Yes, I had in mind simplifying the expression like so:

let $lookup-word := local:lookup-word(?, $id, $key)
let $definitions := map:find($lookup-word($word), "definitions")
for $definition at $num in $definitions?*
return $num || ". " || $definition

In other words, I wanted to show students that the ?* operator is really a shorthand for iterating through the size of the array and calling a function to return every item in the array. Do you have a suggestion for improving the wording?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants