Discussion
Loading...

#Tag

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Jamie in Cuckooland
@jamie@zotum.net  ·  activity timestamp 4 days ago

I'll either rewrite this to be easier to understand or provide more commentary or both in the near future. An org-mode literature program maybe?

#tem25 #elisp

  • Copy link
  • Flag this post
  • Block
Eduardo Mercovich (él)
@edumerco@social.coop  ·  activity timestamp 4 days ago

Dear #emacs and #org-mode comrades.
Given:
+ a table w/ a list of tags + their # of appearances per question 1 & 2.
+ org support for tag groups (https://orgmode.org/manual/Tag-Hierarchy.html)
+ GroupTag1=tagA+tagC+tagD and
+ GroupTag2=tagB+tagE

How can I count the sum of each group per question?
Example:
| tag | Q1 | Q2 |
|------+----+----|
| tagA | 9 | |
| tagB | 4 | 2 |
| tagC | 1 | 4 |
| tagD | | 5 |
| tagE | | 6 |
|------+----+----|
| GT1 | 10 | 9 |
| GT2 | 4 | 9 |
Thanks!
#tem25

Jamie in Cuckooland
@jamie@zotum.net replied  ·  activity timestamp 4 days ago

@Eduardo Mercovich (él)

Well, I got this much working, which is sort of the crux of the problem.  It takes a list of pairs and a function and applies the function repeatedly to the cdrs of the pairs that share the same car.

Roger has shown an expanded version of the table where the groups have been put against the values that apply to them.  The last two columns of that table should be able to be turned into an appropriate list easily enough - I have not attempted this yet.

I'm in two minds about this as a solution for you.  

On the one hand it's short, and has some general applicability beyond the stated problem.  

On the other, I may be being a bit too clever - not quite 'week 1 of Lisp' material I suppose. Sticking to explicit iteration and solving the specific problem only would be more digestible.  But this is the concrete thing that I got to first.

On the other other hand - I'm wondering whether there are library functions available to do this with fewer lines that I'm ignorant of.


Plus the use of the lambda in the application is a bit clunky - might be nicer to just pass + in (could just put in another layer of wrapping to do this).  

And the function names might need some further thought...

But I thought I'd table it anyway — might be good to see some progress and perhaps it will inspire others to do better 😄

(defun assoc-replace (new alist)
  "non-destructively replace the alist element with new, where the keys are equal"
  (cl-substitute-if new
            (lambda (x)
              (equal (car x) (car new)))
            alist))


(defun alist-acummulate-step (f alist pair)
  "lookup alist using car pair and replace the element with f applied to the cdrs of it and pair. Add pair to alist if not found."
  (let* ((key (car pair))
(old-pair (assoc key alist)))
    (cond
(old-pair
      (let ((result (funcall f (cdr old-pair) (cdr pair))))
        (assoc-replace (list key result) alist)))
(t
      (cons pair alist)))))

(defun alist-reduce (f pairs alist-initial)
  "reduce using f into an alist with keys as the unique cars of pairs"
  (seq-reduce
(lambda (x y) (alist-acummulate-step f x y))
pairs alist-initial))

Example of use:
(alist-reduce (lambda (x y) (+ (car x) (car y))) '((a 1) (b 2) (a 3) (c 4) (b 3) (b 4)) nil)
=>
((c 4) (b 9) (a 4))



#tem25 #elisp

  • Copy link
  • Flag this comment
  • Block
Paolo Amoroso
@amoroso@oldbytes.space  ·  activity timestamp 2 weeks ago

Avalonia Visual Basic 6 is a recreation of the Visual Basic 6 IDE that also runs in the browser. It looks quite close to the original.

https://github.com/BAndysc/AvaloniaVisualBasic6

https://bandysc.github.io/AvaloniaVisualBasic6/

#VisualBasic #retrocomputing #windows

Karsten Johansson
@ksaj@infosec.exchange replied  ·  activity timestamp 2 weeks ago
@amoroso I've never understood why you can't do that in Lisp via emacs.

If someone proves me wrong (I could be!) it'll greatly improve my opinion of emacs.

#lisp #commonlisp #elisp #emacs

  • Copy link
  • Flag this comment
  • Block
Eugene :freebsd: :emacslogo:
@evgandr@mastodon.bsd.cafe  ·  activity timestamp 2 weeks ago
#TIL that Emacs ELisp version of sudo may be extremely slow and hang an Emacs if my real hostname (set in /etc/rc.conf) doesn't match with lines for localhost in /etc/hosts drgn_shocked

#Emacs #elisp

  • Copy link
  • Flag this post
  • Block
Eduardo Mercovich (él)
@edumerco@social.coop  ·  activity timestamp 3 weeks ago

What else can I share to better describe the thesis? Some parts that are not clear?

While #orgmode does 85% out of the box (#LiterateProgramming, tagging, counting, writing, exporting, even interacting with #gnuplot, etc.) #elisp is needed to do some of this calculations, ordering and grouping... :)

[end] #tem25

  • Copy link
  • Flag this post
  • Block
dinomug
@miguel@mstdn.mx  ·  activity timestamp 3 weeks ago
@edumerco Mas que elisp puro, en especial por lo que mencionas del apartado de programación literaria y reproducible, es meterle mano a Org-mode.
Eduardo Mercovich (él)
@edumerco@social.coop replied  ·  activity timestamp 3 weeks ago
@miguel

Tb hay partes q implican #elisp y #programacionliteraria. Pej integro 2 tablas con https://github.com/tbanel/orgtbljoin (genio tbanel) y debo ordenarla de forma específica. Se puede crear una función para hacer ése orden, y debe ser en elisp.

  • Copy link
  • Flag this comment
  • Block
Eduardo Mercovich (él)
@edumerco@social.coop  ·  activity timestamp 3 weeks ago

Querides Emacseres.
Necesito ayuda con #elisp para mi tesis (exploración de aprendizajes significativos para operar fuera de la academia) con #ProgramaciónLiteraria + #InvestigaciónReproducible. Y quiero q esté tan autocontenida en #Emacs (sí, soy un geek y estoy orgulloso) como sea posible. Sin embargo y aunque avanzo, encuentro mi elisp fu limitante.
¿Podría alguien ayudarme con esta tesis para mostrar el poder de Emacs y el #SoftwareLibre? Me encantará devolver con mis habilidades.
1e^3.Grcs

  • Copy link
  • Flag this post
  • Block
Eduardo Mercovich (él)
@edumerco@social.coop  ·  activity timestamp 3 weeks ago

Dear Emacsers.
I need some help w/ #elisp for my #LiterateProgramming + #ReproducibleResearch thesis (an exploration of meaningful abilities to operate outside academia).
I'd like it as completely self contained in -and sustained by- #Emacs (yes, I'm a geek and I'm proud) as possible and, while going forward, I've found my #elisp fu limiting.
Can anyone share some time to help me with this thesis and show the power of Emacs and #FreeSoftware? I'd gladly share my abilities back.
1e^3.Thxs

  • Copy link
  • Flag this post
  • Block
Artyom Bologov
@aartaka@merveilles.town  ·  activity timestamp 4 months ago
#Emacs#Lisp ability to provide multiple forms in the else branch (implicit progn) deserves some praise. I often write recursive algorithms that have a simple base case returning a value, and a much more involved recursive else case. Whapping the else into a progn/prog1/begin/do is an annoyance, however small. So #Elisp got this thing right, at least.
  • Copy link
  • Flag this post
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0-rc.2.21 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login