Advertisement
Guest User

Untitled

a guest
Nov 28th, 2011
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. "indent
  2. [
  3. str_String
  4. ]
  5. := Module
  6. [
  7.  
  8. {
  9. ind,
  10. indent,
  11. f
  12. }
  13. ,
  14. ind = 0;
  15.  
  16. indent
  17. [
  18. i_
  19. ]
  20. := \"\\n\" <> Nest
  21. [
  22. \" \" <> ToString
  23. [
  24. #
  25. ]
  26. &,
  27. \"\",
  28. i
  29. ]
  30. ;
  31.  
  32. f
  33. [
  34. c_
  35. ]
  36. :=
  37. (
  38. indent
  39. [
  40. ind
  41. ]
  42. <> c <> indent
  43. [
  44. ++ind
  45. ]
  46.  
  47. )
  48. /;
  49.  
  50. StringMatchQ
  51. [
  52. \"
  53. [
  54.  
  55. (
  56.  
  57. {
  58. \",
  59. ___ ~~ c ~~ ___
  60. ]
  61. ;
  62.  
  63. f
  64. [
  65. c_
  66. ]
  67. :=
  68. (
  69. indent
  70. [
  71. --ind
  72. ]
  73. <> c <> indent
  74. [
  75. ind
  76. ]
  77.  
  78. )
  79. /;
  80.  
  81. StringMatchQ
  82. [
  83. \"
  84. ]
  85.  
  86. )
  87.  
  88. }
  89. \",
  90. ___ ~~ c ~~ ___
  91. ]
  92. ;
  93.  
  94. f
  95. [
  96. c_
  97. ]
  98. :=
  99. (
  100. c <> indent
  101. [
  102. ind
  103. ]
  104.  
  105. )
  106. /;
  107. StringMatchQ
  108. [
  109. \";
  110. ,
  111. \",
  112. ___ ~~ c ~~ ___
  113. ]
  114. ;
  115.  
  116. f
  117. [
  118. c_
  119. ]
  120. := c;
  121.  
  122. f /
  123. @
  124. Characters
  125. @
  126. str // StringJoin
  127. ]
  128. "
  129.  
  130.  
  131.  
  132. "List
  133. [
  134. List
  135. [
  136. 6,
  137. 10,
  138. 6
  139. ]
  140. ,
  141. List
  142. [
  143. 4,
  144. 0,
  145. 10
  146. ]
  147. ,
  148. List
  149. [
  150. 8,
  151. 7,
  152. 5
  153. ]
  154.  
  155. ]
  156. "
  157.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement