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
Haskell-style map function for ACSets #352
Conversation
@epatters btw this is ready to be reviewed. |
Cool, thanks. I'll review it soon. |
Thanks Owen. Two questions/comments:
Putting these suggestions together, I would imagine an API supporting examples like map(g::WeightedGraph{Symbol}, weight = s -> Int(s[1])) # `weight` attribute only
map(g::WeightedGraph{Symbol}, Weight = s -> Int(s[1])) # all attributes with codomain `Weight`
map(g::RelationDiagram{Symbol}, name = titlecase∘string, variable = uppercase∘string) What do you think? |
OK, so I guess then there is an error if you don't correctly map all of the attributes to a new type? Yeah, can do! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Owen, I think this method will be very useful.
_map(acs, fns) | ||
end | ||
|
||
function sortunique!(x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice if this were built into Julia. I call unique!(sort!(x))
all over the codebase.
Awesome, merging now. |
Pretty simple, basically:
All attributes with a given codomain get converted using the supplied function. Partly addresses AlgebraicJulia/ACSets.jl#7.