Mathematica 学习资源3

原文在这里

A collection of Mathematica learning resources -- Part III

Advanced evaluation of expressions

  • Non standard evaluation allows to work on the symbols of an expression before they get evaluated.

    Here's how I represent myself Mathematica's evaluation: consider a function/tree f[a,b]. Without any particular attribute for f the leafs/arguments will be evaluated before the parent f. With f having a HoldAll attribute you don't evaluate the leafs but go directly in the evaluation of f. a and b will be evaluated as soon as they are used in a function that doesn't hold again their evaluation. For example

    f[a_,b_]:= a Hold[b]; 
    f[2^2,2^2] (* returns 4 Hold[4] *)
    
    SetAttributes[f, HoldAll];  
    f[2^2,2^2] (* returns 4 Hold[2^2] *)
    

    http://reference.wolfram.com/mathematica/tutorial/NonStandardEvaluation.html
    Preventing evaluation ofMathematica expressions
    Hold any argument
    How can I hold UpValues but evaluate other expressions?
    Symbolic computations with already assigned variables
    How to pass a symbol name to a function with any of the Hold attributes?
    Pure function with attributes of arbitrary number of arguments: Is it possible?

  • Mathematica Language Structure
  • Mathematica Internals: A Tutorial
    The evaluation process
    http://reference.wolfram.com/mathematica/tutorial/Evaluation.html
    http://reference.wolfram.com/mathematica/tutorial/TheStandardEvaluationProcedure.html
    List manipulation to build a functional expression
    How does Mathematica determine that an evaluation should be terminated?
  • Some notes on internal implementation
    The Internals of the Wolfram System
    Algorithm used by IsomorphicGraphQ
  • What is the complete sequence of evaluations/transformations from submitting a cell to actual evaluation?
    $PreRead,$Pre, $Post, $PrePrint
  • http://library.wolfram.com/conferences/devconf99/villegas/UnevaluatedExpressions.nb (Advanced resource about the evaluation process)
    Update a function avoiding infinite recursion (Villegas-Gayley technique)
    Understanding Villegas-Gayley
  • What are the use cases for different scoping constructs?
    A speed comparison between Module, Block and With (Still, Module is what users use most of the time)
    Enforcing correct variable bindings and avoiding renamings for conflicting variables in nested scoping constructs
    What does Internal`InheritedBlock do?
    How safe is the use of Block and Internal`InheritedBlock
    What is the purpose of Internal`LocalizedBlock?
    What are the scoping rules for function parameters shadowing System` symbols?
    Constructing symbol definitions for With
    Using With to scope over pure functions
    Module variable scoping in Scheduled Tasks?

    Enforcing correct variable bindings and avoiding renamings for conflicting variables in nested scoping constructs
    StringReplace, ReplaceAll and Rule interact in a bizarre way

  • What are some advanced uses for Block?
    How to set Block local variables by code?
    Safely nesting RuleDelayed
  • Metaprogramming in Mathematica
  • Can one identify the design patterns of Mathematica?
  • Replace inside Held expression
    Injecting a sequence of expressions into a held expression
    Is it possible to replicate the "magic" of OptionPatterns[] with DynamicModule's local variables?
    How does MakeBoxes handle an n-ary operator?
    How to inject an evaluated expression into a held expression? (Trott-Strzebonski in-place evaluation trick, RuleCondition)
    How to pass a list of arguments into HoldAll
    Returning an unevaluated expression with values substituted in
    Passing a joined list of symbols for Module or Block to treat as its own local symbols
    Replacing parts of a held expression with held parts of another expression
  • Expression parsing examples
    Converting StringJoin to StringForm inside Hold
    How to write a function to remove comments from a .m source file preserving formatting such as line wrapping reasonably?
    How to write a function-defining function which stores the function arguments in a stack?
    Is there a Mathematica API for the functions.wolfram site?
    Function that counts the number of arguments of other functions
    Using MatchQ (or other means) to parse an expression using sums of COS or SIN correctlyAutomatically generating a dependency graph of an arbitrary Mathematica function?

    Programmatic formatting for Mathematica code - possible?

  • Functional style using lazy lists?
    Tally repeated evaluation of function
    File-backed lists/variables for handling large data (Lazy evaluation of streams)
    Lazy lists of Tuples and Subsets
  • How to use pattern matching to assign values to Subscript[f,x_]?
  • Implementing a safe ValueQ that does not evaluate its argument
  • Convert an expression to a Function
    Nested definition: How can I define a function with a passed-in expression?
  • How to avoid nested With[]?
    Comparing LetL and Module efficiency
  • Do people actually use UpValues?
    Upvalues, TagSet and UpSet, what's the difference, when should a use each?
    How to implement dual numbers in Mathematica?
    Make mathematica treate2i as numeric
    how to differentiate formally?
  • Currying with Mathematica
    Going full functional (Haskell style)
  • How to avoid returning a Null if there is no "else" condition in an If contruct (Vanishing function)
  • SetAttributes[f,Flat]: Why the order dependence?
    The Flat Attribute, Unevaluated and the Evaluation Process
    Orderless pattern matching
  • Spelunking
    What is the most convenient way to read definitions of in-memory symbols when we don't have the source files? (Spelunking tools)
    How to see which arguments are passed into a function
  • How does Return work?
    What can I use as the second argument to Return in my own functions?
    FoldWhile and FoldWhileList
  • Tail call optimization in Mathematica?
    What tools can help in realizing tail recursion?
  • Elegant manipulation of the variables list
  • Block attributes of Equal
  • How to find the name of the current function
  • Does pass-by-value affect the performance of function calls?
  • Comparing Mathematica expressions like diff
  • What is the fastest way to get a list of subexpressions and their positions?
  • Resource management in Mathematica
  • How to pass a list of arguments into HoldAll
    Dynamic Programming with delayed evaluation
  • Multiplying expressions within a list of pure functions
    Using Through to evaluate complex expressions
  • How to make a function like Set, but with a Block construct for the pattern names
    Scoping in assigning a derivative
  • Getting a usable expression tree
  • Call Functions From File Without Modifying Context (Sandbox)
  • Functions vs. patterns
    when is f@g not the same as f[g]?
    When should I use Apply (or Function) and when @@ (or &)?
  • Constructing functions with variable number of output arguments
    Alternative to overloading Set

Pattern matching

A pattern is a way to quickly describe the structure of expressions and do computations on them, using/. or Cases for example.

  • Some examples
    Much more elaborate: a Texas Hold'em package by Sal Mangano
  • Rules, pattern and functions, one of the chapter of Leonid Shifrin's book.
    Demistifying rules
  • Where in the documentation can I find a list of function argument types?
    How can I type-check the arguments of a Mathematica function?
  • Using ?NumericQ to Affect Order of Evaluation
    Is it possible to use the LevenbergMarquardt algorithm for fitting a black-box residual function?
  • Convert boolean test function to pattern?
  • http://library.wolfram.com/infocenter/Conferences/6999/ (Inside the Mathematica pattern matcher)
  • Is there an open source implementation of Mathematica-the-language? (Some interesting links to papers about pattern matching)
    Mathador
    Mathematica as a normal programming language
    Mathematica for Computer Scientists
  • Mathematica Destructuring (Mr. Wizard also gives many links to interesting answers illustrating the same point)
  • How to match a pattern with a pattern?
    How to generally match, unify and merge patterns?
    Pattern matching a pattern with patterns
  • Semantica, a package for using semantic patterns (f[(2 n_)] for example)
  • How do I perform string matching and replacements?
    Working with string patterns
    Counting the number of instances of one sub-string within a given string within a lower- and upper-bound gap of a second sub-string
  • Placement of Condition /; expressions
    Using a PatternTest versus a Condition for pattern matching
    Use of StringExpression as argument
  • Assessing argument type in set delayed function definitions
    How to Combine Pattern Constraints and Default Values for Function Arguments
  • ForEach in Mathematica
  • Why does the name of a pattern affect the result of a transformation rule?
  • How to match expressions with a repeating pattern
  • Is it possible to specify a context-sensitive, "depth-agnostic" rewrite rule?
  • Change variables in differential expressions
  • Transforming XML
    Extract information from HTML using Mathematica
    How to manipulate web pages on Mathematica?
  • Replacements/Substitutions in Mathematica ($Assumptions)
  • Position function not always retuning an answer even with no apparent problems
  • How can I ensure that I am constructing patterns in the most efficient way possible?
  • How can I find these patterns' signatures?
  • replacement rules from a pattern and a matching expression
  • Position of a pattern-matched part of an expression
    Select cases from a list (ReplaceList)
  • Patternmatching sets
  • Using patterns in pure functions
  • The difference between 0. and 0
  • “Strange” behavior of Rule
  • f[arg1, arg2,...,argN] vs. f[{arg1, arg2,...,argN}]
    A function that accepts a pair or a list of pairs
    Alternatives pattern in a function definition
    How to distinguish between lists and values?
    Vanishing patterns
  • Get a "step by step" evaluation in Mathematica
    Interactively inspecting parts of an object
  • How to do Cases with multiple related patterns?
  • How to match a cyclically repeating sequence?

Neat algorithms

  • Mathematica Minecraft
    How to create word clouds?
    How can I use Mathematica's graph functions to cheat at Boggle?
    Performance tuning for game solving (peg solitaire | senku)
    Factorisation diagrams
    Happy 2K prime question
    Simulating Theatre puzzle
    How can I generate this "domain coloring" plot?
    Tiling a square
    Generating visually pleasing circle packs
    Circuit drawing in Mathematica
    Detecting patterns of black and white stones on a 2D board
  • How to draw Fractal images of iteration functions on the Riemann sphere?
    Generating a Sierpinski carpet
    Speeding up this fractal-generating code
  • Explain a Mathematica winning one-liner
  • How can this confetti code be improved to include shadows and gravity?
    How to create animated snowfall?
  • xkcd-style graphs
    xkcdConvert routines perform slower in Mathematica 9
    http://blog.wolfram.com/2012/10/05/automating-xkcd-diagrams-transforming-serious-to-funny/
    Sketch-type graphics with transparency and dashed hidden lines?
  • How to improve the performance of solutions to Project Euler (#39)?
    How to find palindromic numbers (Project Euler #4)?
  • Image processing
    Help find a bright object on Mars!
    How can I find Waldo?
    QR Code in shopping cart handle
    Playing with Matrix falling code in Mathematica
    Image segmentation and object separation in 3D using Mathematica
    Artistic image vectorization
    DumpsterDoofus's captivating generative art
  • How to express trigonometric equation in terms of of given trigonometric function?
    How do I introduce a new variable in a trigonometric equation?
    Checking if two trigonometric expressions are equal
  • Efficiently generating n-D Gaussian random fields
    Distribution of random points in 3D space to simulate the Crab Nebula
  • How to improve this code for solving the "Mr.S and Mr.P" puzzle?
    Efficient code for the Ten True Sentences puzzle
    Mathematica Implementations of the Random Forest algorithm
    Soft-Match String Comparison
    Gram Schmidt Process for Polynomials
    How to determine the center and radius of a circle given three points in 3D?
    Counting multiplications (complexity function)
    Insert +,,×,/,(,) into 123456789 to make it equal to 100
    Higher order SVD
    How to check if a 2D point is in a polygon?
    Find eigen energies of time-independent Schrödinger equation
    Solving a time-dependent Schroedinger equation
    Efficient backtracking with Mathematica
    Determine frequency of oscillations
    Alternative ways to implement a triangular recursion
  • Position
    Efficiently finding the positions of a large list of targets in another, even larger list
    Looking for a way to insert multiple elements into multiple positions simultaneously in a list
    Efficient way of identifying the indices of first occurrences
  • Duplicates
    Deleting quasi-duplicates from large list efficiently
    Delete duplicate elements from a list
    Ordering function with recognition of duplicates
    How to get list of duplicates when using DeleteDuplicates?
    How to efficiently find positions of duplicates?
    Removing elements from a list which appear in another list
  • Map/Thread
    Scan vs Map vs Apply
    Map a function across a list conditionally
    Map-Thread-Through-Apply a list of functions onto a list of (lists of) values
    Thread over list in different levelsThread over a nested list top to bottom until non-list elements are foundHow can I make threading more flexible?
  • Flatten
    "Unflattening" a list
    Transpose uneven lists
  • List manipulations
    How to select minimal subsets?
    Optimising 2D binning code
    Efficiently extracting an array subset given a separate array
    Quick multiple selections from a list
    How to Derive Tuples Without Replacement
    Need help coding/creating a recursive list (FoldList)
    Find continuous sequences inside a list
    Instruct a Table to only evaluate until a condition is fulfilled
    How do I replace a missing value in a column with the value immediately above throughout a table?
    Sort+Union on a list
    How to generalize and speed up this program?
    How do I obtain an intersection of two or more list of lists conditioned on the first element of each sub-list?
    Vlookup function as Excel in Mathematica
    Partitioning a list of numbers the Mathematica way
    How to pick increasing numbers from the list
    How to replace an element in a list based on the value of the next element?
    How to partition a list in a specific way
    Nest , Fold ... is there an extension for more than 2 arguments?
    List comprehension in Mathematica (similar to Python)
    Select a repeated element in a list
    Fast method for combining two lists
    Discrete Convolution
    Shuffle product of two lists
    Is there a function which instantly tells you whether an element is part of a list?
    Sort per column

你可能感兴趣的:(Math)