Skip to content

Commit

Permalink
Merge pull request #13 from robertluo/11-vector
Browse files Browse the repository at this point in the history
change vector's implementation to array
  • Loading branch information
robertluo authored Aug 4, 2019
2 parents ef00296 + dde98c1 commit d57f4f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/Edn.Net/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Edn =
| EBool of bool
| EKeyword of Keyword
| ESymbol of Keyword
| EVector of Edn list
| EVector of Edn array
| ESet of Set<Edn>
| EMap of Map<Edn, Edn>
| EUuid of System.Guid //to support builtin uuid
Expand All @@ -40,7 +40,7 @@ type Edn =
| ESymbol v -> "'" + v.ToString()
| EVector v ->
v
|> List.map (fun i -> i.ToString())
|> Array.map (fun i -> i.ToString())
|> String.concat ", "
|> sprintf "[%s]"
| ESet v ->
Expand Down Expand Up @@ -164,7 +164,7 @@ module Edn =

let listBetween sopen sclose pElement f =
between (str sopen) (str sclose) (ws >>. many (pElement .>> ws) |>> f)
let evector = listBetween "[" "]" evalue EVector
let evector = listBetween "[" "]" evalue (List.toArray >> EVector)
let eset = listBetween "#{" "}" evalue (Set.ofList >> ESet)
let keyValue = evalue .>>. (ws >>. evalue)
let emap = listBetween "{" "}" keyValue (Map.ofList >> EMap)
Expand Down Expand Up @@ -213,7 +213,7 @@ type Edn with
|> EKeyword

/// Shortcut for creating EVector from an array
static member VecOf(elems) = List.ofArray elems |> EVector
static member VecOf(elems) = EVector elems

/// Shortcut for creating ESet from an array
static member SetOf(elems) = Set.ofArray elems |> ESet
Expand Down
4 changes: 2 additions & 2 deletions test/Edn.Net.Test/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ let test2 =
let input =
EMap(Map.ofList [ (EKeyword { Ns = Some "foo"
Name = "bar" },
EVector [ EFloat 35.1
EBool false ])
Edn.VecOf [| EFloat 35.1
EBool false |])
(EKeyword { Ns = None
Name = "a" }, ENull) ])

Expand Down

0 comments on commit d57f4f4

Please sign in to comment.