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

Record lookup across sequences. #1561

Closed
smithnormform opened this issue Jan 28, 2022 · 1 comment
Closed

Record lookup across sequences. #1561

smithnormform opened this issue Jan 28, 2022 · 1 comment

Comments

@smithnormform
Copy link

Is there a syntactic sugar for creating a sequence of elements corresponding to a particular field in a sequence of records. For example, the following syntax works in Cryptol, but not in SAW:

sawscript> print [{a = 1, b = true}, {a = 2, b = false}].a

Thank you!

@brianhuffman
Copy link
Contributor

We don't have any syntactic sugar like that in saw-script at the moment. One possible workaround is to define a saw-script map function, and then use that to map a field projection over all the elements of a list.

rec map f xs = if null xs then [] else concat [f (head xs)] (map f (tail xs));

@jldodds jldodds closed this as completed Feb 21, 2022
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

3 participants