Re: [racket-users] Why are hash and make-hash not symmetric?
Thank you, Spencer and Matthew both. That gives me enough to go on with. On Wed, Dec 7, 2016 at 9:59 AM, Matthew Flattwrote: > Maybe there's some technical reason that I've forgotten, but I think > it's just that `hash` is newer and was an experiment toward a better > interface. A `mutable-hash` function would make sense, as far as I can > tell. > > Meanwhile, something like `(hash-copy (hash 'a 1 'b 2))` might be the > most convenient option right now. > > At Wed, 7 Dec 2016 08:49:42 -0800, David Storrs wrote: > > -> (hash 'a 1 'b 2) > > '#hash((a . 1) (b . 2)) > > > > -> (make-hash '((a . 1) (b . 2))) > > '#hash((b . 2) (a . 1)) > > > > -> (make-hash 'a 1 'b 2) > > (make-hash 'a 1 'b 2) > > ; make-hash: arity mismatch; > > ; the expected number of arguments does not match the given number > > ; expected: 0 to 1 > > ; given: 4 > > ; [,bt for context] > > > > Why does 'make-hash' not work like 'hash'? Is it possible that a flag > > could be added that would *make* it work like hash? Or, alternatively, > > does another function exist that will create a mutable hash but will > accept > > N arguments the way 'hash' does? I understand that it's not very FP to > use > > mutation but there are certain problems that are easier that way. > > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Why are hash and make-hash not symmetric?
Maybe there's some technical reason that I've forgotten, but I think it's just that `hash` is newer and was an experiment toward a better interface. A `mutable-hash` function would make sense, as far as I can tell. Meanwhile, something like `(hash-copy (hash 'a 1 'b 2))` might be the most convenient option right now. At Wed, 7 Dec 2016 08:49:42 -0800, David Storrs wrote: > -> (hash 'a 1 'b 2) > '#hash((a . 1) (b . 2)) > > -> (make-hash '((a . 1) (b . 2))) > '#hash((b . 2) (a . 1)) > > -> (make-hash 'a 1 'b 2) > (make-hash 'a 1 'b 2) > ; make-hash: arity mismatch; > ; the expected number of arguments does not match the given number > ; expected: 0 to 1 > ; given: 4 > ; [,bt for context] > > Why does 'make-hash' not work like 'hash'? Is it possible that a flag > could be added that would *make* it work like hash? Or, alternatively, > does another function exist that will create a mutable hash but will accept > N arguments the way 'hash' does? I understand that it's not very FP to use > mutation but there are certain problems that are easier that way. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Why are hash and make-hash not symmetric?
For symmetry there is "make-immutable-hash", which is like "hash" but has the interface of "make-hash". (I don't know why "hash" is the way it is though). --spencer On Wed, Dec 7, 2016 at 10:49 AM David Storrswrote: > -> (hash 'a 1 'b 2) > '#hash((a . 1) (b . 2)) > > -> (make-hash '((a . 1) (b . 2))) > '#hash((b . 2) (a . 1)) > > -> (make-hash 'a 1 'b 2) > (make-hash 'a 1 'b 2) > ; make-hash: arity mismatch; > ; the expected number of arguments does not match the given number > ; expected: 0 to 1 > ; given: 4 > ; [,bt for context] > > Why does 'make-hash' not work like 'hash'? Is it possible that a flag > could be added that would *make* it work like hash? Or, alternatively, > does another function exist that will create a mutable hash but will accept > N arguments the way 'hash' does? I understand that it's not very FP to use > mutation but there are certain problems that are easier that way. > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] Why are hash and make-hash not symmetric?
-> (hash 'a 1 'b 2) '#hash((a . 1) (b . 2)) -> (make-hash '((a . 1) (b . 2))) '#hash((b . 2) (a . 1)) -> (make-hash 'a 1 'b 2) (make-hash 'a 1 'b 2) ; make-hash: arity mismatch; ; the expected number of arguments does not match the given number ; expected: 0 to 1 ; given: 4 ; [,bt for context] Why does 'make-hash' not work like 'hash'? Is it possible that a flag could be added that would *make* it work like hash? Or, alternatively, does another function exist that will create a mutable hash but will accept N arguments the way 'hash' does? I understand that it's not very FP to use mutation but there are certain problems that are easier that way. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.