Author Topic: Challenge: Matrix Code Scroll  (Read 4524 times)

0 Members and 1 Guest are viewing this topic.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Challenge: Matrix Code Scroll
« Reply #15 on: December 21, 2017, 01:02:51 PM »
Probably my fav ...
very cool. <thumbs up>
TheSwamp.org  (serving the CAD community since 2003)

Lee Mac

  • Seagull
  • Posts: 12925
  • London, England
Re: Challenge: Matrix Code Scroll
« Reply #16 on: December 21, 2017, 01:42:38 PM »
Good Unicode knowledge Michael :lol:

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Challenge: Matrix Code Scroll
« Reply #17 on: December 21, 2017, 02:17:30 PM »
Thanks Lee. :)

Amaze your friends with this variant:

Code: [Select]
(defun c:Matrix ( / *error* s h l n )
    (defun *error* (x) (princ))
    (setq
        s  42
        h '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F")
        l  (apply 'append (mapcar '(lambda (p) (mapcar '(lambda (s) (strcat p s)) h)) (member "4" (reverse h))))
        n  (length l)       
    )
    (while (princ "\n")
        (repeat 40
            (princ
                (strcat " \\U+25"
                    (setq h
                        (nth
                            (rem
                                (abs
                                    (   /
                                        (setq s (+ (* 214013 s) 2531011))
                                        65536
                                    )
                                )
                                n
                            )
                            l
                        )
                    )
                )
            )
        )
    )   
)

 :lol:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

dubb

  • Swamp Rat
  • Posts: 1105
Re: Challenge: Matrix Code Scroll
« Reply #18 on: December 21, 2017, 05:19:15 PM »
hm..it crashes autocad. I can't see it.

Lee Mac

  • Seagull
  • Posts: 12925
  • London, England
Re: Challenge: Matrix Code Scroll
« Reply #19 on: December 21, 2017, 05:42:26 PM »
hm..it crashes autocad. I can't see it.

Try inserting:
Code: [Select]
(princ)
After the repeat expression.

dubb

  • Swamp Rat
  • Posts: 1105
Re: Challenge: Matrix Code Scroll
« Reply #20 on: December 21, 2017, 05:51:11 PM »
Oh it worked.
Genius!

MickD

  • King Gator
  • Posts: 3649
  • (x-in)->[process]->(y-out) ... simples!
Re: Challenge: Matrix Code Scroll
« Reply #21 on: December 21, 2017, 09:16:01 PM »
Not in lisp but I liked the idea for a test run in my new IronPython interpreter for Bricscad :)

Code - Python: [Select]
  1. from System import Random
  2.  
  3. import Bricscad.ApplicationServices as AcAp
  4. import Bricscad.EditorInput as AcEd
  5. import Teigha.DatabaseServices as AcDb
  6.  
  7. def matrix():
  8.     chars = get_random_unicode(200)
  9.     ed = AcAp.Application.DocumentManager.MdiActiveDocument.Editor
  10.     ed.WriteMessage(chars)
  11.  
  12. def get_random_unicode(length):
  13.     include_ranges = [
  14.         ( 0x0021, 0x0021 ),
  15.         ( 0x0023, 0x0026 ),
  16.         ( 0x0028, 0x007E ),
  17.         ( 0x00A1, 0x00AC ),
  18.         ( 0x00AE, 0x00FF ),
  19.         ( 0x0100, 0x017F ),
  20.         ( 0x0180, 0x024F ),
  21.         ( 0x2C60, 0x2C7F ),
  22.         ( 0x16A0, 0x16F0 ),
  23.         ( 0x0370, 0x0377 ),
  24.         ( 0x037A, 0x037E ),
  25.         ( 0x0384, 0x038A ),
  26.         ( 0x038C, 0x038C ),
  27.     ]
  28.     random = Random()
  29.     alphabet = []
  30.    
  31.     for i in range(length):
  32.         for (i, j) in include_ranges:
  33.             alphabet.append(unichr(random.Next(i, j)))
  34.             alphabet.append(' ')
  35.  
  36.     return ''.join(alphabet)
  37.  

« Last Edit: December 21, 2017, 09:37:54 PM by MickD »
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Challenge: Matrix Code Scroll
« Reply #22 on: December 22, 2017, 01:02:16 AM »
Beautiful.  :smitten:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst