dharmik,
@dharmik@mathstodon.xyz avatar

Even-odd function in lisp to make your day.

dharmik,
@dharmik@mathstodon.xyz avatar

Trying things I've done for Java in my class is more fun in Lisp.

dharmik,
@dharmik@mathstodon.xyz avatar

Swapping using a temporary variable in Lisp.

screwtape,
@screwtape@mastodon.sdf.org avatar

@dharmik pretty cool, do you mind if I think out loud about these examples on the #lispyGopher #climate tomorrow?

louis,
@louis@emacs.ch avatar

@dharmik @screwtape

If you don't mind, the more elegant form to swap values (without the need to create a tmp symbol) is parallel assignment:

(psetq a1 a2 a2 a1)

There is also psetf, in case you need that.

zyd,
@zyd@emacs.ch avatar

@louis @dharmik @screwtape

rotatef is also fun.

As a verbose example:

(defvar a 'a-value)<br></br>(defvar b 'b-value)<br></br>(rotatef a b)<br></br>
  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • magazineikmin
  • cubers
  • InstantRegret
  • cisconetworking
  • Youngstown
  • vwfavf
  • slotface
  • Durango
  • rosin
  • everett
  • kavyap
  • thenastyranch
  • mdbf
  • megavids
  • khanakhh
  • modclub
  • tester
  • ethstaker
  • osvaldo12
  • GTA5RPClips
  • ngwrru68w68
  • Leos
  • anitta
  • tacticalgear
  • normalnudes
  • provamag3
  • JUstTest
  • All magazines