<commit_before>(module advanced-funs scheme/base
  (require "teachprims.rkt"
           mzlib/etc
           mzlib/list
           mzlib/pretty
           syntax/docprovide
           scheme/promise
           scheme/port
           "../posn.rkt"
           (for-syntax scheme/base))

  (define pp
    (let ([pretty-print (lambda (v)
                          (pretty-write v))])
      pretty-print))
  
  (provide-and-document
   procedures
   
   ("Numbers: Integers, Rationals, Reals, Complex, Exacts, Inexacts"
    (random (case->
             (integer -> integer)
             (-> (and/c real inexact? (>/c 0) (</c 1))))
            "Generates a random natural number less than some given integer, or to generate a random inexact number between 0.0 and 1.0 exclusive."))
   
   ("Reading and Printing"
    (with-input-from-file (string (-> any) -> any)
      "Opens the named input file and to extract all input from there.")
    (with-output-to-file (string (-> any) -> any)
      "Opens the named output file and to put all output there.")
    (with-input-from-string (string (-> any) -> any)
      "Turns the given string into input for read* operations.")
    (with-output-to-string (string (-> any) -> any)
      "Produces a string from all write/display/print operations.")
    
    
    (print (any -> void)
           "Prints the argument as a value to stdout.")
    (display (any -> void)
             "Prints the argument to stdout (without quotes on symbols and strings, etc.).")
    (write (any -> void)
           "Prints the argument to stdout (in a traditional style that is somewhere between print and display).")
    ((pp pretty-print) (any -> void)
                       "Like write, but with standard newlines and indentation.")
    (printf (string any ... -> void)
            "Formats the rest of the arguments according to the first argument and print it to stdout.")
    (newline (-> void)
             "Prints a newline to stdout.")
    (read (-> sexp) "Reads input from the user."))
   
   ("Lists"
    (list? (any -> boolean)
           "Determines whether some value is a list.")
    
    ((advanced-list* list*) (any ... (listof any) -> (listof any)) 
                            "Constructs a list by adding multiple items to a list.")
    
    ((advanced-cons cons) (X (listof X) -> (listof X))
                          "Constructs a list.")
    
    ((advanced-append append) ((listof any) ... -> (listof any))
                              "Creates a single list from several.")
    
    (assoc 
     (any (listof any) -> (listof any) or false)
     "Produces the first element on the list whose first is equal? to v; otherwise it produces false."))
   
   ("Misc"
    (gensym (-> symbol?)
            "Generates a new symbol, different from all symbols in the program.")
    (sleep (-> positive-number void)
           "Causes the program to sleep for the given number of seconds.")
    (current-milliseconds (-> exact-integer)
                          "Returns the current “time” in fixnum milliseconds (possibly negative).")
    
    (force (delay -> any) "Finds the delayed value; see also delay.")
    (promise? (any -> boolean) "Determines if a value is delayed.")
    (void (-> void) "Produces a void value.")
    (void? (any -> boolean) "Determines if a value is void."))
   
   ("Posns"
    (set-posn-x! (posn number -> void) "Updates the x component of a posn.")
    (set-posn-y! (posn number -> void) "Updates the x component of a posn."))
   
   ("Vectors"
    (vector (X ... -> (vector X ...))
            "Constructs a vector.")
    (make-vector (number X -> (vectorof X))
                 "Constructs a vector.")
    (build-vector (nat (nat -> X)  -> (vectorof X))
                  "Constructs a vector.")	
    (vector-ref ((vector X) nat -> X)
                "Extracts an element from a vector.")
    (vector-length ((vector X) -> nat)
                   "Determines the length of a vector.")	
    (vector-set! ((vectorof X) nat X -> void)
                 "Updates a vector.")
    (vector? (any -> boolean)
             "Determines if a value is a vector."))
   
   ("Boxes"
    (box (any -> box)
         "Constructs a box.")
    (unbox (box -> any)
           "Extracts the boxed value.")
    (set-box! (box any -> void)
              "Updates a box.")
    (box? (any -> boolean)
          "Determines if a value is a box."))
   
   ("Hash Tables"
    ((advanced-make-hash make-hash) 
     (case->
      (-> (hash X Y))
      ((listof (list X Y)) -> (hash X Y)))
     "Constructs a mutable hash table from an optional list of mappings that uses equal? for comparisions.")
    ((advanced-make-hasheq make-hasheq) 
     (case->
      (-> (hash X Y))<commit_msg>added vector->list<commit_after>(module advanced-funs scheme/base
  (require "teachprims.rkt"
           mzlib/etc
           mzlib/list
           mzlib/pretty
           syntax/docprovide
           scheme/promise
           scheme/port
           "../posn.rkt"
           (for-syntax scheme/base))

  (define pp
    (let ([pretty-print (lambda (v)
                          (pretty-write v))])
      pretty-print))
  
  (provide-and-document
   procedures
   
   ("Numbers: Integers, Rationals, Reals, Complex, Exacts, Inexacts"
    (random (case->
             (integer -> integer)
             (-> (and/c real inexact? (>/c 0) (</c 1))))
            "Generates a random natural number less than some given integer, or to generate a random inexact number between 0.0 and 1.0 exclusive."))
   
   ("Reading and Printing"
    (with-input-from-file (string (-> any) -> any)
      "Opens the named input file and to extract all input from there.")
    (with-output-to-file (string (-> any) -> any)
      "Opens the named output file and to put all output there.")
    (with-input-from-string (string (-> any) -> any)
      "Turns the given string into input for read* operations.")
    (with-output-to-string (string (-> any) -> any)
      "Produces a string from all write/display/print operations.")
    
    
    (print (any -> void)
           "Prints the argument as a value to stdout.")
    (display (any -> void)
             "Prints the argument to stdout (without quotes on symbols and strings, etc.).")
    (write (any -> void)
           "Prints the argument to stdout (in a traditional style that is somewhere between print and display).")
    ((pp pretty-print) (any -> void)
                       "Like write, but with standard newlines and indentation.")
    (printf (string any ... -> void)
            "Formats the rest of the arguments according to the first argument and print it to stdout.")
    (newline (-> void)
             "Prints a newline to stdout.")
    (read (-> sexp) "Reads input from the user."))
   
   ("Lists"
    (list? (any -> boolean)
           "Determines whether some value is a list.")
    
    ((advanced-list* list*) (any ... (listof any) -> (listof any)) 
                            "Constructs a list by adding multiple items to a list.")
    
    ((advanced-cons cons) (X (listof X) -> (listof X))
                          "Constructs a list.")
    
    ((advanced-append append) ((listof any) ... -> (listof any))
                              "Creates a single list from several.")
    
    (assoc 
     (any (listof any) -> (listof any) or false)
     "Produces the first element on the list whose first is equal? to v; otherwise it produces false."))
   
   ("Misc"
    (gensym (-> symbol?)
            "Generates a new symbol, different from all symbols in the program.")
    (sleep (-> positive-number void)
           "Causes the program to sleep for the given number of seconds.")
    (current-milliseconds (-> exact-integer)
                          "Returns the current “time” in fixnum milliseconds (possibly negative).")
    
    (force (delay -> any) "Finds the delayed value; see also delay.")
    (promise? (any -> boolean) "Determines if a value is delayed.")
    (void (-> void) "Produces a void value.")
    (void? (any -> boolean) "Determines if a value is void."))
   
   ("Posns"
    (set-posn-x! (posn number -> void) "Updates the x component of a posn.")
    (set-posn-y! (posn number -> void) "Updates the x component of a posn."))
   
   ("Vectors"
    (vector (X ... -> (vector X ...)) "Constructs a vector.")
    (make-vector (number X -> (vectorof X)) "Constructs a vector.")
    (build-vector (nat (nat -> X)  -> (vectorof X)) "Constructs a vector.")	
    (vector-ref ((vector X) nat -> X) "Extracts an element from a vector.")
    (vector-length ((vector X) -> nat) "Determines the length of a vector.")	
    (vector-set! ((vectorof X) nat X -> void) "Updates a vector.")
    (vector->list ((vectorof X) -> (listof X)) "creates a list of values from the vector of values.")
    (vector? (any -> boolean) "Determines if a value is a vector."))
   
   ("Boxes"
    (box (any -> box)
         "Constructs a box.")
    (unbox (box -> any)
           "Extracts the boxed value.")
    (set-box! (box any -> void)
              "Updates a box.")
    (box? (any -> boolean)
          "Determines if a value is a box."))
   
   ("Hash Tables"
    ((advanced-make-hash make-hash) 
     (case->
      (-> (hash X Y))
      ((listof (list X Y)) -> (hash X Y)))
     "Constructs a mutable hash table from an optional list of mappings that uses equal? for comparisions.")
    ((advanced-make-hasheq make-hasheq) 
     (case->
      (-> (hash X Y))
{'fraction_non_alphanumeric': 0.13237943826179122, 'fraction_numerical': 0.0012718600953895071, 'mean_word_length': 2.007010834926705, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 106, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4318334', 'n_tokens_mistral': 2825, 'n_tokens_neox': 2761, 'n_words': 1051}