5. Use BASH
|
Author | Content |
---|---|
nmset Jun 29, 2013 6:01 AM EDT |
Just for fun : export z="linux and life";i=0;while [ $i -lt ${#z} ]; do c=${z:i:1}; r=$c$r; i=$((i+1));done; echo $r; unset r; unset i; unset z No external dependency required. |
Jeff91 Jul 01, 2013 10:48 AM EDT |
Whenever I compare doing something in bash and doing it in python... It amazes me that people still use non-python for scripting:text = raw_input("Enter a string: ") print text[::-1] ~Jeff |
gus3 Jul 01, 2013 11:37 AM EDT |
So why not just make Python your shell? |
TxtEdMacs Jul 01, 2013 12:13 PM EDT |
Because it's scaly and slimy. But so pretty designs obviated by it's propensity to bite so fiercely. Any other questions, My August Gus III? |
gus3 Jul 01, 2013 12:14 PM EDT |
What about Perl as a shell? |
nmset Jul 01, 2013 1:28 PM EDT |
The Python way is very smart, one may agree we cannot learn all languages however. It was just funny to play with on a Saturday. |
herzeleid Jul 01, 2013 5:27 PM EDT |
as in the original article: echo "linux and life" | rev pfft. who needs python for this? Of course, if you want to do complicated arbitrary string handling, something other than a standard unix shell might be in order. Edit: Much as I appreciate the precision of python, I can't seem to cozy up to it, while perl just feels right. |
flufferbeer Jul 01, 2013 5:53 PM EDT |
@nmset >> export z="linux and life";i=0;while [ $i -lt ${#z} ]; do c=${z:i:1}; r=$c$r; i=$((i+1));done; echo $r; unset r; unset i; unset z That seems a bit cchaotic. Just for fun, I wonder how it would appear in organized emacs-lisp? Some think that Emacs itself is its own compiler, OS and shell... 2c |
gus3 Jul 02, 2013 2:00 PM EDT |
Quoting:Some think that Emacs itself is its own compiler, OS and shell...Because it is. Being written in Lisp makes possible a lot of advantages, including being a platform for developing its own extensions, then attaching them for use, without having to exit and re-start. I know, not every Lisp program can do all that, but if you're going to develop an editor in Lisp, it only makes sense. |
djohnston Jul 02, 2013 3:18 PM EDT |
Quoting:Some think that Emacs itself is its own compiler, OS and shell... Quoting:Because it is. Its own compiler and shell, yes. Its own OS, no. |
mbaehrlxer Jul 03, 2013 5:27 AM EDT |
can't help with emacs lisp, but here is the common lisp version:(reverse "linux and life") "efil dna xunil" (let ((result)) (loop for char across "linux and life" do (push char result)) (coerce result 'string)) "efil dna xunil" find examples in countless other languages on rosettacode: http://rosettacode.org/wiki/Reverse_a_string (emacs lisp is there too) greetings, eMBee |
gus3 Jul 03, 2013 4:13 PM EDT |
Quoting:Its own compiler and shell, yes. Its own OS, no.Hey, if Firefox is now an OS, can Emacs be far behind? |
djohnston Jul 03, 2013 6:09 PM EDT |
Quoting:Hey, if Firefox is now an OS, can Emacs be far behind? Sure, that's possible. Don't get me wrong. Emacs is one helluva program. But its own OS it's not. Not yet, anyway. |
mbaehrlxer Jul 04, 2013 10:08 AM EDT |
someone tried running emacs on a bare kernel: http://www.informatimago.com/linux/emacs-on-user-mode-linux.... FirefoxOS also uses the linux kernel. neither solution goes as far as SqueakNOS which runs squeak on bare hardware. greetings, eMBee. |
Posting in this forum is limited to members of the group: [ForumMods, SITEADMINS, MEMBERS.]
Becoming a member of LXer is easy and free. Join Us!