This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-07-31
Channels
- # admin-announcements (23)
- # announcements (3)
- # beginners (59)
- # boot (122)
- # clojure (117)
- # clojure-berlin (3)
- # clojure-dev (3)
- # clojure-italy (3)
- # clojure-japan (10)
- # clojure-russia (69)
- # clojurebridge (12)
- # clojurescript (183)
- # clojutre (14)
- # code-reviews (4)
- # core-async (79)
- # core-logic (18)
- # core-matrix (1)
- # cursive (7)
- # datascript (1)
- # datomic (18)
- # editors (3)
- # events (18)
- # hoplon (20)
- # ldnclj (24)
- # luminus (1)
- # off-topic (1)
- # other-lisps (1)
- # re-frame (12)
- # reagent (104)
Is there a function or macro that takes a vector and returns the elements of that vector?
e.g. I have [[1 2] [3 4]]
And I want [1 2] [3 4]
@surreal.analysis: How can a function return multiple things?
I should say just a macro
In many Clojure libraries, e.g. Hiccup, Reagent, clj-pdf, vectors are used to represent the data
In my case, I am using clj-pdf
In both Hiccup and Reagent, you have to pass them a single data structure, and they return a single data structure.
I suppose my issue is, right now, I’m not sure what that data structure would be in clj-pdf
As far as I can tell, there is no div
equivalent
So what I would like is essentially three or four data structures in a row
And I’m not sure how to group them
But perhaps I’m just misusing the library
For example, I remember once that I wanted a function that returns all of the :li
s for a :ul
, so what you’re saying would be useful. But it turned out that I was thinking about it wrong. I needed to have the thing generating the :ul
create all of the :li
s.
I agree, I’m almost certainly thinking about it incorrectly
But I’m not sure how to thing about it correctly
So, here is an example http://stackoverflow.com/questions/23456672/templating-in-clj-pdf
And I want to do something pretty similar to that
Except, instead of returning a paragraph
I want to generate a PDF table and a paragraph
So my employee-template looks more like
(template
[:pdf-table …]
[:paragraph …]
)
Now, that’s wrong, because template takes 1 argument
So my first path towards solving this issue was wrapping it in a vector
(template
[[:pdf-table ..]
[:paragraph ..]]
)
Thinking that if I had that, I could make it work from there
Which prompted the original question
Hi all, am I using trampoline correctly here?
I’m trying to wrap my head around recursion in functional style languages and how to use trampoline so there’s no stackoverflow
in this example, I’m trying to convert a tree like structure like {:a {:b “1” :c “2”}}
into something like [[:a :b “1”] [:a :c “2”]]
@surreal.analysis: Sorry for taking all day. Got caught up.
Yeah, the accepted answer to that stackoverflow question pretty much sums up what I was saying.
Regarding your issue, so you want a function that returns a table followed by a paragraph?
If they’re siblings and can’t be wrapped, I don’t know of any other way besides specifying them side-by-side. However, if that’s the case, I would question whether or not they truly need to be abstracted away.
@potetm: Yes, they are siblings
re: using a template, the benefit of the template is that templates can easily be applied to collections
I ended up fixing it by wrapping them in a pdf-table
But that’s kind of ugly
Because it’s not really a table
Just siblings
@surreal.analysis: And there’s no kind of container for this whole thing?
Not to the best of my knowledge
so you have a list of things that are: [:table][:paragraph]
. There has to be some kind of parent….
pdf
is a function (or macro) that takes a vector of elements
Thanks, that pointed me enough in the right direction
Something like that might work
But what I ended up doing
Is having the template return a vector
of [[:table] [:paragraph]]
And then just applied concat to that
Thanks!