Skip to content
New issue

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

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

Already on GitHub? # to your account

convenience method for lossy conversion of lists to vectors #15

Open
trevor opened this issue May 15, 2013 · 0 comments
Open

convenience method for lossy conversion of lists to vectors #15

trevor opened this issue May 15, 2013 · 0 comments

Comments

@trevor
Copy link

trevor commented May 15, 2013

It would be handy to have a settable flag to convert lists to vectors if that level of detail isn't needed. For example:

puts YAML.dump EDN.read('[1 (2 [3 4] #{5 6} {:a 7 :b 8})]')
puts
puts
puts YAML.dump EDN.read('[1 [2 [3 4] #{5 6} {:a 7 :b 8}]]')

---
- 1
- !ruby/array:EDN::Type::List
  - 2
  - - 3
    - 4
  - !ruby/object:Set
    hash:
      5: true
      6: true
  - :a: 7
    :b: 8


---
- 1
- - 2
  - - 3
    - 4
  - !ruby/object:Set
    hash:
      5: true
      6: true
  - :a: 7
    :b: 8

Currently this behavior can be invoked with a one-line change of line 37 in lib/edn/transform.erb:

rule(:list => subtree(:array)) { EDN::Type::List.new(*array) }

to:

rule(:list => subtree(:array)) { array }
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant