Skip to content

Instantly share code, notes, and snippets.

View mneedham's full-sized avatar

Mark Needham mneedham

View GitHub Profile
(defmacro a [person]
`(println "hello" ~person))
user=> (macroexpand-1 '(a "mark"))
(clojure.core/println "hello" "mark")
user=> (a "mark")
hello mark
nil
(defmacro a [person]
`(println "hello" ~person))
user=> (macroexpand-1 '(a anybody))
(clojure.core/println "hello" anybody)
user=> (a "anybody")
hello anybody
nil
(defmacro a [person]
(list println "hello" person))
(defmacro a [person]
'(println "hello" person))
(defn say-hello [person] println "hello" person)
(say-hello "Mark")
-> "Mark"
If I put the brackets in then it'll work fine:
(defn say-hello [person] (println "hello" person))
#light
open System
open System.IO
open System.Text.RegularExpressions
let (|File|Directory|) path = if(Directory.Exists path) then Directory(path) else File(path)
let getFileSystemEntries path = Directory.GetFileSystemEntries path |> Array.to_list
let files path =
let rec inner fileSystemEntries files =
def parse
expr = assert_expr :expr
assert_done
expr
end
def assert_expr(name)
(e = send(name)) && (return e)
raise Sass::SyntaxError.new("Expected expression, was #{@lexer.done? ? 'end of text' : "#{@lexer.peek.type} token"}.")
require 'sass/script/lexer'
module Sass
module Script
# The parser for SassScript.
# It parses a string of code into a tree of {Script::Node}s.
class Parser
# @param str [String, StringScanner] The source text to parse
# @param line [Fixnum] The line on which the SassScript appears.
# Used for error reporting
let rec nums = seq { yield 1
for n in nums do yield n+1 }
How does this work?
When we call 'nums' on line 2 it recurses to the function again which means that on the first recursion the only value
in 'nums' is 1? So then we add the value 2 into the sequence presumably. Which means that if we recurse again then 1
and 2 will both be in the sequence. Not convinced I understand this very well...
let rec nums = seq { yield 1
printfn "yield 1"
for n in nums do
printfn "(for)yield %d" (n)
yield n+1 }
> Seq.take 5 nums |> Seq.iter (printfn "%d");;
1
yield 1
(for)yield 1
[Test]
public void ShouldNotCopyTheId()
{
Mapper.Reset();
Mapper.CreateMap<Mark, Mark>();
Mapper.CreateMap<Foo, Foo>().ForMember(foo => foo.Id, opts => opts.Ignore());
var mark = new Mark { Foos = new List<Foo> { new Foo { Id = Guid.NewGuid()}}};
var newMark = Mapper.Map<Mark, Mark>(mark);