This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-03
Channels
- # admin-announcements (8)
- # beginners (99)
- # boot (60)
- # cider (44)
- # cljs-dev (47)
- # cljsrn (68)
- # clojure (223)
- # clojure-art (1)
- # clojure-russia (190)
- # clojure-sg (9)
- # clojure-uk (2)
- # clojurecup (1)
- # clojurescript (59)
- # clojurex (3)
- # core-async (43)
- # core-typed (2)
- # cursive (18)
- # datavis (7)
- # datomic (16)
- # events (2)
- # funcool (3)
- # hoplon (3)
- # jobs (1)
- # lein-figwheel (10)
- # leiningen (6)
- # off-topic (1)
- # om (123)
- # onyx (57)
- # parinfer (16)
- # portland-or (2)
- # random (1)
- # re-frame (4)
- # reagent (7)
- # remote-jobs (1)
- # spacemacs (12)
@rantingbob: I have clojure code modifying a polygon mesh using the http://thi.ng library output to an X3D file that I'm uploading to my Shapeways account where they render the file, which I'm simply saving as a jpg file. You can view/manipulate the model using the Shapeways 3D tools here: https://www.shapeways.com/model/3dtools/4108313/1/26?key=693ebbbc85d333d8708ec57a96dff6e2
Thats really cool, thank you
Glad you like it. I'm having a lot of fun making them. You can see a bunch of them on my profile page on Shapeways here: https://www.shapeways.com/designer/pkobrien
All my code is on github here: https://github.com/pkobrien/cad
Might have to change that description since I'm not really using OpenSCAD anymore as I can do more by manipulating a mesh directly in Clojure and outputting to X3D.
Here's one in silver. Don't ask what it would cost to actually print it.
https://images3.sw-cdn.net/model/picture/625x465_4093153_13239119_1449113030.jpg
How well do they print out?
@rantingbob: I have no idea. I haven't gotten any of them printed yet. None of them are actually for sale. I'm still working on my process. These are just baby steps.
@meow: What's the end goal, or is it just for fun?
I just need to sell one of these and I'll be set: https://images4.sw-cdn.net/model/picture/625x465_4088521_13239589_1449116396.jpg
Or a million of these: https://images4.sw-cdn.net/model/picture/625x465_4088521_13160630_1448989545.jpg
That gold one is beautiful
Im trying to find out where this error message is coming from : CompilerException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long, of this code : https://www.refheap.com/112295. Anyone who can give me a hint where the problem is
@roelof: apply's last arg should be a sequence.
@andy.fingerhut: thanks, I deleted apply and everything seems to work fine
any remarks : https://www.refheap.com/112297 from the experts
@roelof: A minor comment is that if you wanted to change your code to allow a variable number of args as the name 'args' implies, you could put the 'apply' back in, and change process-user-action args to [action & args]
...or call it like (process-user-action :deposit [200])
.
The body of the deposit function could be changed to (update amount :amount + deposit-amount)
.
@henriklundahl: oke, I Always thought that only swap could change the contents of a stom
@andy.fingerhut: as I meant it args can only be 1 number
Well, the update function doesn't really change anything. The code I proposed does exactly what your function does.
and I did not know update as function exist. The clojure programming book makes no mention of it
I believe it was added in Clojure 1.7.0. Before that there was update-in.
(update-in amount [:amount] + deposit-amount)
swap! is something else. It's for changing atoms. update and update-in just returns a new map.
So you need swap! in process-user-action, but not in deposit or withdraw.
Now I can think of how I make it work that the atom is updated and a description is added
Thanks for bringing update
to my attention, @henriklundahl. I always hated my solution of (update-in coll [:one-key] f)
😄
@arohner: replying to yesterday's question: yes, clojure core is AOT compiled with direct linking on (since 1.8.0-alpha3)
does anyone have a link handy where I'd be able to read about the work that's going into 1.8?
@clark: http://dev.clojure.org/jira/secure/ReleaseNote.jspa?projectId=10010&version=10254
@matt @birdspider awesome, thank you!
My first polygon mesh model is now available here: http://shpws.me/L0c3
Or in Platinum: https://images2.sw-cdn.net/model/picture/625x465_4110302_13243544_1449152760.jpg
@marvotron: tyvm
@clark you can always find the latest change log at https://github.com/clojure/clojure/blob/master/changes.md
@alexmiller: perfect, thank you!
If I use atom for a very simple accounting app. Schould I store the transitions into a map
@ajmagnifico: no problem. Can happen
@ajmagnifico: You can delete messages.
lol, thanks @exupero
such amazing technology!
@roelof I'd use a vector. Unless a time stamp is your map key.
I have this in my mind at the moment { :date 01-02-2015 :description "taken from the bank" :amount 100 :transaction-sort: "withdraw}
Seems fine. I'd probably do -100. Then you could sum the amounts in order to see a balance at a given point.
@jeff.engebretsen: thanks
@roelof: https://github.com/clj-time/clj-time is a good library for dates
@cfleming: that one starts as a hexahedron, then conway kis'd, then catmull-clark three times, then another conway kis, then colorized by the face normal
maths is pretty
the fun for me is to take these known algorithms, expose all of their parameters (or take a callback function that can do whatever the heck it wants) and then run through strange combinations of values and out come unexpected results - many are ugly, over time I can usually get it to settle on something that I like
catmull-clark is really nice, but also a bit heavy-handed - 3 seems to be the magic number before it just produces something indistinguishably smoother or a sphere
yeah. i remember being utterly floored by the demo scene back before we had GUI OSes
the amazing amount of things they could pack into a meg or two, considering there were ZERO frameworks or anything. a great example of embracing constraints for creativity
so I recently came up with a different algorithm that maintains the bounding box of the original shape and doesn't move so much towards a sphere and it creates some really intriguing results - plus the parameters make a big difference so I can, for example, run it three times but each time with different parameters to get really controlled results within its basic mode of operation
I've rewritten the catmull-clark one time already from the version that comes with http://thi.ng and I'm about to rewrite it again and make it parameterized so I can mess with how it works
Yeah, just yesterday I rendered all my designs on shapeways in different materials so that you can see how the shapes look without color and how the color is really adding more depth and interest than actually exists in the basic topology.
i love the normals-decides-colour trick
there are so many directions I want to go with coloring and I just have to keep putting that off to work on the mesh operators for now
the color is just a function that gets passed the mesh and the face, so the sky is the limit on how the color is determined
I have one version the blends the color based on the face's neighbors -like cellular automata life rules
distance from camera, distance from mouse, combination of the two, etc
but it could use the distance from the centroid of the mesh, or distance from anything or averages or whatever
I'm applying the color to the face of the polygon - how it gets rendered is done on Shapeway's servers.
ohh i see
Their rendering is supposed to simulate the materials they have available via their 3D printing service.
These are meant to be printed objects. I'm conforming to all their printing restrictions.
i’d love to see a material that changes colours based on ‘normals’
that’s awesome, though. you planning to have some printed?
bazinga
made with maths and lisp and love
Actually, its kinda hard to stop spinning them around and zooming in and out. It's addicting.
nothing. think of it as the 27th character of the alphabet
pvinis: in the context of a macro unsplice
`(let [foo# ....])
ending with a # has a specific meaning (auto-generated symbol), but outside the unsplice it doesn'tok so im trying go model a card game, and wanna generate the deck. i have this (map (fn [n] (suit-card :hearts n)) (range 1 14))
which generates all hearts
i tried to do this (map (fn [s] (map (fn [n] (suit-card s n)) (range 1 14))))
but i get a fn back
so i guess map in map is a bit weird?
Are you passing the suits to the outer map?
@jeff.engebretsen: thanks… duh
Did that fix it?
i am not used to clojure yet, so i just closed all parens, without putting the suits there
I'm confused why it returned a fn instead of throwing an Arity exception.
(for [rank (concat (range 1 11) [:jack :queen :king]) suit [:spade :club :diamond :heart]] [rank suit])
You can do nested for's that way?!
hi all, is there anyway on the CLI to get a list of all possible flags for new project? (luminus in my case)
Collections are iterated in a nested fashion, rightmost fastest,
and nested coll-exprs can refer to bindings created in prior
binding-forms.
np. And if you are just getting started, make sure you know about shuffle
for handling a card game.
I guess I can just look at the source https://github.com/luminus-framework/luminus-template/blob/master/src/leiningen/new/luminus.clj
ugh or the docs http://www.luminusweb.net/docs/profiles.md
ok and now for a bit of testing. i have a vec of hands i wanna test. how can i test all of them together? so instead of 10 (is (single? hand1))
, can i have something like a map to that?
pvinis, you could maybe use (doseq)
for that, which is similar to (for)
but just executes its body for side effects (like is
)
So like (doseq [hand all-hands] (is (single? hand)))
Another approach would be (map (fn [h] (is (single? h)) all-hands)
Or (map #(is (single? %)) all-hands)
Personally I like doseq
for that kind of thing because it gives me a heads-up to look for side effects
One thing is you can simplify (map (fn [card] (:rank card)) trick)
to (map :rank trick)
which is a little easier to read
I'm not sure that function does what you intend it to do either, if I'm reading right after (set)
you'd have #{ 4 }
I like that ok
so i thought, check the number of cards, and take all the ranks and see if its the same for all
I think that works if you only ever have 3 cards, but it would also return true for 7 cards
Oh, I see, right
Sorry, missed that bit
i want to chck if numbers in a seq are continious, is that close? (reduce (fn [a b] (= (inc a) b)) (list 4 5 6))
Is there a generalization of this pattern I find myself repeating a lot:
(into {} (for [item coll] [item (somefunc item)]))
was going to code something like (defn into-map [coll f] (into {} (for [item coll] [item (f item)])))