This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object RationalGroup extends Group[(Int, Int)] { | |
| val zero = (0, 0) | |
| def plus(x: (Int, Int), y: (Int, Int)): (Int, Int) = (x, y) match { | |
| case ((x1, x2), (y1, y2)) => (x1*y2 + x2*y1, x2*y2) | |
| } | |
| def inverse(x: (Int, Int)) = (-x._1, x._2) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import annotation.implicitNotFound | |
| @implicitNotFound("No member of type class Group found for type ${T}") | |
| trait Group[T] { | |
| def zero: T | |
| def plus(x: T, y: T): T | |
| def inverse(x: T): T | |
| def minus(x: T, y: T): T = plus(x, inverse(y)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| var Name = React.createClass({ | |
| getInitialState: function() { | |
| return { value: "" }; | |
| }, | |
| onValueChange: function(event) { | |
| this.setState({ value: event.target.value }); | |
| }, | |
| render: function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| var Name = React.createClass({ | |
| getInitialState: function() { | |
| return { value: "", errors: [], sync: true }; | |
| }, | |
| validate: function(value) { | |
| var validations = [ | |
| v => v.length < 15 || "Your name is too long!", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default function (React) { | |
| var Name = React.createClass({ | |
| getInitialState: function() { /* No Change */ }, | |
| validate: function(value) { /* No Change */ }, | |
| syncToServer: function() { /* No Change */ }, | |
| onValueChange: function(value) { /* No Change */ }, | |
| render: function() { | |
| var { value, errors, sync } = this.state | |
| var RenderView = this.props.view; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default function (React) { | |
| var Name = React.createClass({ | |
| getInitialState: function() { /* No Change */ }, | |
| validate: function(value) { /* No Change */ }, | |
| syncToServer: function() { /* No Change */ }, | |
| onValueChange: function(value) { /* No Change */ }, | |
| render: function() { | |
| var { value, errors, sync } = this.state | |
| var RenderView = this.props.view; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| var NameViewWeb = ({ value, errors, sync, onValueChange }) => { | |
| var errorNodes = errors.map((err, i) => <div key={i}>{err}</div>); | |
| var syncNode = value && <div>{ sync ? "Synced!" : "Syncing..." }</div>; | |
| return (<div> | |
| <label>Name : </label> | |
| <input type="text" value={value} | |
| onChange={e => onValueChange(e.target.value)} /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import ReactDOM from 'react-dom'; | |
| import NameBase from '../shared/Name'; | |
| import NameViewWeb from './NameViewWeb'; | |
| var Name = NameBase(React); | |
| ReactDOM.render( | |
| <Name view={NameViewWeb} />, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react-native'; | |
| var { | |
| View, | |
| Text, | |
| TextInput, | |
| StyleSheet | |
| } = React; | |
| var NameViewNative = React.createClass({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log('x'); |