Other ENTJs
Here. In addition to ChrisAn and I, Harrison Ford is an ENTJ, as are FDR, Nixon, Steve Martin, David Letterman and Jim Carrey.
This is so true: "ENTJs are often 'larger than life' in describing their projects or proposals... In combination with the natural propensity for filibuster, our hero can make it very difficult for the customer to decline... Experience teaches many ENTJs that restraint may often be the better part of valor, lest one find oneself victorious but alone."


Main Menu
Assessment Coversheet
General Neighbourhood Characteristics
Logout
About
Credits
Walkthrough/ Room Audit
Lighting
L1
Yes
No
Dont Know
Not Applicable
Required!
L2
Yes
No
Dont Know
Not Applicable
Required!
L3
Yes
No
Dont Know
Not Applicable
Required!
L4
Yes
No
Dont Know
Not Applicable
Required!
Previous
Add Next Room


--- layout: post title: Blog design updated date: '2008-12-04T11:04:00.001Z' tags: modified_time: '2008-12-04T11:04:22.703Z' blogger_id: tag:blogger.com,1999:blog-4015568221071268916.post-7890187732280788328 comments: true blogger_orig_url: http://serialseb.blogspot.com/2008/12/blog-design-updated.html ---
For those of you only reading from an RSS reader, have a look at the website when you got time. I’ve updated the logo. Gives some well-deserved character to this blog.


Hardworking and dedicated student, who is close to graduating highschool in the top of his class. Was part of NHS for his Junior and Seniors years and has excellent grades in every subject. Has a passion for science, math, and computers. Wants to achieve further by going to college and getting a degree in Mathematics and Particle Physics. Eventually wants to do research at a large institute alonside others who share his passion for science and learning.
Trinity Christian Academy, May 2017
Plans on attending Vanderbilt, 2017-2021
- Fluent in HTML, CSS, SQL, Python, and JavaScript
- Knows how to run audio and visual systems
- Knowledgable about Windows and Mac operating systems
- Proficient in Microsoft Office and Google Suite
31 Avondale Cv, Jackson, TN 38305
731-394-8792
<EMAIL_ADDRESS>Lora Seeley, Calculus Teacher
-<EMAIL_ADDRESS>Mary Courtney Marsh, Art Teacher
-<EMAIL_ADDRESS>Marla Walker, Pharmacy Student & Biology Teacher
-<PHONE_NUMBER>


These are an adaptation of the Ninety-Nine Prolog Problems written by Werner Hett at the Berne University of Applied Sciences in Berne, Switzerland. I (Phil Gold) have altered them to be more amenable to programming in Scala. Feedback is appreciated, particularly on anything marked TODO.
The problems have different levels of difficulty. Those marked with a single asterisk (*) are easy. If you have successfully solved the preceeding problems you should be able to solve them within a few (say 15) minutes. Problems marked with two asterisks (**) are of intermediate difficulty. If you are a skilled Scala programmer it shouldn't take you more than 30-90 minutes to solve them. Problems marked with three asterisks (***) are more difficult. You may need more time (i.e. a few hours or more) to find a good solution. The difficulties were all assigned for the Prolog problems, but the Scala versions seem to be of roughly similar difficulty.
Your goal should be to find the most elegant solution of the given problems. Efficiency is important, but clarity is even more crucial. Some of the (easy) problems can be trivially solved using built-in functions. However, in these cases, you learn more if you try to find your own solution.
Solutions are available by clicking on the link at the beginning of the problem description.
[I don't have example solutions to all of the problems yet. I'm working on getting them all done, but in the meantime, contributed solutions, particularly from seasoned Scala programmers would be appreciated. If you feel a particular problem can be solved in a better manner than I did, please let me know that, too. <PMG>]
In Scala, lists are objects of type List[A]
,
where A can be any type. Lists are effective for many
recursive algorithms, because it's easy to add elements to the head of
a list, and to get the tail of the list, which is everything but the
first element.
The solutions to the problems in this section will be in objects
named after the problems (P01, P02, etc.). You can compile the source
files with scalac
and thereafter use import
to bring the functions into scope. Some of the problems can be solved
easily by using imported solutions to previous problems.
In many cases, there's more than one reasonable approach. The files linked here may include multiple solutions, with all but one commented out. They'll also indicate whether there's a builtin method in Scala that accomplishes the task.
scala> last(List(1, 1, 2, 3, 5, 8)) res0: Int = 8
scala> penultimate(List(1, 1, 2, 3, 5, 8)) res0: Int = 5
Example:
scala> nth(2, List(1, 1, 2, 3, 5, 8)) res0: Int = 2
scala> length(List(1, 1, 2, 3, 5, 8)) res0: Int = 6
scala> reverse(List(1, 1, 2, 3, 5, 8)) res0: List[Int] = List(8, 5, 3, 2, 1, 1)
scala> isPalindrome(List(1, 2, 3, 2, 1)) res0: Boolean = true
scala> flatten(List(List(1, 1), 2, List(3, List(5, 8)))) res0: List[Any] = List(1, 1, 2, 3, 5, 8)
Example:
scala> compress(List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, 'a, 'd, 'e, 'e, 'e, 'e)) res0: List[Symbol] = List('a, 'b, 'c, 'a, 'd, 'e)
Example:
scala> pack(List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, 'a, 'd, 'e, 'e, 'e, 'e)) res0: List[List[Symbol]] = List(List('a, 'a, 'a, 'a), List('b), List('c, 'c), List('a, 'a), List('d), List('e, 'e, 'e, 'e))
(N,
E)
where N is the number of duplicates of the
element E.
Example:
scala> encode(List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, 'a, 'd, 'e, 'e, 'e, 'e)) res0: List[(Int, Symbol)] = List((4,'a), (1,'b), (2,'c), (2,'a), (1,'d), (4,'e))
(N, E)
terms.
Example:
scala> encodeModified(List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, 'a, 'd, 'e, 'e, 'e, 'e)) res0: List[Any] = List((4,'a), 'b, (2,'c), (2,'a), 'd, (4,'e))
Example:
scala> decode(List((4, 'a), (1, 'b), (2, 'c), (2, 'a), (1, 'd), (4, 'e))) res0: List[Symbol] = List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, 'a, 'd, 'e, 'e, 'e, 'e)
pack
); do all the work
directly.
Example:
scala> encodeDirect(List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, 'a, 'd, 'e, 'e, 'e, 'e)) res0: List[(Int, Symbol)] = List((4,'a), (1,'b), (2,'c), (2,'a), (1,'d), (4,'e))
scala> duplicate(List('a, 'b, 'c, 'c, 'd)) res0: List[Symbol] = List('a, 'a, 'b, 'b, 'c, 'c, 'c, 'c, 'd, 'd)
scala> duplicateN(3, List('a, 'b, 'c, 'c, 'd)) res0: List[Symbol] = List('a, 'a, 'a, 'b, 'b, 'b, 'c, 'c, 'c, 'c, 'c, 'c, 'd, 'd, 'd)
scala> drop(3, List('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k)) res0: List[Symbol] = List('a, 'b, 'd, 'e, 'g, 'h, 'j, 'k)
Example:
scala> split(3, List('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k)) res0: (List[Symbol], List[Symbol]) = (List('a, 'b, 'c),List('d, 'e, 'f, 'g, 'h, 'i, 'j, 'k))
Example:
scala> slice(3, 7, List('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k)) res0: List[Symbol] = List('d, 'e, 'f, 'g)
scala> rotate(3, List('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k)) res0: List[Symbol] = List('d, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'a, 'b, 'c) scala> rotate(-2, List('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k)) res1: List[Symbol] = List('j, 'k, 'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i)
Example:
scala> removeAt(1, List('a, 'b, 'c, 'd)) res0: (List[Symbol], Symbol) = (List('a, 'c, 'd),'b)
scala> insertAt('new, 1, List('a, 'b, 'c, 'd)) res0: List[Symbol] = List('a, 'new, 'b, 'c, 'd)
scala> range(4, 9) res0: List[Int] = List(4, 5, 6, 7, 8, 9)
scala> randomSelect(3, List('a, 'b, 'c, 'd, 'f, 'g, 'h)) res0: List[Symbol] = List('e, 'd, 'a)
Hint: Use the solution to problem P20
scala> lotto(6, 49) res0: List[Int] = List(23, 1, 17, 33, 21, 37)
Example:
scala> randomPermute(List('a, 'b, 'c, 'd, 'e, 'f)) res0: List[Symbol] = List('b, 'a, 'd, 'c, 'e, 'f)
C(12,3) = 220
possibilities (C(N,K)
denotes the well-known binomial
coefficient). For pure mathematicians, this result may be great.
But we want to really generate all the possibilities.
Example:
scala> combinations(3, List('a, 'b, 'c, 'd, 'e, 'f)) res0: List[List[Symbol]] = List(List('a, 'b, 'c), List('a, 'b, 'd), List('a, 'b, 'e), ...
Example:
scala> group3(List("Aldo", "Beat", "Carla", "David", "Evi", "Flip", "Gary", "Hugo", "Ida")) res0: List[List[List[String]]] = List(List(List(Aldo, Beat), List(Carla, David, Evi), List(Flip, Gary, Hugo, Ida)), ...
b) Generalize the above predicate in a way that we can specify a list of group sizes and the predicate will return a list of groups.
Example:
scala> group(List(2, 2, 5), List("Aldo", "Beat", "Carla", "David", "Evi", "Flip", "Gary", "Hugo", "Ida")) res0: List[List[List[String]]] = List(List(List(Aldo, Beat), List(Carla, David), List(Evi, Flip, Gary, Hugo, Ida)), ...
Note that we do not want permutations of the group members; i.e. ((Aldo, Beat), ...) is the same solution as ((Beat, Aldo), ...). However, we make a difference between ((Aldo, Beat), (Carla, David), ...) and ((Carla, David), (Aldo, Beat), ...).
You may find more about this combinatorial problem in a good book on discrete mathematics under the term "multinomial coefficients".
Example:
scala> lsort(List(List('a, 'b, 'c), List('d, 'e), List('f, 'g, 'h), List('d, 'e), List('i, 'j, 'k, 'l), List('m, 'n), List('o))) res0: List[List[Symbol]] = List(List('o), List('d, 'e), List('d, 'e), List('m, 'n), List('a, 'b, 'c), List('f, 'g, 'h), List('i, 'j, 'k, 'l))
b) Again, we suppose that a list contains elements that are lists themselves. But this time the objective is to sort the elements according to their length frequency; i.e. in the default, sorting is done ascendingly, lists with rare lengths are placed, others with a more frequent length come later.
Example:
scala> lsortFreq(List(List('a, 'b, 'c), List('d, 'e), List('f, 'g, 'h), List('d, 'e), List('i, 'j, 'k, 'l), List('m, 'n), List('o))) res1: List[List[Symbol]] = List(List('i, 'j, 'k, 'l), List('o), List('a, 'b, 'c), List('f, 'g, 'h), List('d, 'e), List('d, 'e), List('m, 'n))
Note that in the above example, the first two lists in the result have length 4 and 1 and both lengths appear just once. The third and fourth lists have length 3 and there are two list of this length. Finally, the last three lists have length 2. This is the most frequent length.
For the next section, we're going to take a different tack with
the solutions. We'll declare a new class, S99Int
, and
an implicit conversion from regular Int
s.
The arithmetic1 file contains the
starting definitions for this section. Each individual solution
will show the relevant additions to the S99Int
class.
The full class will be given at the end of the section.
scala> 7.isPrime res0: Boolean = true
scala> gcd(36, 63) res0: Int = 9
scala> 35.isCoprimeTo(64) res0: Boolean = true
phi(m)
.phi(m)
is
defined as the number of positive integers
r (1 <= r <= m) that are coprime
to m.
scala> 10.totient res0: Int = 4
scala> 315.primeFactors res0: List[Int] = List(3, 3, 5, 7)
scala> 315.primeFactorMultiplicity res0: List[(Int, Int)] = List((3,2), (5,1), (7,1))
Alternately, use a Map for the result.
scala> 315.primeFactorMultiplicity res0: Map[Int,Int] = Map(3 -> 2, 5 -> 1, 7 -> 1)
phi(m>)
can be efficiently calculated as
follows: Let [[p1, m1],
[p2, m2],
[p3, m3], ...] be the list of
prime factors (and their multiplicities) of a given
number m. Then phi(m)
can be calculated with
the following formula:
phi(m) = (p1-1)*p1(m1-1) * (p2-1)*p2(m2-1) * (p3-1)*p3(m3-1) * ...
Note that ab stands for the bth power of a.
scala> listPrimesinRange(7 to 31) res0: List[Int] = List(7, 11, 13, 17, 19, 23, 29, 31)
scala> 28.goldbach res0: (Int, Int) = (5,23)
scala> printGoldbachList(9 to 20) 10 = 3 + 7 12 = 5 + 7 14 = 3 + 11 16 = 3 + 13 18 = 5 + 13 20 = 3 + 17
In most cases, if an even number is written as the sum of two prime numbers, one of them is very small. Very rarely, the primes are both bigger than, say, 50. Try to find out how many such cases there are in the range 2..3000.
Example (minimum value of 50 for the primes):
scala> printGoldbachListLimited(1 to 2000, 50) 992 = 73 + 919 1382 = 61 + 1321 1856 = 67 + 1789 1928 = 61 + 1867
The file containing the full class for this section is arithmetic.scala.
As in the previous section, we will start with a skeleton file, logic1.scala, and add code to it for each problem. The difference here is that the file starts out almost empty.
and
, or
, nand
, nor
, xor
, impl
,
and equ
(for logical equivalence) which return true
or false according to the result of their respective operations;
e.g. and(A, B)
is true if and only if both A
and B are true.
scala> and(true, true) res0: Boolean = true scala> xor(true. true) res1: Boolean = false
A logical expression in two variables can then be written as an
function of two variables, e.g: (a: Boolean, b: Boolean) =>
and(or(a, b), nand(a, b))
Now, write a function called table2
which prints the
truth table of a given logical expression in two variables.
scala> table2((a: Boolean, b: Boolean) => and(a, or(a, b))) A B result true true true true false true false true false false false false
and
, or
, etc as operators.
(i.e. make them methods of a new class with an implicit conversion
from Boolean.) not
will have to be left as a object
method.
scala> table2((a: Boolean, b: Boolean) => a and (a or not(b))) A B result true true true true false true false true false false false false
Find out the construction rules and write a function to generate Gray codes.
scala> gray(3) res0 List[String] = List(000, 001, 011, 010, 110, 111, 101, 100)
See if you can use memoization to make the function more efficient.
We suppose a set of symbols with their frequencies, given as a
list of (S, F)
Tuples. E.g. (("a", 45),
("b", 13), ("c", 12), ("d", 16), ("e", 9), ("f", 5))
.
Our objective is to construct a list of (S, C)
Tuples, where C is the Huffman code word for the
symbol S.
scala> huffman(List(("a", 45), ("b", 13), ("c", 12), ("d", 16), ("e", 9), ("f", 5))) res0: List[String, String] = List((a,0), (b,101), (c,100), (d,111), (e,1101), (f,1100))
A binary tree is either empty or it is composed of a root element and two successors, which are binary trees themselves.
We shall use the following classes to represent binary trees.
(Also available in tree1.scala.) An End
is equivalent to an empty tree. A Branch has a value, and two
descendant trees. The toString
functions are
relatively arbitrary, but they yield a more compact output than
Scala's default. Putting a plus in front of the T
makes the class covariant; it will be able to hold subtypes
of whatever type it's created for. (This is important so
that End
can be a singleton object; as a singleton, it
must have a specific type, so we give it type Nothing
,
which is a subtype of every other type.)
sealed abstract class Tree[+T] case class Node[+T](value: T, left: Tree[T], right: Tree[T]) extends Tree[T] { override def toString = "T(" + value.toString + " " + left.toString + " " + right.toString + ")" } case object End extends Tree[Nothing] { override def toString = "." } object Node { def apply[T](value: T): Node[T] = Node(value, End, End) }
The example tree on the right is given by
Node('a', Node('b', Node('d'), Node('e')), Node('c', End, Node('f', Node('g'), End)))
A tree with only a root node would be Node('a')
and an
empty tree would be End
.
Throughout this section, we will be adding methods to the classes
above, mostly to Tree
.
Define an object named Tree
. Write a
function Tree.cBalanced
to construct completely
balanced binary trees for a given number of nodes. The function
should generate all solutions. The function should take as
parameters the number of nodes and a single value to put in all
of them.
scala> Tree.cBalanced(4, "x") res0: List(Node[String]) = List(T(x T(x . .) T(x . T(x . .))), T(x T(x . .) T(x T(x . .) .)), ...
isSymmetric
method to the Tree class to check whether a given binary tree is
symmetric. Hint: Write an isMirrorOf
method first to
check whether one tree is the mirror image of another. We are
only interested in the structure, not in the contents of the nodes.
scala> Node('a', Node('b'), Node('c')).isSymmetric res0: Boolean = true
scala> End.addValue(2) res0: Node[Int] = T(2 . .) scala> res0.addValue(3) res1: Node[Int] = T(2 . T(3 . .)) scala> res1.addValue(0) res2: Node[Int] = T(2 T(0 . .) T(3 . .))
Hint: The abstract definition of addValue
in Tree
should be def addValue[U >: T
<% Ordered[U]](x: U): Tree[U]
. The >: T
is
because addValue
's parameters need to
be contravariant in T
. (Conceptually,
we're adding nodes above existing nodes. In order for the
subnodes to be of type T
or any subtype, the upper
nodes must be of type T
or any supertype.)
The <% Ordered[U]
allows us to use
the <
operator on the values in the tree.
Use that function to construct a binary tree from a list of integers.
scala> Tree.fromList(List(3, 2, 5, 7, 1)) res3: Node[Int] = T(3 T(2 T(1 . .) .) T(5 . T(7 . .)))
Finally, use that function to test your solution to P56.
scala> Tree.fromList(List(5, 3, 18, 1, 4, 12, 21)).isSymmetric res4: Boolean = true scala> Tree.fromList(List(3, 2, 5, 7, 4)).isSymmetric res5: Boolean = false
scala> Tree.symmetricBalancedTrees(5, "x") res0: List[Node[String]] = List(T(x T(x . T(x . .)) T(x T(x . .) .)), T(x T(x T(x . .) .) T(x . T(x . .))))
Write a method Tree.hbalTrees
to construct
height-balanced binary trees for a given height with a supplied value
for the nodes. The function should generate all solutions.
scala> Tree.hbalTrees(3, "x") res0: List[Node[String]] = List(T(x T(x T(x . .) T(x . .)) T(x T(x . .) T(x . .))), T(x T(x T(x . .) T(x . .)) T(x T(x . .) .)), ...
minHbalNodes
that takes a height and returns MinN.
scala> minHbalNodes(3) res0: Int = 4
On the other hand, we might ask: what is the maximum
height H a height-balanced binary tree with N nodes can
have? Write a maxHbalHeight
function.
scala> maxHbalHeight(4) res1: Int = 3
Now, we can attack the main problem: construct all the height-balanced binary trees with a given nuber of nodes.
scala> Tree.hbalTreesWithNodes(4, "x") res2: List[Node[String]] = List(T(x T(x T(x . .) .) T(x . .)), T(x T(x . T(x . .)) T(x . .)), ...
Find out how many height-balanced trees exist for N = 15.
leafCount
to count them.
scala> Node('x', Node('x'), End).leafCount res0: Int = 1
leafList
to collect them in a list.
scala> Node('a', Node('b'), Node('c', Node('d'), Node('e'))).leafList res0: List[Char] = List(b, d, e)
internalList
to collect them
in a list.
scala> Node('a', Node('b'), Node('c', Node('d'), Node('e'))).internalList res0: List[Char] = List(a, c)
atLevel
to collect all nodes at a given level in a
list.
scala> Node('a', Node('b'), Node('c', Node('d'), Node('e'))).atLevel(2) res0: List[Char] = List(b, c)
Using atLevel
it is easy to construct a
method levelOrder
which creates the level-order sequence
of the nodes. However, there are more efficient ways to do that.
End
s which are not really nodes!) come last.
Particularly, complete binary trees are used as data structures (or addressing schemes) for heaps.
We can assign an address number to each node in a complete binary
tree by enumerating the nodes in levelorder, starting at the root with
number 1. In doing so, we realize that for every node X with
address A the following property holds: The address
of X's left and right successors are 2*A and
2*A+1, respectively, supposed the successors do exist. This
fact can be used to elegantly construct a complete binary tree
structure. Write a method completeBinaryTree
that takes
as parameters the number of nodes and the value to put in each node.
scala> Tree.completeBinaryTree(6, "x") res0: Node[String] = T(x T(x T(x . .) T(x . .)) T(x T(x . .) .))
In this layout strategy, the position of a node v is obtained by the following two rules:
In order to store the position of the nodes, we add a new class with the additional information.
case class PositionedNode[+T](override val value: T, override val left: Tree[T], override val right: Tree[T], x: Int, y: Int) extends Node[T](value, left, right) { override def toString = "T[" + x.toString + "," + y.toString + "](" + value.toString + " " + left.toString + " " + right.toString + ")" }
Write a method layoutBinaryTree
that turns a tree of
normal Node
s into a tree
of PositionedNode
s.
scala> Node('a', Node('b', End, Node('c')), Node('d')).layoutBinaryTree res0: PositionedNode[Char] = T[3,1](a T[1,2](b . T[2,3](c . .)) T[4,2](d . .))
The tree at right may be constructed
with Tree.fromList(List('n','k','m','c','a','h','g','e','u','p','s','q'))
.
Use it to check your code.
Use the same conventions as in problem P64.
scala> Node('a', Node('b', End, Node('c')), Node('d')).layoutBinaryTree2 res0: PositionedNode[Char] = T[3,1]('a T[1,2]('b . T[2,3]('c . .)) T[5,2]('d . .))
The tree at right may be constructed
with Tree.fromList(List('n','k','m','c','a','e','d','g','u','p','q'))
.
Use it to check your code.
Use the same conventions as in problem P64 and P65. Note: This is a difficult problem. Don't give up too early!
scala> Node('a', Node('b', End, Node('c')), Node('d')).layoutBinaryTree3 res0: PositionedNode[Char] = T[2,1]('a T[1,2]('b . T[2,3]('c . .)) T[3,2]('d . .))
Which layout do you like most?
a(b(d,e),c(,f(g,)))
Write a method which generates this string representation, if the
tree is given as usual (in Node
s and End
s).
Use that method for the Tree
class's and
subclass's toString
methods. Then write a method (on
the Tree
object) which does this inverse; i.e. given the
string representation, construct the tree in the usual form.
For simplicity, suppose the information in the nodes is a single letter and there are no spaces in the string.
scala> Node('a', Node('b', Node('d'), Node('e')), Node('c', End, Node('f', Node('g'), End))).toString res0: String = a(b(d,e),c(,f(g,))) scala> Tree.fromString("a(b(d,e),c(,f(g,)))") res1: Node[Char] = a(b(d,e),c(,f(g,)))
a) Write methods preorder
and inorder
that
construct the preorder and inorder sequence of a given binary tree,
respectively. The results should be lists,
e.g. List('a','b','d','e','c','f','g')
for the preorder
sequence of the example in problem P67.
scala> Tree.string2Tree("a(b(d,e),c(,f(g,)))").preorder res0: List[Char] = List(a, b, d, e, c, f, g) scala> Tree.string2Tree("a(b(d,e),c(,f(g,)))").inorder res1: List[Char] = List(d, b, e, a, c, g, f)
b) If both the preorder sequence and the inorder sequence of the
nodes of a binary tree are given, then the tree is determined
unambiguously. Write a method preInTree
that does the
job.
scala> Tree.preInTree(List('a', 'b', 'd', 'e', 'c', 'f', 'g'), List('d', 'b', 'e', 'a', 'c', 'g', 'f')) res2: Node[Char] = a(b(d,e),c(,f(g,)))
What happens if the same character appears in more than one node?
Try, for instance, Tree.preInTree(List('a', 'b', 'a'), List('b',
'a', 'a'))
.
End
) is encountered during the tree
traversal. For example, the tree shown in
problem P67 is represented
as "abd..e..c.fg..."
. First, try to establish a syntax
(BNF or syntax diagrams) and then write two
methods, toDotstring
and fromDotstring
, which
do the conversion in both directions.
scala> Tree.string2Tree("a(b(d,e),c(,f(g,)))").toDotstring res0: String = abd..e..c.fg... scala> Tree.fromDotstring("abd..e..c.fg...") res1: Node[Char] = a(b(d,e),c(,f(g,)))
The file containing the full class definitions for this section is tree.scala.
A multiway tree is composed of a root element and a (possibly empty) set of successors which are multiway trees themselves. A multiway tree is never empty. The set of successor trees is sometimes called a forest.
The code to represent these is somewhat simpler than the code for binary trees, partly because we don't separate classes for nodes and terminators, and partly because we don't need the restriction that the value type be ordered.
case class MTree[+T](value: T, children: List[MTree[T]]) { def this(value: T) = this(value, List()) override def toString = "M(" + value.toString + " {" + children.map(_.toString).mkString(",") + "})" } object MTree { def apply[T](value: T) = new MTree(value, List()) def apply[T](value: T, children: List[MTree[T]]) = new MTree(value, children) }
The example tree is, thus:
MTree('a', List(MTree('f', List(MTree('g'))), MTree('c'), MTree('b', List(MTree('d'), MTree('e')))))
The starting code skeleton for this section is mtree1.scala.
nodeCount
which counts the nodes of a
given multiway tree.
scala> MTree('a', List(MTree('f'))).nodeCount res0: Int = 2
By this rule, the tree in the figure opposite is represented as:
afg^^c^bd^e^^^
Define the syntax of the string and write a
function string2MTree
to construct an MTree
from a String
. Make the function an
implicit conversion from String
. Write the reverse
function, and make it the toString method of MTree.
scala> MTree('a', List(MTree('f', List(MTree('g'))), MTree('c'), MTree('b', List(MTree('d'), MTree('e'))))).toString res0: String = afg^^c^bd^e^^^
internalPathLength
to return that sum.
scala> "afg^^c^bd^e^^^".internalPathLength res0: Int = 9
postorder
which constructs the postorder
sequence of the nodes of a multiway tree. The result should be
a List
.
scala> "afg^^c^bd^e^^^".postorder res0: List[Char] = List(g, f, c, d, e, b, a)
Our example tree would be represented in Lisp as (a (f g) c (b d
e))
. The following pictures give some more examples.
Note that in the "lispy" notation a node with successors (children)
in the tree is always the first element in a list, followed by its
children. The "lispy" representation of a multiway tree is a sequence
of atoms and parentheses '(' and ')', with the atoms separated by
spaces. We can represent this syntax as a Scala String
.
Write a method lispyTree
which constructs a "lispy
string" from an MTree
.
scala> MTree("a", List(MTree("b", List(MTree("c"))))).lispyTree res0: String = (a (b c))
As a second, even more interesting, exercise try to write a method that takes a "lispy" string and turns it into a multiway tree.
[Note: Much of this problem is taken from the wording of the same problem in the Prolog set. This is certainly one way of looking at Lisp notation, but it's not how the language actually represents that syntax internally. I can elaborate more on this, if requested. <PMG>]
The complete source file for this section is mtree.scala.
A graph is defined as a set of nodes and a set of edges, where each edge is a pair of nodes.
The class to represent a graph is mutable, which isn't in keeping with pure functional programming, but a pure functional data structure would make things much, much more complicated. [Pure functional graphs with cycles require laziness; I think Scala can handle it, but I think that would add too much of a barrier to the following questions. <PMG>]
Our Graph
s use an incidence list internally. Each has a
list of nodes and a list of edges. Each node also has a list of edges
that connect it to other nodes. In a directed graph, nodes that are the
target of arcs do not have references to those arcs in their adjacency
list.
abstract class GraphBase[T, U] { case class Edge(n1: Node, n2: Node, value: U) { def toTuple = (n1.value, n2.value, value) } case class Node(value: T) { var adj: List[Edge] = Nil def neighbors: List[Node] = adj.map(edgeTarget(_, this).get) } var nodes: Map[T, Node] = Map() var edges: List[Edge] = Nil // If the edge E connects N to another node, returns the other node, // otherwise returns None. def edgeTarget(e: Edge, n: Node): Option[Node] override def equals(o: Any) = o match { case g: GraphBase[T,U] => (nodes.keys.toList -- g.nodes.keys.toList == Nil && edges.map(_.toTuple) -- g.edges.map(_.toTuple) == Nil) case _ => false } def addNode(value: T) = { val n = new Node(value) nodes = Map(value -> n) ++ nodes n } } class Graph[T, U] extends GraphBase[T, U] { override def equals(o: Any) = o match { case g: Graph[T,U] => super.equals(g) case _ => false } def edgeTarget(e: Edge, n: Node): Option[Node] = if (e.n1 == n) Some(e.n2) else if (e.n2 == n) Some(e.n1) else None def addEdge(n1: T, n2: T, value: U) = { val e = new Edge(nodes(n1), nodes(n2), value) edges = e :: edges nodes(n1).adj = e :: nodes(n1).adj nodes(n2).adj = e :: nodes(n2).adj } } class Digraph[T, U] extends GraphBase[T, U] { override def equals(o: Any) = o match { case g: Digraph[T,U] => super.equals(g) case _ => false } def edgeTarget(e: Edge, n: Node): Option[Node] = if (e.n1 == n) Some(e.n2) else None def addArc(source: T, dest: T, value: U) = { val e = new Edge(nodes(source), nodes(dest), value) edges = e :: edges nodes(source).adj = e :: nodes(source).adj } }
The full initial Graph code, which also includes objects for creating graphs, is in graph1.scala.
 The graph-term form lists the nodes and edges separately:
Graph.term(List('b', 'c', 'd', 'f', 'g', 'h', 'k'), List(('b', 'c'), ('b', 'f'), ('c', 'f'), ('f', 'k'), ('g', 'h')))
The adjacency-list form associates each node with its adjacent nodes. In an undirected graph, care must be taken to ensure that all links are symmetric--if b is adjacent to c, c must also be adjacent to b.
Graph.adjacent(List(('b', List('c', 'f')), ('c', List('b', 'f')), ('d', Nil), ('f', List('b', 'c', 'k')), ('g', List('h')), ('h', List('g')), ('k', List('f'))))
The representations we introduced so far are bound to our implementation and therefore well suited for automated processing, but their syntax is not very user-friendly. Typing the terms by hand is cumbersome and error-prone. We can define a more compact and "human-friendly" notation as follows: A graph is represented by a string of terms of the type X or Y-Z separated by commas. The standalone terms stand for isolated nodes, the Y-Z terms describe edges. If an X appears as an endpoint of an edge, it is automatically defined as a node. Our example could be written as:
[b-c, f-c, g-h, d, f-b, k-f, h-g]
We call this the human-friendly form. As the example shows, the list does not have to be sorted and may even contain the same edge multiple times. Notice the isolated node d.
When the edges of a graph are directed, we call them arcs. These are represented by ordered pairs. Such a graph is called directed graph. To represent a directed graph, the forms discussed above are slightly modified. The example graph opposite is represented as follows:
graph-term form:
Digraph.term(List('r', 's', 't', 'u', 'v'), List(('s', 'r'), ('s', 'u'), ('u', 'r'), ('u', 's'), ('v', 'u')))
adjacency-list form:
Digraph.adjacent(List(('r', Nil), ('s', List('r', 'u')), ('t', Nil), ('u', List('r', 's')), ('v', List('u'))))
(Note that the adjacency-list form is the same for graphs and digraphs.)
human-friendly form:
[s>r, t, u>r, s>u, u>s, v>u]
Finally, graphs and digraphs may have additional information attached to nodes and edges (arcs). For the nodes, this is no problem, as we can put any type into them. On the other hand, for edges we have to extend our notation. Graphs with additional information attached to edges are called labeled graphs.
graph-term form:
Digraph.termLabel(List('k', 'm', 'p', 'q'), List(('m', 'q', 7), ('p', 'm', 5), ('p', 'q', 9)))
adjacency-list form:
Digraph.adjacentLabel( List(('k', Nil), ('m', List(('q', 7))), ('p', List(('m', 5), ('q', 9))), ('q', Nil)))
human-friendly form:
[p>q/9, m>q/7, k, p>m/5]
The notation for labeled graphs can also be used for so-called multi-graphs, where more than one edge (or arc) is allowed between two given nodes.
Graph
. Write another method to output the
human-friendly form for a graph. Make it the toString
method for Graph
. Write more functions to create graphs
from strings.
Hint: You might need separate functions for labeled and unlabeled graphs.
scala> Graph.fromString("[b-c, f-c, g-h, d, f-b, k-f, h-g]").toTermForm res0: (List[String], List[(String, String, Unit)]) = (List(d, k, h, c, f, g, b),List((h,g,()), (k,f,()), (f,b,()), (g,h,()), (f,c,()), (b,c,()))) scala> Digraph.fromStringLabel("[p>q/9, m>q/7, k, p>m/5]").toAdjacentForm res1: List[(String, List[(String, Int)])] = List((m,List((q,7))), (p,List((m,5), (q,9))), (k,List()), (q,List()))
findPaths
to find acyclic paths
from one node to another in a graph. The method should return all
paths.
scala> Digraph.fromStringLabel("[p>q/9, m>q/7, k, p>m/5]").findPaths("p", "q") res0: List[List[String]] = List(List(p, q), List(p, m, q)) scala> Digraph.fromStringLabel("[p>q/9, m>q/7, k, p>m/5]").findPaths("p", "k") res1: List[List[String]] = List()
findCycles
to find closed paths
(cycles) starting at a given node in a graph. The method should return
all cycles.
scala> Graph.fromString("[b-c, f-c, g-h, d, f-b, k-f, h-g]").findCycles("f") res0: List[List[String]] = List(List(f, c, b, f), List(f, b, c, f))
spanningTrees
to construct all spanning trees of a
given graph. With this method, find out how many spanning trees there
are for the graph depicted to the right. The data of this example graph
can be found below. When you have a correct solution for
the spanningTrees
method, use it to define two other useful
methods: isTree
and isConnected
. Both are
five-minute tasks!
Graph:
Graph.term(List('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'), List(('a', 'b'), ('a', 'd'), ('b', 'c'), ('b', 'e'), ('c', 'e'), ('d', 'e'), ('d', 'f'), ('d', 'g'), ('e', 'h'), ('f', 'g'), ('g', 'h')))
scala> Graph.fromString("[a-b, b-c, a-c]").spanningTrees res0: List[Graph[String,Unit]] = List([a-b, b-c], [a-c, b-c], [a-b, a-c])
minimalSpanningTree
to construct the minimal
spanning tree of a given labeled graph. Hint: Use Prim's Algorithm. A
small modification of the solution of P83 does the
trick. The data of the example graph to the right can be found below.
Graph:
Graph.termLabel( List('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'), List(('a', 'b', 5), ('a', 'd', 3), ('b', 'c', 2), ('b', 'e', 4), ('c', 'e', 6), ('d', 'e', 7), ('d', 'f', 4), ('d', 'g', 3), ('e', 'h', 5), ('f', 'g', 4), ('g', 'h', 1)))
scala> Graph.fromStringLabel("[a-b/1, b-c/2, a-c/3]").minimalSpanningTree res0: Graph[String,Int] = [a-b/1, b-c/2]
Write a method that determines whether two graphs are isomorphic.
scala> Graph.fromString("[a-b]").isIsomorphicTo(Graph.fromString("[5-7]")) res0: Boolean = true
Node.degree
that determines the degree
of a given node.
scala> Graph.fromString("[a-b, b-c, a-c, a-d]").nodes("a").degree res0: Int = 3
b) Write a method that lists all nodes of a graph sorted according to decreasing degree.
scala> Graph.fromString("[a-b, b-c, a-c, a-d]").nodesByDegree res1: List[Graph[String,Unit]#Node] = List(Node(a), Node(c), Node(b), Node(d))
c) Use Welsh-Powell's algorithm to paint the nodes of a graph in such
a way that adjacent nodes have different colors. Make a
method colorNodes
that returns a list of tuples, each of
which contains a node and an integer representing its color.
scala> Graph.fromString("[a-b, b-c, a-c, a-d]").colorNodes res2: List[(Graph[String,Unit]#Node,Int)] = List((Node(a),1), (Node(b),2), (Node(c), 3), (Node(d), 2))
scala> Graph.fromString("[a-b, b-c, e, a-c, a-d]").nodesByDepthFrom("d") res0: List[String] = List(c, b, a, d)
scala> Graph.fromString("[a-b, c]").splitGraph res0: List[Graph[String,Unit]] = List([a-b], [c])
scala> Digraph.fromString("[a>b, c>a, d>b]").isBipartite res0: Boolean = true scala> Graph.fromString("[a-b, b-c, c-a]").isBipartite res1: Boolean = false scala> Graph.fromString("[a-b, b-c, d]").isBipartite res2: Boolean = true scala> Graph.fromString("[a-b, b-c, d, e-f, f-g, g-e, h]").isBipartite res3: Boolean = false
The complete source file for this section is graph.scala.
Hint: Represent the positions of the queens as a list of numbers
1..N. Example: List(4, 2, 7, 3, 6, 8, 5, 1)
means
that the queen in the first column is in row 4, the queen in the
second column is in row 2, etc. Use the generate-and-test paradigm.
Hints: Represent the squares by pairs of their coordinates of the form (X, Y), where both X and Y are integers between 1 and N. (Alternately, define a Point class for the same purpose.) Write a function jumps(N, (X, Y)) to list the squares that a knight can jump to from (X, Y) on a NÃ—N chessboard. And finally, represent the solution of our problem as a list of knight positions (the knight's tour).
It might be nice to find more than one tour, but a computer will take a long time trying to find them all at once. Can you make a lazy list that only calculates the tours as needed?
Can you find only "closed tours", where the knight can jump from its final position back to its starting position?
Anyway the puzzle goes like this: Given a tree with N nodes (and hence N-1 edges), find a way to enumerate the nodes from 1 to N and, accordingly, the edges from 1 to N-1 in such a way, that for each edge K the difference of its node numbers is equal to K. The conjecture is that this is always possible.
For small trees the problem is easy to solve by hand. However, for larger trees, and 14 is already very large, it is extremely difficult to find a solution. And remember, we don't know for sure whether there is always a solution!
Write a function that calculates a numbering scheme for a given tree. What is the solution for the larger tree pictured below?
List(2,3,5,7,11)
we can form the equations 2-3+5+7
= 11 or 2 = (3*5+7)/11 (and ten others!).Problem statement Solution . . 4 | 8 . . | . 1 7 9 3 4 | 8 2 5 | 6 1 7 | | | | 6 7 . | 9 . . | . . . 6 7 2 | 9 1 4 | 8 5 3 | | | | 5 . 8 | . 3 . | . . 4 5 1 8 | 6 3 7 | 9 2 4 --------+---------+-------- --------+---------+-------- 3 . . | 7 4 . | 1 . . 3 2 5 | 7 4 8 | 1 6 9 | | | | . 6 9 | . . . | 7 8 . 4 6 9 | 1 5 3 | 7 8 2 | | | | . . 1 | . 6 9 | . . 5 7 8 1 | 2 6 9 | 4 3 5 --------+---------+-------- --------+---------+-------- 1 . . | . 8 . | 3 . 6 1 9 7 | 5 8 2 | 3 4 6 | | | | . . . | . . 6 | . 9 1 8 5 3 | 4 7 6 | 2 9 1 | | | | 2 4 . | . . 1 | 5 . . 2 4 6 | 3 9 1 | 5 7 8
Every spot in the puzzle belongs to a (horizontal) row and a (vertical) column, as well as to one single 3Ã—3 square (which we call "square" for short). At the beginning, some of the spots carry a single-digit number between 1 and 9. The problem is to fill the missing spots with digits in such a way that every number between 1 and 9 appears exactly once in each row, in each column, and in each square.
The puzzle goes like this: Essentially, each row and column of a rectangular bitmap is annotated with the respective lengths of its distinct strings of occupied cells. The person who solves the puzzle must complete the bitmap given only these lengths.
Problem statement: Solution: |_|_|_|_|_|_|_|_| 3 |_|X|X|X|_|_|_|_| 3 |_|_|_|_|_|_|_|_| 2 1 |X|X|_|X|_|_|_|_| 2 1 |_|_|_|_|_|_|_|_| 3 2 |_|X|X|X|_|_|X|X| 3 2 |_|_|_|_|_|_|_|_| 2 2 |_|_|X|X|_|_|X|X| 2 2 |_|_|_|_|_|_|_|_| 6 |_|_|X|X|X|X|X|X| 6 |_|_|_|_|_|_|_|_| 1 5 |X|_|X|X|X|X|X|_| 1 5 |_|_|_|_|_|_|_|_| 6 |X|X|X|X|X|X|_|_| 6 |_|_|_|_|_|_|_|_| 1 |_|_|_|_|X|_|_|_| 1 |_|_|_|_|_|_|_|_| 2 |_|_|_|X|X|_|_|_| 2 1 3 1 7 5 3 4 3 1 3 1 7 5 3 4 3 2 1 5 1 2 1 5 1
For the example above, the problem can be stated as the two lists
[[3],[2,1],[3,2],[2,2],[6],[1,5],[6],[1],[2]]
and
[[1,2],[3,1],[1,5],[7,1],[5],[3],[4],[3]]
which give the
"solid" lengths of the rows and columns, top-to-bottom and
left-to-right, respectively. Published puzzles are larger than this
example, e.g. 25Ã—20, and apparently always have unique solutions.
The particular crossword puzzle is specified in a text file which first lists the words (one word per line) in an arbitrary order. Then, after an empty line, the crossword framework is defined. In this framework specification, an empty character location is represented by a dot (.). In order to make the solution easier, character locations can also contain predefined character values. The puzzle opposite is defined in the file p99a.dat, other examples are p99b.dat and p99d.dat. There is also an example of a puzzle (p99c.dat) which does not have a solution.
Words are strings of at least two characters. A horizontal or vertical sequence of character places in the crossword puzzle framework is called a site. Our problem is to find a compatible way of placing words onto sites.
Hints: (1) The problem is not easy. You will need some time to thoroughly understand it. So, don't give up too early! And remember that the objective is a clean solution, not just a quick-and-dirty hack!
(2) For efficiency reasons it is important, at least for larger puzzles, to sort the words and the sites in a particular order. For this part of the problem, the solution of P28 may be very helpful.


| DOSE: |
repeated |
oral |
Kratom |
(daily) |
I've used kratom tea since about spring of 2004 in an attempt to stop a drinking habit that had gotten out of hand. I found kratom to completely mute alcohol cravings -- something that had always beaten prior attempts to moderate or stop drinking. I have to give kratom total credit for my not drinking, or even really wanting to drink, since then.
However, on the down side, I broke the rules of kratom use and began to drink it every day. So, of course, I became addicted to kratom. I've decided to give it up entirely since I can't seem to moderate well. I'm now going through the withdrawal which so far has been only slightly miserable. At the end of week one I've had mild craving (though not for alcohol, just kratom), extreme fatigue, some depression. According to other reports I've seen, I can expect worse depression next week. But so far, my experience in quitting kratom has been easier than the others I've read about.
Anyhow, I would do it again -- use kratom to quit drinking. If I ever decide to use it again (assuming it remains legal), I will not let myself use it more than once a week at most.
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


Organizing Controllers¶
When your application starts to define too many controllers, you might want to group them logically:
// define controllers for a blog
$blog = $app['controllers_factory'];
$blog->get('/', function () {
return 'Blog home page';
});
// ...
// define controllers for a forum
$forum = $app['controllers_factory'];
$forum->get('/', function () {
return 'Forum home page';
});
// define "global" controllers
$app->get('/', function () {
return 'Main home page';
});
$app->mount('/blog', $blog);
$app->mount('/forum', $forum);
// define controllers for an admin
$app->mount('/admin', function ($admin) {
// recursively mount
$admin->mount('/blog', function ($user) {
$user->get('/', function () {
return 'Admin Blog home page';
});
});
});
Note
$app['controllers_factory']
is a factory that returns a new instance
of ControllerCollection
when used.
mount()
prefixes all routes with the given prefix and merges them into the
main Application. So, /
will map to the main home page, /blog/
to the
blog home page, /forum/
to the forum home page, and /admin/blog/
to the
admin blog home page.
Caution
When mounting a route collection under /blog
, it is not possible to
define a route for the /blog
URL. The shortest possible URL is
/blog/
.
Note
When calling get()
, match()
, or any other HTTP methods on the
Application, you are in fact calling them on a default instance of
ControllerCollection
(stored in $app['controllers']
).
Another benefit is the ability to apply settings on a set of controllers very easily. Building on the example from the middleware section, here is how you would secure all controllers for the backend collection:
$backend = $app['controllers_factory'];
// ensure that all controllers require logged-in users
$backend->before($mustBeLogged);
Tip
For a better readability, you can split each controller collection into a separate file:
// blog.php
$blog = $app['controllers_factory'];
$blog->get('/', function () { return 'Blog home page'; });
return $blog;
// app.php
$app->mount('/blog', include 'blog.php');
Instead of requiring a file, you can also create a Controller provider.


My Library Portal
Home
API Documentation
Book Title:
Book Author:
Release Date:
Genre:
Fiction
Non-Fiction
Rating:
Language of book:
All Stored Books Information


Wendy Williams Takes Swipe At ‘Sexiest Man Alive’ John Legend, Says Jason Momoa Gets Her Vote
by Becca LongmireWendy Williams had a few things to say about John Legend nabbing People‘s “Sexiest Man Alive” honour during her show Wednesday.
According to toofab, Williams insisted she liked Legend and his wife Chrissy Teigen as a couple but not separately.
She told viewers, “Like, they’re short and they’re thin. I love them together, but not apart.”
Williams added, “You know who I like and he’s not even the ‘Sexiest Man Alive’. I normally don’t like facial hair, but in new life, I’m meeting a lot of new men. If I could think of one person it would be Jason Momoa. Anyway, but congratulations, John.”
But that wasn’t all she had to say about Legend nabbing the title.
“When I think about a sexy man, I’m not thinking John Legend. The first thing I think of is that I weigh so much more than him. If we were walking down the street and somebody wanted to spray me with a water gun, I need a man that’s going to punch someone in the face. You know what I mean?
“If I’m not quite feeling right after leaving the club, I need a man to throw me over his shoulder and say, ‘Come on girl.’ John is not that guy. But congratulations, Jonathan.”


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <float.h>
#include "dalclient.h"
Functions | |
| char * | scsp_getQueryURL (dalQuery_t *query) |
| void | scsp_initProperties (dalQR_t *qr) |
Most of the DALClient code is generic and common to all service types. The files dalSCSP (cone simple search), dalSIAP (simple image access), and so forth contain the protocol-specific code for each class of service. In particular this is where we deal with multiple versions of the VO prtotocols, and shielding the client from the details of the VO protocols as they evolve.
The Simple Cone Search protocol (SCSP) is used to query arbitrary astronomical catalogs for all records for which the position described by the object in a record (table row) falls within the circular region centered at RA,DEC with radius SR.
------ Query Parameters ---------
The following standard query parameters are recognized by the SCSP driver and may be used for custom protocol-specific translation. All other query parameters are merely passed through to the remote service.
RA Right ascension (ICRS, decimal degrees) DEC Declination (ICRS, decimal degrees) SR Search radius (decimal degrees)
POS-object Not yet implemented. This will be a generic spatial region object that gets translated into whatever the specific protocol requires, in this case ra,dec,sr.
------ Object Properties ---------
Cone search is used for catalog queries hence there is no real object data model for which to define properties, however the following properties are defined to describe table rows, and the protocol itself:
protocol Protocol implemented ("SCS") version Protocol version ("1.0")
id Unique key for table row / object (ID_MAIN) ra Right ascension dec Declination
------ SCSP routines (internal) ---------
str = scsp_getQueryURL (query) void scsp_initProperties (qr)
The routines in this file are internal to the DALClient code and are not intended to be called directly by applications.


split2020(3f) - [M_strings:TOKENS] parse a string into tokens using proposed f2023 method (LICENSE:PD)
Synopsis
Description
Options
Examples
Author
License
Version
TOKEN form
subroutine split2020 (string, set, tokens, separator) character(len=*),intent(in) :: string character(len=*),intent(in) :: set character(len=:),allocatable,intent(out) :: tokens(:) character(len=1),allocatable,intent(out),optional :: separator(:)BOUNDS ARRAY form
subroutine split2020 (string, set, first, last) character(len=*),intent(in) :: string character(len=*),intent(in) :: set integer,allocatable,intent(out) :: first(:) integer,allocatable,intent(out) :: last(:)STEP THROUGH BY POSITION form
subroutine split2020 (string, set, pos [, back]) character(len=*),intent(in) :: string character(len=*),intent(in) :: set integer,intent(inout) :: pos logical,intent(in),optional :: back
Parse a string into tokens. STRING, SET, TOKENS and SEPARATOR must all be of the same CHARACTER kind type parameter.
STRING string to break into tokens SET Each character in SET is a token delimiter. A sequence of zero or more characters in STRING delimited by any token delimiter, or the beginning or end of STRING, comprise a token. Thus, two consecutive token delimiters in STRING, or a token delimiter in the first or last character of STRING, indicate a token with zero length. ??? how about if null defaults to all whitespace characters
TOKENS It is allocated with the lower bound equal to one and the upper bound equal to the number of tokens in STRING, and with character length equal to the length of the longest token. The tokens in STRING are assigned by intrinsic assignment, in the order found, to the elements of TOKENS, in array element order. ???If input is null it still must be of size 1?
SEPARATOR Each element in SEPARATOR(i) is assigned the value of the ith token delimiter in STRING. It is allocated with the lower bound equal to one and the upper bound equal to one less than the number of tokens in STRING, and with character length equal to one. ???one less than?
FIRST It is allocated with the lower bound equal to one and the upper bound equal to the number of tokens in STRING. Each element is assigned, in array element order, the starting position of each token in STRING, in the order found. If a token has zero length, the starting position is equal to one if the token is at the beginning of STRING, and one greater than the position of the preceding delimiter otherwise. LAST It is allocated with the lower bound equal to one and the upper bound equal to the number of tokens in STRING. Each element is assigned, in array element order, the ending position of each token in STRING, in the order found. If a token has zero length, the ending position is one less than the starting position. POS If BACK is present with the value .TRUE., the value If BACK is absent or is present with the value .FALSE., POS is assigned the position of the leftmost token delimiter in STRING whose position is greater than POS, or if there is no such character, it is assigned a value one greater than the length of STRING. This identifies a token with starting position one greater than the value of POS on invocation, and ending position one less than the value of POS on return.
of POS shall be in the range 0 < POS LEN (STRING)+1; otherwise it shall be in the range 0 POS LEN (STRING). If BACK is present with the value true, POS is assigned the position of the rightmost token delimiter in STRING whose position is less than POS, or if there is no such character, it is assigned the value zero. This identifies a token with ending position one less than the value of POS on invocation, and starting position one greater than the value of POS on return.
When SPLIT is invoked with a value for POS of 1 <= POS <= LEN(STRING) and STRING(POS:POS) is not a token delimiter present in SET, the token identified by SPLIT does not comprise a complete token as described in the description of the SET argument, but rather a partial token.
BACK shall be a logical scalar. It is an INTENT (IN) argument. If POS does not appear and BACK is present with the value true, STRING is scanned backwards for tokens starting from the end. If POS does not appear and BACK is absent or present with the value false, STRING is scanned forwards for tokens starting from the beginning.
Sample of uses
program demo_sort2020 use M_strings, only : split2020 implicit none character(len=*),parameter :: gen=(*("[",g0,"]":,","))Results:! Execution of TOKEN form block character (len=:), allocatable :: string character (len=:), allocatable :: tokens(:) character (len=*),parameter :: set = " ," string = first,second,third call split2020(string, set, tokens ) write(*,gen)tokens
! assigns the value [first ,second,third ] ! to TOKENS. endblock
! Execution of BOUNDS form
block character (len=:), allocatable :: string character (len=*),parameter :: set = " ," integer, allocatable :: first(:), last(:) string = first,second,,forth call split2020 (string, set, first, last) write(*,gen)first write(*,gen)last
! will assign the value [ 1, 7, 14, 15 ] to FIRST, ! and the value [ 5, 12, 13, 19 ] to LAST. endblock
! Execution of STEP form block character (len=:), allocatable :: string character (len=*),parameter :: set = " ," integer :: p, istart, iend string = " one, last example " do while (p < len(string)) istart = p + 1 call split2020 (string, set, p) iend=p-1 if(iend > istart)then print (t3,a,1x,i0,1x,i0), string (istart:iend),istart,iend endif enddo endblock end program demo_sort2020
[first ],[second],[third ] [1],[7],[14],[15] [5],[12],[13],[19] one 2 4 last 9 12 example 15 21> ??? option to skip adjacent delimiters (not return null tokens) > common with whitespace > ??? quoted strings, especially CSV both " and , Fortran adjacent > is insert versus other rules > ??? escape character like \\ . > ??? multi-character delimiters like \\n, \\t, > ??? regular expression separator
Milan Curcic<EMAIL_ADDRESS>version 0.1.0, copyright 2020, Milan Curcic
| Nemo Release 3.1 | split2020 (3) | July 22, 2023 |


You can buy more Space Diamonds with Ether. The current price per Space Diamond is {{tokenPrice$ | async}} Wei. Excessive Ether will not be returned.


Note: The ability to click or press a label
to trigger an event on a control provides
usability and accessibility benefits by increasing the hit area of a control, making it easier for a user to operate.
These benefits may be lost or reduced, if the label
element contains an element with its own activation
behavior, such as a link:
 <input type=checkbox name=tac>I agree to the terms and conditions
 <input type=checkbox name=tac>I agree to the terms and conditions
The usability and accessibility benefits can be maintained by placing such elements outside the label
element:
 <input type=checkbox name=tac>I agree to the terms and conditions (read Terms and Conditions)


Careful Declaration
问题描述 :
To calm down their clients, the banks and governments may issue various declarations stating that there is really nothing to worry about. It is very important for such declarations to be consistent, otherwise the people may not believe them.
Imagine that we have two declarations, one suggested by a bank and the other coming from the government. They finally decided to merge those two declarations into a single one and issue it together. (People may think there is some problem if there are too many declarations.) Both the bank and the government insist that the common declaration must contain the whole text of their original declarations.
Your task is to create the joint declaration that will be issued at a press conference tonight. The main condition is that the resulting text must contain all words from the two original proposals, in the same order. Also, we have to keep the declaration as short as possible.
输入:
There is one additional line with a single dot after the last test case in the input.
输出:
There is one additional line with a single dot after the last test case in the input.
样例输入:
all our banks are sound and safe . all deposits in our bank are safe do not worry . everything fine firmly under control . deposits in bank abc are fine like nothing is . .
样例输出:
all deposits in our bank banks are sound and safe do not worry . deposits everything in bank abc are fine firmly like nothing is under control .
看我二级跳跃
看我二级跳跃
看我二级跳跃
看我二级跳跃
看我二级跳跃
看我二级跳跃
看我二级跳跃
看我二级跳跃
看我二级跳跃
看我二级跳跃
看我二级跳跃
看我二级跳跃
看我二级跳跃
排版
博主，你这个是wordpress哪个主题啊，不错哦~
这代码的输出格式不对阿，else语句的low=p移动一下位置，增加可读性
…. 配图居然是没方向的。。
88行是多余的，可以删除
mark, 备用
Java真是解决大数的利器
这张页面太松散拉，重新编辑一下，弄紧凑一点。
为什么暴力求解方法循环到sqrt(n) 就可以了呢
分析的很详细！赞一个
看来学好代数很重要啊
请不要灌水，多谢！
Java真是解决大数的利器


%= processTemplate('_head') %>
Established in 1899
We proudly serve the greater Atlanta area. Choose a county below to find your neighborhood.
About
Specials


Week3 Notes of "Data Structures And Types" -- "Functional Programming in Haskell" MOOC
Contents
Functions on Lists
Recursion and lists
- Every list must be either
-
[]
or
-
(x:xs)
for some x
(the head
of the list) and xs
(the tail
) where (x:xs)
is pronounced as x cons xs
.
- The recursive definition follows the structure of the data:
- Base case of the recursion is
[]
.
- Recursion (or induction) case is
(x:xs)
.
length
function
- Recursive definition of
length
:
length :: [a] -> Int
length [] = 0 # base case
length (x:xs) = 1 + length xs # recursion case
filter
function
-
filter
is given a predicate (a function that gives a Boolean result) and a list, and returns a list of the elements that satisfy the predicate.
filter :: (a->Bool) -> [a] -> [a]
filter (<5) [3,9,2,12,6,4] -- > [3,2,4]
- Recursive definition of
filter
:
filter :: (a -> Bool) -> [a] -> [a]
filter pred [] = []
filter pred (x:xs)
| pred x = x : filter pred xs
| otherwise = filter pred xs
Computations over lists
-
for
/ while
loops in an imperative language are naturally expressed as list computations in a functional language.
- Perform a computation on each element of a list:
map
- Iterate over a list:
- from left to right:
foldl
;
- from right to left:
foldr
Function composition
- Express a large computation by "chaining together" a sequence of functions that perform smaller computations.
- The entire computation (first
g
, then f
) is written as f ∘ g
(traditional mathematical notation).
- In
f ∘ g
, the functions are used in right to left order.
- Haskell uses
.
as the function composition operator.
(.) :: (b->c) -> (a->b) -> a -> c
(f . g) x = f (g x)
map
function
-
map
applies a function to every element of a list.
map f [x0,x1,x2] -- > [f x0, f x1, f x2]
- Common style is to define a set of simple computations using
map
, and to compose them.
map f (map g xs) = map (f . g) xs
- Recursive definition of
map
:
map :: (a -> b) -> [a] -> [b]
map _ [] = []
map f (x:xs) = f x : map f xs
Folding a list (reduction)
- An iteration over a list to produce a singleton value is called a
fold
.
Left fold: foldl
-
foldl
is fold from the left.
- Typical application is
foldl f z xs
- The
z::b
is an initial value [or can be treated as an accumulator].
- The
xs::[a]
argument is a list of values which we combine systematically using the supplied function f
.
- Recursive definition of
foldl
:
foldl :: (b -> a -> b) -> b -> [a] -> b
foldl f z0 xs0 = lgo z0 xs0
where
lgo z [] = z
lgo z (x:xs) = lgo (f z x) xs
- Example of
foldl
function with (+)
as infix function:
foldl (+) z [x0,x1,x2] -- > ((z + x0) + x1) + x2
- Or
foldl
function can be summarized as:
foldl f z [x0,x1,x2] -- > f (f (f z x0) x1) x2
Right fold: foldr
- Similar to
foldl
, but foldr
is fold from the right to left.
- typical application is
foldr f z xs
- The
z::b
is an initial value [or can be treated as an accumulator].
- The
xs::[a]
argument is a list of values which we combine systematically using the supplied function f
.
- Recursive definition of
foldl
:
foldr :: (a -> b -> b) -> b -> [a] -> b
foldr k z = go
where
go [] = z
go (y:ys) = y `k` go ys
- Example of
foldr
function with (+)
as infix function:
foldr (+) z [x0,x1,x2] -- > x0 + (x1 + (x2 + z))
- Or
foldr
function can be summarized as:
foldr f z [x0,x1,x2] -- > f x0 (f x1 (f x2 z))
- A list can be constructed with
foldr
as foldr cons [] xs = xs
.
foldr (:) [] [x0,x1,x2] -- > x0 : x1 : x2 : []
sum xs = foldr (+) 0 xs
product xs = foldr (*) 1 xs
Maps and Folds versus Loops
- For list operations, it is usually easier to use higher-order functions like:
-
map
for performing an operation on every element of a list
-
foldl
/ foldr
for reducing a list to a single value.
- Sometimes these functions are referred to as list combinators.
-- a list
lst = [1.. 10]
-- map
f x = x * (x + 1)
lst_ = map f lst
-- foldl
g = (/)
accl = foldl g 1 lst -- > ((((((((((1 / 1) / 2) / 3) / 4) / 5) / 6) / 7) / 8) / 9) / 10) = 2.7557319223985894e-7
-- foldr
g' = (/)
accr = foldr g' 1 lst -- > 1 / (2 / (3 / (4 / (5 / (6 / (7 / (8 / (9 / (10 / 1))))))))) = 0.24609375
-- main
main = do
print lst_ -- > [2.0,6.0,12.0,20.0,30.0,42.0,56.0,72.0,90.0,110.0]
print accl -- > 2.7557319223985894e-7
print accr -- > 0.24609375
Summary of Map and Folds
-
map
: loop over list element-by-element, append new element to new list.
-
foldl
: loop over list element-by-element, update accumulator using current accumulator and element.
-
foldr
: loop over reverse list element-by-element, update accumulator using current accumulator and element.
map :: (a -> b) -> [a] -> [b]
foldl :: (b -> a -> b) -> b -> [a] -> b
foldr :: (a -> b -> b) -> b -> [a] -> b
Custom Data Types
User defined data types
- Combining the basic types [like Int, Bool, etc] we can generate custom data types, using algebraic sums and products.
- Custom data types are called algebraic data types.
- Keyword
data
indicates we are defining a new type.
- The name of the type and the names of the values should start with capital letters.
Sum Data Type
- The alternative values are separated with a vertical bar character (
|
).
- The alternative values relate to algebraic sums.
-
deriving Show
is required for printing values of custom data types.
data SimpleNum = One | Two | Many deriving Show
let convert 1 = One
convert 2 = Two
convert _ = Many
:t One -- > One :: SimpleNum
convert 1 -- > One
convert 50 -- > Many
map convert [1..5] -- > [One, Two, Many, Many, Many]
Record or Product Data Type
- Stores portfolio of values.
- The record values relate to algebraic products.
data CricketScore = Score [Char] Int Int deriving Show
let x = Score "England" 255 10
:t x -- > CricketScore
Type Classes
- The type class constrains member types to provide functions that conform to certain type signatures effectively, API constraints.
- Type classes are like interfaces in Java.
- Types in the type class are like concrete implementations of the interface.
- Type classes provide a neat mechanism to enable operator overloading in Haskell.
- A Type class is a generalized family of similar types.
-
Num
is a type class, which specifies a family of types including integer and floating-point types.
- With
Eq
type class, we can compare values of such types equality with the (==
) operator.
- With
Ord
type class, we can order values of such types with relational operators like less than (<
) and greater than (>
).
- For strings, less than (
<
) implements a lexicographic ordering.
- With
Show
type class, we can generate string values that represent values of such types, like toString()
in Java.
- With
Read
type class, we can generate values of such types from string values.
data SimpleNum = One | Two | Many deriving (Eq, Ord, Show, Read)
-- Show
show One -- > "One"
show Many -- > "Many"
-- Read
read "One" :: SimpleNum -- > One
-- Eq
One == One -- > True
One == Two -- > False
-- Ord
One <= Two -- > True
:t (+) -- > (+) :: Num a => a -> a -> a
:t (==) -- > (==) :: Eq a => a -> a -> Bool
:t (<) -- > (<) :: Ord a => a -> a -> Bool
Haskell History


initialize method
Initialize FawryPay payment charge.
Initialize the payment charge by adding some parameters.
Returns true
if it initialized fine.
Throws exception if not.
merchantID
sets the merchantID that you have received from Fawry.
items
sets the list of items that the user will pay for.
merchantRefNumber
sets an optional number consists of 16 random characters and numbers.
language
sets the language of payment, whether English or Arabic, default English.
environment
sets the environment of payment, whether Test or Live, default Test.
customParam
sets a map of custom data you want to receive back with result data after payment.
Implementation
Future<bool> initialize({
@required String merchantID,
@required List<FawryItem> items,
String merchantRefNumber,
Language language = Language.EN,
Environment environment = Environment.TEST,
Map<String, dynamic> customParam,
}) async {
try {
return await _channel.invokeMethod(_METHOD_INITIALIZE, <String, dynamic>{
'merchantID': merchantID,
'items': items.map((e) => e.toJSON()).toList(),
'merchantRefNumber': merchantRefNumber,
'language': language.toString(),
'environment': environment.toString(),
'customParam': customParam,
});
} on PlatformException catch (e) {
if (e.code == _ERROR_INITIALIZE)
throw "Error Occurred: Code: $_ERROR_INITIALIZE. Message: ${e.message}. Details: SDK Initialization Error";
throw "Error Occurred: Code: ${e.code}. Message: ${e.message}. Details: ${e.details}";
} catch (e) {
throw "Error Occurred: $e";
}
}


My name is Catherine Wong, a certified money coach and financial counselor.  Money is a foundational tool that you need to know and have enough of to succeed in life. Email me for a free 25 minute conversation!


Jeffrey Zeldman
August 5th, 9-10 AMJeffrey Zeldman is a web designer and author. He has founded two design studios, and a magazine, and has written several books.
Jeffrey Zeldman is a web designer and author. He has founded two design studios, and a magazine, and has written several books.


Pokello warriors’ visit criticism intensifies after drab draw with Botswana
Angry fans disappointed by the Zimbabwe Warriors draw with Botswana in an AFCON tie came out guns blazing attacking socialite Pokello Nare’s visit to their camp as the reason for the drab draw.
by Marshall BwanyaDisgruntled fans took to social media to vent out their anger bombarding Nare with inflammatory obscenities while labeling her visit to the camp retrogressive for Zimbabwean soccer.

Related Articles
Pokello criticised over Warriors visit
Nov 15, 2019 80,116 154
Gringo blames piracy for his financial woes
Oct 22, 2019 28,470 24
Oct 18, 2019 39,492 10
Pokello, Jackie Ngarande rescue Gringo
Oct 18, 2019 46,266 34
Facebook user Inini ndini in Mugadza posted a derogatory meme featuring Khama Billiat showing an intrigued attentive Nare his tattoos that read:
“Pokello competing to become the goal posts if you know you know nyaya yangu ndatopedza.”
Nare’s Warriors visit has been viewed as a distraction that instilled misplaced priorities on the players contributing to yesterday’s poor result.
Former legendary Warriors left back George Mbwando also criticised Nare’s warriors visit as unprofessional conduct that jeopardized the national team’s integrity.
“If Pokello is allowed in Camp then that’s not a camp…call it something else, in our days this would never happen,” he said.
The general view of most soccer stakeholders is that the warriors camp is not a recreational leisure spot for taking pictures to gain traction on social media. Nehanda Radio


--- title: Playing Creative Atrocities ---
Let me in!
I'm going with this!
Go back!
Are you sure you want to leave the game?
Go back! Leave!
Close the browser window and find another game invite to scan.


Mar 27, 2021
How to start using hot songs. Why billboard music awards are the new black. What the world would be like if top new songs didn’t exist. The best ways to utilize rock bands. How free dances make you a better lover. 6 ideas you can steal from popular songs. Expose: you’re losing money by not using concert events. 20 facts about music festivals that’ll keep you up at night. What the world would be like if radio stations didn’t exist. How twitter can teach you about billboard music awards.
16 ways free songs can find you the love of your life. Why rock fame is the new black. The only latin instrument resources you will ever need. 19 ways music festivals can find you the love of your life.  How free dances make you a better lover. The 7 best resources for country music festivals. How country music festivals aren’t as bad as you think. 12 facts about top new songs that will impress your friends. How hot songs are making the world a better place.
Why music festivals are the new black. The complete beginner’s guide to live shows. Why music scores beat peanut butter on pancakes. Why rock bands will make you question everything. Top new songs in 14 easy steps. How radio stations can make you sick. 15 amazing rock fame pictures. 13 things you don’t want to hear about top country songs. 6 facts about country song ringtones that will impress your friends. How to be unpopular in the rock band world.
12 ways rock fame is completely overrated. The best ways to utilize top new songs. 15 great articles about radio stations. How hollywood got piano stores all wrong. Why our world would end if free songs disappeared. Why your music festival never works out the way you plan. 13 problems with billboard music awards. 10 facts about free dances that will impress your friends. How music notes aren’t as bad as you think. 15 things that won’t happen in latin music videos
Sharing is caring!


If the executive or board contact information has inaccuracy please update personnel contact information for your organization before submitting this program application.


Documents Uploaded.
Please upload {{MaxDocs - DocLength}} document{{MaxDocs - DocLength > 1 ? 's' : ''}}
Verified: {{Verified / MaxDocs * 100}}%
Documents
Verified


Comments
-
Greg Hurrell
This is a duplicate of feature request #1746 so I am going to mark this one as closed.
As I said in that ticket, I am not much of a tags user myself (I would be, but I've never been able to get tags working properly in a Ruby on Rails project). As such, I'm not really in a position to develop and test this feature myself.
You're welcome to have a try at it. Check out the Git repo and look at how the buffer search was added, and more recently, the jumplist navigation. I suspect that you might be able to get the output of
:tags
and use that (or something similar, I'm really not familiar with Vim's tag-related commands); but basically you just want to get a list of all tags and then let Command-T do its thing.Getting it to not only jump to the right file, but also the right line within a file, is probably going to be trickier, as Command-T has only ever cared about opening files and buffers. I think just opening the file with the tag in it is a reasonable start though.
Anyway, as I said, this ticket is a duplicate so please continue any further conversation about the issue over on ticket #1746.
-
Greg Hurrell
Status changed:
- From: new
- To: closed
Add a comment
Comments are now closed for this issue.


The Line Item Display capabilities of the Genius solution are encapsulated within a TCayanGeniusLineItems component. This gets attached to a corresponding TCayanGeniusTransaction component.
This component is responsible for handling Line Item Display on the Genius CED payment terminal. You can only use one instance of this component per CED at a time.


Elbakyan was born in Almaty, Kazakhstan on 6 November, 1988. She is of Armenian, Slavic, and Asian descent.Elbakyan undertook university studies in Almaty, where she developed skills in computer hacking. A year working in computer security in Moscow gave her the finances to proceed to Freiburg in 2010 to work on a brain–computer interface project, and she developed an interest in transhumanism, which led her to a summer internship at Georgia Institute of Technology in the United States, where she studied "Neuroscience and Consciousness".In 2009 she obtained a Bachelor of Science degree in computer science from the Kazakh National Technical University, specializing in information security.
Elbakyan has stated that she is inspired by communist ideals, although she does not consider herself a strict Marxist. She has stated that she supports a strong state which can stand up to the Western world, and that she does not want for "the scientists of Russia and of my native Kazakhstan to share the fates of the scientists of Iraq, Libya, and Syria, that were 'helped' by the USA to become more democratic"
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia neque assumenda ipsam nihil, molestias magnam, recusandae quos quis inventore quisquam velit asperiores, vitae? Reprehenderit soluta, eos quod consequuntur itaque. Nam.
Close ProjectLorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia neque assumenda ipsam nihil, molestias magnam, recusandae quos quis inventore quisquam velit asperiores, vitae? Reprehenderit soluta, eos quod consequuntur itaque. Nam.
Close ProjectLorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia neque assumenda ipsam nihil, molestias magnam, recusandae quos quis inventore quisquam velit asperiores, vitae? Reprehenderit soluta, eos quod consequuntur itaque. Nam.
Close Project


default
[round]
[rounded]
default
[flat]
[plain]
[plain]
button[icon]
button i[icon]
edit
button <icon>
button i[icon]
button <icon>
edit
Rounded
Round
Rounded
Round
[text]
[text][icon]
TODO: another class like [plain] but with padding on sides. [plain] has no padding which is good for aligning with edges and keylines (like inside card), material spec says there should be 8px.


--- layout: archive title: Zulip Chat Archive permalink: /stream/113488-general/topic/coercions.20from.20polynomials.html ---
import data.mv_polynomial open mv_polynomial variables {k : Type*} [comm_ring k] variable {n : Type*} instance : has_coe_to_fun (mv_polynomial n k) := { F := λ f, (n → k) → k, coe := λ f x, eval x f} def 𝕍 (S : set (mv_polynomial n k)) : set (n → k) := -- {x : n → k | ∀ s ∈ S, s x = 0} -- doesn't work -- {x : n → k | ∀ s ∈ S, s.eval x = 0} -- also doesn't work {x : n → k | ∀ s ∈ S, eval x s = 0} -- works BUT VARIABLES IN STUPID ORDER!
If s is a polynomial and x is some assignment of the variables, I want to write s(x)
to be the evaluation of the polynomial at the assignment of the variables. As does every mathematician. Why am I failing in the above?
eval x
is a ring hom. That's why they're in the current order.
I don't understand why s.eval x = 0
fails. Is this an issue with the elaborator?
It's because of ∀ s ∈ S
, I think.
If you would write ∀ f, f ∈ S → f.eval x = 0
, I think it would work
But of course that is ugly
At least∀ f : mv_polynomial n k, f ∈ S → f.eval x = 0
should work
If you would write
∀ f, f ∈ S → f.eval x = 0
, I think it would work
It doesn't work for me:
import data.mv_polynomial open mv_polynomial variables {k : Type*} [comm_ring k] variable {n : Type*} instance : has_coe_to_fun (mv_polynomial n k) := { F := λ f, (n → k) → k, coe := λ f x, eval x f} def 𝕍 (S : set (mv_polynomial n k)) : set (n → k) := -- {x : n → k | ∀ f, f ∈ S → f x = 0} -- doesn't work -- {x : n → k | ∀ f, f ∈ S → f.eval x = 0} -- also doesn't work -- {x : n → k | ∀ f ∈ S, eval x f = 0} -- works BUT VARIABLES IN STUPID ORDER! {x : n → k | ∀ f, f ∈ S → eval x f = 0} -- works BUT VARIABLES IN STUPID ORDER!
oh yeah, inference with has_mem is super annoying
When using "forall in" so that I can't write the type, I usually do something like this:
{x : n → k | ∀ f ∈ S, (f : mv_polynomial n k).eval x = 0}
:thumbs_up: But it is still 3.1415 miles away from what mathematicians would write...
Are there examples of has_mem X Y
in mathlib where X
is not uniquely determined by Y
? More precisely, can someone point me to two instances with types has_mem X_1 Y
and has_mem X_2 Y
such that X_1
differs from X_2
?
(The dual case is clear: has_mem X (set X)
and has_mem X (finset X)
, etc... all exist and are desirable.)
X
is an out_param
so I think the case you suggest is not supposed to happen, but I never really understood whether out_param
behaves like I would expect from Haskell
Like here we definitely know that S : set (mv_polynomial n k)
, so there should be no problem inferring f : mv_polynomial n k
and yet here we are
class has_mem' (Y : Type u) := (T : Type u) (mem : T → Y → Prop)
Also I think it would be better if ∈ was not overloaded at all, but only had type a -> set a -> Prop
. The other cases you refer to could be handled using coercions.
after all, a set S is exactly determined by its membership predicate so there is no loss of information this way
Also I think it would be better if ∈ was not overloaded at all, but only had type
a -> set a -> Prop
. The other cases you refer to could be handled using coercions.
But you run the risk that you have to explicitly tell Lean that you want to coerce...
Suppose I write ∀ f ∈ S
, and S : finset X
. Then Lean doesn't know the type of f
yet. It will want to coerce S
to set m_1?
, but probably isn't smart enough to figure out that finset X
only coerces to set X
.
oh this might be an issue, yes, but isn't that already broken?
So you end up writing ∀ f ∈ (S : set (mv_polynomial k n))
, which is what we want to avoid.
Anyways that's the same as the coercion to function issue which will hopefully be fixed in :four_leaf_clover:
Well, not if you allow multiple has_mem
s, I think
What do you think of my has_mem'
?
It's probably broken as well... I dunno
I think this encoding might get annoying in practice because Lean will naturally synthesize a type like (@set.has_mem a).T
and then it will need to be reduced to a
and it might not happen automatically in the right places
Other than that, I think it would work
I think the problem with out_param
was that it kicks in too late. My version would hopefully kick in at the right time
Do whatever you want as long as we don't loose sets being members of a filter.
Patrick, as long as nothing else can be member of a filter, that should be fine.
I wish we could register lookup tables in the parser and/or elaborator. Where you say: Oh, you've got ∀ f ∈ S
? Figure out the type of S
, and I'll look in the table what the type of f
must be.
But that is a very ad hoc thing to do, I guess
Isn't it covered by unification hints?
Je ne sais pas
I don't know either, I'm only trolling.
{% endraw %}Last updated: Apr 24 2020 at 19:02 UTC


Four Tests Two Attributes
There were two different types of tests that were conducted on the subjects to test their reaction time. There was a visual and auditory reaction time test. In the visual test, the subjects went to the website Humanbenchmark.com to take its well crafted reaction time test. After five attempts, the tests will give their average reaction time in milliseconds.
After the visual reaction test, the subjects went on the website, cognitivefun.net. This test was set up to allow the subject to react once a sound was played through the computer. It would then tell how fast your average speed was in reacting in milliseconds as well.
Here are the link to the test if you want to try them yourself:
There were two different types of awareness tests. As like the reaction time tests, the awareness tests also tested visual and auditory awareness. The visual awareness test was a video that created a lot of distraction while the subject had to count how many times the people in the video passed the ball to one another. In the end the subject ahs to guess how many times the ball was passed.
In the auditory reaction test, I created a situation where the subjects had to use hearing to identify how far a certain person is away from them and thier position from the subject. A subject stands in the middle of a ten foot in diameter circle and has to close their eyes. Another person walks arounf them for twenty seconds and after twenty seconds, the subject has to identify how many feet away the subject is from them and which side of they are facing the subject.
Here is a link to the visual awareness test and the auditroy awareness test methodology:


WITNESS LIST Public School Finance, Select Committee May 9, 2002 - 9:00A Public School Finance ON: Anderson, David lawyer (TEA), Austin, TX Kennedy, John Senior Analyst (Texas Taxpayers and Research Assn.), TX Lavine, Dick Fiscal Analyst (Center Public Policy Priorities), Austin, TX Perryman, Ray Economist (Region 17 Schools), Waco, TX Wisnoski, Joe Assistant Commissioner (TEA), Austin, TX


Patient Profile
- First Name<PHONE_NUMBER>
- Birthday: 3rd March
- Phone<PHONE_NUMBER>
- Hospital<EMAIL_ADDRESS>- Address: 714 Burwell Heights Road, Bridge City, TX, 77611
- Last Name<PHONE_NUMBER>
- Gender: Female
- Email<EMAIL_ADDRESS>- Registration ID 3rd March
- Short Biography 714 Burwell Heights Road, Bridge City, TX, 77611


WebGL
Press space for next slide.
Press backspace for previous slide.
WebGL
OpenGL ES 2.0 + JavaScript
<CANVAS>
How do I get it?
Firefox 4 beta or Minefield
WebKit nightly on OS X 10.6
Chromium
khronos.org/webgl/wiki/Getting_a_WebGL_Implementation
IE9 support?
No idea whatsoever.
Chrome Frame?
In HTML
The usual <CANVAS>
Works like an image
CSS, toDataURL(), etc.
OpenGL ES 2.0
OpenGL for mobile phones.
Also works on computers.
Accelerated drawing.
1.1 vs. 2.0
Fixed vs. programmable.
Programmable?
Shaders, baby, yeah!
Massive performance.
No kidding?
1000x faster than JavaScript
(depending on shader)
What's it good for?
Custom 2D drawing.
Custom 3D drawing.
Custom?
Everything requires shaders.
No shortcuts.
Drawing pipeline
Vertex shader
⇓
Fragment shader
⇓
Render target
Vertex shader
Computes
- Where to draw
- Varyings for the fragment shader
Vertex shader
Parameters
- Buffers (vertex arrays)
- Textures (images)
- Uniforms (call parameters)
Fragment shader
Computes
- Color of the pixel
Fragment shader
Parameters
- Varyings from the vertex shader
- Textures
- Uniforms
Render target
<CANVAS>
or
Framebuffer object (FBO)
FBO
In GPU memory
For rendering to textures
Textures
WebGL can load:
- <CANVAS>
- <IMG>
- <VIDEO>
- And pixel arrays.
CANVAS
All the text here.
(CSS 3D would be nicer, but eh.)
IMG
VIDEO
Further reading
learningwebgl.com
Isn't that a bit...
...cumbersome? Yes.
Overkill for simple drawing.
Libraries to the rescue!
Libraries
Alphabetically:
C3DL
CopperLight
CubicVR
GLGE
O3D
SpiderGL
X3DOM
XB PointStream
GLGE
glge.org
SpiderGL
spidergl.org
Games
Google's Quake 2 -port
O3D pool game
Some Q3 map viewers
Applications?
3D model viewers
ChemDoodle molecule visualizer
ShaderToy
WebGL Street View
ChemDoodle
web.chemdoodle.com
ShaderToy
www.iquilezles.org/apps/shadertoy/
Status
WebGL 1.0 soon.
Chrome, Safari, Firefox, Opera(?)
Shader validation with ANGLE.
CPU rendering with OSMESA.
ANGLE?
Almost Native Graphics Layer Engine
angleproject.googlecode.com
OpenGL ES 2.0 interpreter
Interpreter?
Converts WebGL shaders to native.
GLES 2.0 -> OpenGL 2.1
GLES 2.0 -> DirectX 9
OSMESA
Off-Screen MESA GL
Draws on the CPU.
Very slow.
Conclusion
Fast custom drawing.
Quite well supported.
Web-compatible.
Requires programming.
Thank You!
Ilmari Heikkinen
<EMAIL_ADDRESS>Cheats
App.editSlide()
App.toggleAllSlidesVisible()
App.toggleApp()
App.wavyText = false
App.cycleColors = true
txt = App.scene.getNodesByKlass(Magi.MeshText)[0]
txt.alignedNode.material.floats.pitch = 2
txt = App.scene.getNodesByKlass(Magi.MeshText)[2]
App.addDotShader(txt)
txt.alignedNode.material.floats.pitch = 2
The End
Click to return to start.


"State and local police departments obtain some of their military-style equipment through a free Defense Department program created in the early 1990s.
While the portion of their gear that comes from the program is relatively small, detailed data from the Pentagon illustrates how ubiquitous such equipment has become." -
New York Times


Paul McCartney to headline Glastonbury festival
by EndPlayLONDON (AP) - Paul McCartney has snagged the coveted Saturday night headline slot at Glastonbury next year as the British music festival celebrates its 50th birthday.
Festival organizers confirmed Monday that the former Beatle will perform on the main Pyramid Stage on June 27.
McCartney last played Glastonbury in 2004, delivering a set of songs covering the Beatles era, his later work solo and with Wings.
The 77-year-old star tweeted: "Hey Glasto - excited to be part of your Anniversary celebrations. See ya next summer!"
The festival takes over Worthy Farm in southwest England from June 24-28. The 135,000 tickets sold within an hour of going on sale last month.


| Opcode/Instruction | Op/En | 64/32 bit Mode Support | CPUID Feature Flag | Description |
|---|---|---|---|---|
| EAX = 05H ENCLU[EACCEPT] | IR | V/V | SGX2 | This leaf function accepts changes made by system software to an EPC page in the running enclave. |
| Op/En | EAX | RBX | RCX | |
| IR | EACCEPT (In) | Return Error Code (Out) | Address of a SECINFO (In) | Address of the destination EPC page (In) |
This leaf function accepts changes to a page in the running enclave by verifying that the security attributes specified in the SECINFO match the security attributes of the page in the EPCM. This instruction leaf can only be executed when inside the enclave.
RBX contains the effective address of a SECINFO structure while RCX contains the effective address of an EPC page. The table below provides additional information on the memory parameter of the EACCEPT leaf function.
| SECINFO | EPCPAGE (Destination) |
| Read access permitted by Non Enclave | Read access permitted by Enclave |
The instruction faults if any of the following:
| The operands are not properly aligned. | RBX does not contain an effective address in an EPC page in the running enclave. |
| The EPC page is locked by another thread. | RCX does not contain an effective address of an EPC page in the running enclave. |
| The EPC page is not valid. | Page type is PT_REG and MODIFIED bit is 0. |
| SECINFO contains an invalid request. | Page type is PT_TCS or PT_TRIM and PENDING bit is 0 and MODIFIED bit is 1. |
| If security attributes of the SECINFO page make the page inaccessible. |
The error codes are:
| Error Code (see Table 40-4) | Description |
|---|---|
| No Error | EACCEPT successful. |
| SGX_PAGE_ATTRIBUTES_MISMATCH | The attributes of the target EPC page do not match the expected values. |
| SGX_NOT_TRACKED | The OS did not complete an ETRACK on the target page. |
| Leaf | Parameter | Base Concurrency Restrictions | ||
|---|---|---|---|---|
| Access | On Conflict | SGX_CONFLICT VM Exit Qualification | ||
| EACCEPT | Target [DS:RCX] | Shared | #GP | |
| SECINFO [DS:RBX] | Concurrent |
| Leaf | Parameter | Additional Concurrency Restrictions | |||||
|---|---|---|---|---|---|---|---|
| vs. EACCEPT, EACCEPTCOPY, EMODPE, EMODPR, EMODT | vs. EADD, EEXTEND, EINIT | vs. ETRACK, ETRACKC | |||||
| Access | On Conflict | Access | On Conflict | Access | On Conflict | ||
| EACCEPT | Target [DS:RCX] | Exclusive | #GP | Concurrent | Concurrent | ||
| SECINFO [DS:RBX] | Concurrent | Concurrent | Concurrent |
| Name | Type | Size (bits) | Description |
|---|---|---|---|
| TMP_SECS | Effective Address | 32/64 | Physical address of SECS to which EPC operands belongs. |
| SCRATCH_SECINFO | SECINFO | 512 | Scratch storage for holding the contents of DS:RBX. |
IF (DS:RBX is not 64Byte Aligned)
THEN #GP(0); FI;
IF (DS:RBX is not within CR_ELRANGE)
THEN #GP(0); FI;
IF (DS:RBX does not resolve within an EPC)
THEN #PF(DS:RBX); FI;
IF ( (EPCM(DS:RBX &~FFFH).VALID = 0) or (EPCM(DS:RBX &~FFFH).R = 0) or (EPCM(DS:RBX &~FFFH).PENDING ≠ 0) or
(EPCM(DS:RBX &~FFFH).MODIFIED ≠ 0) or (EPCM(DS:RBX &~FFFH).BLOCKED ≠ 0) or
(EPCM(DS:RBX &~FFFH).PT ≠ PT_REG) or (EPCM(DS:RBX &~FFFH).ENCLAVESECS ≠ CR_ACTIVE_SECS) or
(EPCM(DS:RBX &~FFFH).ENCLAVEADDRESS ≠ (DS:RBX & FFFH)) )
THEN #PF(DS:RBX); FI;
(* Copy 64 bytes of contents *)
SCRATCH_SECINFO ← DS:RBX;
(* Check for misconfigured SECINFO flags*)
IF (SCRATCH_SECINFO reserved fields are not zero )
THEN #GP(0); FI;
IF (DS:RCX is not 4KByte Aligned)
THEN #GP(0); FI;
IF (DS:RCX is not within CR_ELRANGE)
THEN #GP(0); FI;
IF (DS:RCX does not resolve within an EPC)
THEN #PF(DS:RCX); FI;
(* Check that the combination of requested PT, PENDING and MODIFIED is legal *)
IF (NOT (((SCRATCH_SECINFO.FLAGS.PT is PT_REG) and
((SCRATCH_SECINFO.FLAGS.PR is 1) or
(SCRATCH_SECINFO.FLAGS.PENDING is 1)) and
(SCRATCH_SECINFO.FLAGS.MODIFIED is 0)) or
((SCRATCH_SECINFO.FLAGS.PT is PT_TCS or PT_TRIM) and
(SCRATCH_SECINFO.FLAGS.PR is 0) and
(SCRATCH_SECINFO.FLAGS.PENDING is 0) and
(SCRATCH_SECINFO.FLAGS.MODIFIED is 1) )))
THEN #GP(0); FI
(* Check security attributes of the destination EPC page *)
If ( (EPCM(DS:RCX).VALID is 0) or (EPCM(DS:RCX).BLOCKED is not 0) or
((EPCM(DS:RCX).PT is not PT_REG) and (EPCM(DS:RCX).PT is not PT_TCS) and (EPCM(DS:RCX).PT is not PT_TRIM)) or
(EPCM(DS:RCX).ENCLAVESECS ≠ CR_ACTIVE_SECS))
THEN #PF((DS:RCX); FI;
(* Check the destination EPC page for concurrency *)
IF ( EPC page in use )
THEN #GP(0); FI;
(* Re-Check security attributes of the destination EPC page *)
IF ( (EPCM(DS:RCX).VALID is 0) or (EPCM(DS:RCX).ENCLAVESECS ≠ CR_ACTIVE_SECS) )
THEN #PF(DS:RCX); FI;
(* Verify that accept request matches current EPC page settings *)
IF ( (EPCM(DS:RCX).ENCLAVEADDRESS ≠ DS:RCX) or (EPCM(DS:RCX).PENDING ≠ SCRATCH_SECINFO.FLAGS.PENDING) or
(EPCM(DS:RCX).MODIFIED ≠ SCRATCH_SECINFO.FLAGS.MODIFIED) or (EPCM(DS:RCX).R ≠ SCRATCH_SECINFO.FLAGS.R) or
(EPCM(DS:RCX).W ≠ SCRATCH_SECINFO.FLAGS.W) or (EPCM(DS:RCX).X ≠ SCRATCH_SECINFO.FLAGS.X) or
(EPCM(DS:RCX).PT ≠ SCRATCH_SECINFO.FLAGS.PT) )
THEN
RFLAGS.ZF ← 1;
RAX ← SGX_PAGE_ATTRIBUTES_MISMATCH;
GOTO DONE;
FI;
(* Check that all required threads have left enclave *)
IF (Tracking not correct)
THEN
RFLAGS.ZF ← 1;
RAX ← SGX_NOT_TRACKED;
GOTO DONE;
FI;
(* Get pointer to the SECS to which the EPC page belongs *)
TMP_SECS = << Obtain physical address of SECS through EPCM(DS:RCX)>>
(* For TCS pages, perform additional checks *)
IF (SCRATCH_SECINFO.FLAGS.PT = PT_TCS)
IF (DS:RCX.RESERVED ≠ 0) #GP(0); FI;
FI;
(* Check that TCS.FLAGS.DBGOPTIN, TCS stack, and TCS status are correctly initialized *) IF ( ((DS:RCX).FLAGS.DBGOPTIN is not 0) or ((DS:RCX).CSSA ≥ (DS:RCX).NSSA) or ((DS:RCX).AEP is not 0) or ((DS:RCX).STATE is not 0)) THEN #GP(0); FI;
(* Check consistency of FS & GS Limit *)
IF ( (TMP_SECS.ATTRIBUTES.MODE64BIT is 0) and ((DS:RCX.FSLIMIT & FFFH ≠ FFFH) or (DS:RCX.GSLIMIT & FFFH ≠ FFFH)) )
THEN #GP(0); FI;
(* Clear PENDING/MODIFIED flags to mark accept operation complete *)
EPCM(DS:RCX).PENDING ← 0;
EPCM(DS:RCX).MODIFIED ← 0;
EPCM(DS:RCX).PR ← 0;
(* Clear EAX and ZF to indicate successful completion *)
RFLAGS.ZF ← 0;
RAX←0;
DONE:
RFLAGS.CF,PF,AF,OF,SF ← 0;
Sets ZF if page cannot be accepted, otherwise cleared. Clears CF, PF, AF, OF, SF
| #GP(0) | If executed outside an enclave. |
| If a memory operand effective address is outside the DS segment limit. | |
| If a memory operand is not properly aligned. | |
| If a memory operand is locked. | |
| #PF(error | code) If a page fault occurs in accessing memory operands. |
| If a memory operand is not an EPC page. | |
| If EPC page has incorrect page type or security attributes. |
| #GP(0) | If executed outside an enclave. |
| If a memory operand is non-canonical form. | |
| If a memory operand is not properly aligned. | |
| If a memory operand is locked. | |
| #PF(error | code) If a page fault occurs in accessing memory operands. |
| If a memory operand is not an EPC page. | |
| If EPC page has incorrect page type or security attributes. |


| DC(1) | User Commands | DC(1) |
Tiny RPN calculator. Operations: +, -, *, /, %, ~, ^, |, p - print top of the stack without popping f - print entire stack k - pop the value and set the precision i - pop the value and set input radix o - pop the value and set output radix Examples: dc -e'2 2 + p' -> 4, dc -e'8 8 * 2 2 + / p' -> 16
| April 2020 | Fidelix 1.0 |


Conference List
Here is the main conferences within recommender system and some categories which I think is interesting:
- KDD the community for data mining, data science and analytics.
- ICDM draws researchers and application developers from a wide range of data mining related areas such as statistics, machine learning, pattern recognition, databases and data warehousing, data visualization, knowledge-based systems, and high performance computing.
- AAAI promotes research in, and responsible use of, artificial intelligence.
- WWW provides the world a premier forum for discussion and debate about the evolution of the Web, the standardization of its associated technologies, and the impact of those technologies on society and culture.
- NIPS has a responsibility to provide an inclusive and welcoming environment for everyone in the fields of AI and machine learning.
- ICML is the leading international machine learning conference and is supported by the International Machine Learning Society (IMLS).
- CIKM provides an international forum for presentation and discussion of research on information and knowledge management, as well as recent advances on data and knowledge bases.
- SIGIR is the Association for Computing Machinery’s Special Interest Group on Information Retrieval. Since 1963, we have promoted research, development and education in the area of search and other information access technologies.
- Recsys is the most famous conference in recommender system.