{"action":"created","issue":{"url":"https://api.github.com/repos/leftiness/hex_math/issues/49","repository_url":"https://api.github.com/repos/leftiness/hex_math","labels_url":"https://api.github.com/repos/leftiness/hex_math/issues/49/labels{/name}","comments_url":"https://api.github.com/repos/leftiness/hex_math/issues/49/comments","events_url":"https://api.github.com/repos/leftiness/hex_math/issues/49/events","html_url":"https://github.com/leftiness/hex_math/issues/49","id":181837345,"number":49,"title":"Figure out point iterations","user":{"login":"leftiness","id":6913467,"avatar_url":"https://avatars.githubusercontent.com/u/6913467?v=3","gravatar_id":"","url":"https://api.github.com/users/leftiness","html_url":"https://github.com/leftiness","followers_url":"https://api.github.com/users/leftiness/followers","following_url":"https://api.github.com/users/leftiness/following{/other_user}","gists_url":"https://api.github.com/users/leftiness/gists{/gist_id}","starred_url":"https://api.github.com/users/leftiness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leftiness/subscriptions","organizations_url":"https://api.github.com/users/leftiness/orgs","repos_url":"https://api.github.com/users/leftiness/repos","events_url":"https://api.github.com/users/leftiness/events{/privacy}","received_events_url":"https://api.github.com/users/leftiness/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-08T17:11:38Z","updated_at":"2016-10-15T15:45:36Z","closed_at":null,"body":"I wrote a HasValues#into_vec(). I'm not so sure that's the proper solution here.\r\n\r\nFor example, the work I'm doing for ray() has a step where I need to do A + B * C where A: i32, B: f32, C: f32 for each element of three structs (A, A, A, A), (B, B, B, B), (C, C, C, C). So A0 + B0 * C0, A1 + B1 * C1, etc.\r\n\r\nI can't use HasValues#into_vec() here even if I wanted to. This isn't a HasValues. It's a tuple of f32.\r\n\r\nHere's some primitive work:\r\n\r\n```rust\r\npub fn merge<T, U, V, W>(\r\n  a: (T, T, T, T),\r\n  b: (U, U, U, U),\r\n  op: V,\r\n) -> (W, W, W, W) where V: Fn(T, U) -> W {\r\n  (op(a.0, b.0), op(a.1, b.1), op(a.2, b.2), op(a.3, b.3))\r\n}\r\n\r\npub fn map<T, U, V>(\r\n  a: (T, T, T, T),\r\n  op: U,\r\n) -> (V, V, V, V) where U: Fn(T) -> V {\r\n  (op(a.0), op(a.1), op(a.2), op(a.3))\r\n}\r\n\r\npub fn main() {\r\n\r\n  let a = (1, 1, 1, 1);\r\n  let b = (2.5f32, 1f32, 2.5f32, 2.5f32);\r\n  let op = |x, y| x as f32 == y;\r\n  let result = merge(a, b, op);\r\n\r\n  println!(\"{:?}\", result);\r\n\r\n  println!(\"{:?}\", map(a, |x| x as f32 + 1.5f32));\r\n\r\n}\r\n```\r\n\r\nI don't like that either. I'd have to write a lot of functions, and I'd have to duplicate the work for tuples of three, tuples of four... Just no.\r\n\r\nSo maybe a HasValues should be different. It could be a struct which is backed by a private vector. I don't want someone adding or removing or even altering values in this vector. If I give someone access to it, I would just provide an iterator and let them do map(), collect(), etc.\r\n\r\nThis HasValues would need to be `HasValues<T>`. It would impl `From<(T, T, T, T)>`.\r\n\r\nMaybe it wouldn't even be the HasValues trait but maybe more of a struct. It could still implement HasValues. So... maybe this work would be done on the Point struct. With the ability to provide a function for mapping, I could iterate over a `Point<f32>`, convert from f32 to i32, and collect back into a `Point<i32>`.\r\n\r\nIdk though. I kind of appreciate the idea of having a Point.q property, but at the same time I've been using point.values() and stuff like that. I'm not even using that Point.q property."},"comment":{"url":"https://api.github.com/repos/leftiness/hex_math/issues/comments/253992105","html_url":"https://github.com/leftiness/hex_math/issues/49#issuecomment-253992105","issue_url":"https://api.github.com/repos/leftiness/hex_math/issues/49","id":253992105,"user":{"login":"leftiness","id":6913467,"avatar_url":"https://avatars.githubusercontent.com/u/6913467?v=3","gravatar_id":"","url":"https://api.github.com/users/leftiness","html_url":"https://github.com/leftiness","followers_url":"https://api.github.com/users/leftiness/followers","following_url":"https://api.github.com/users/leftiness/following{/other_user}","gists_url":"https://api.github.com/users/leftiness/gists{/gist_id}","starred_url":"https://api.github.com/users/leftiness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leftiness/subscriptions","organizations_url":"https://api.github.com/users/leftiness/orgs","repos_url":"https://api.github.com/users/leftiness/repos","events_url":"https://api.github.com/users/leftiness/events{/privacy}","received_events_url":"https://api.github.com/users/leftiness/received_events","type":"User","site_admin":false},"created_at":"2016-10-15T15:45:36Z","updated_at":"2016-10-15T15:45:36Z","body":"Arrays. Arrays are obviously the answer. An array is an immutable collection of values with a length defined in the type declaration. All elements of an array are the same type. You can `array.iter().map()`. `point.array().iter().map()`. `impl From<[i32;3]> for Point`."}}
{"actor":{"display_login":"leftiness"}}