Tag:proc

  • Analysis of / proc virtual file system in Linux system

    Time:2020-6-29

    The Linux kernel provides a mechanism to access the internal data structure of the kernel and change the kernel settings at runtime through the / proc file system. Although the basic concept of the / proc file system of Linux system on various hardware platforms is the same, this paper only discusses the Linux / […]

  • Using block, proc and lambda to implement closure in Ruby

    Time:2020-3-20

    Closure refers to the free code that is not bound to any object. The code in the closure is not related to any object and global variables, but only to the context in which the code is executed. Today, let’s take a brief look at the closure implementation in ruby. The closure implementations in ruby […]

  • A summary of the differences among block, proc and lambda in Ruby

    Time:2019-11-27

    In the rule engine, Ruby’s closures are frequently used, and there are block, proc and lambda, which are confusing. In order to understand the code in depth, I have learned the similarities and differences of ruby closures again, especially the usage of block, proc and lambda. This week’s notes will share my experience with you. […]

  • Two Differences between Proc and Lambda in Ruby

    Time:2019-8-21

    1. In proc and lambda, return keyword has different meanings:In proc, return simply means return from this lambda.In lambda, return is not returned from proc, but from the scope in which proc is defined. Copy codeThe code is as follows: def one_methodWhen P = Proc. new {return 10} # calls this block, it returns 10 […]

  • Explain the code block object Proc in Ruby

    Time:2019-4-26

    Proc object Proc is an object converted from blocks. There are four ways to create a Proc: Sample code The law of the people inc = Proc.new { | x | x + 1} inc.call(2) #=> 3 The law of two inc = lambda {| x | x + 1 } inc.call(2) #=> 3 The […]

  • Analysis of the Use of Proc Class in Ruby and Proc Class Method Proc.new

    Time:2019-4-25

    Proc is a process object obtained by objectifying blocks and their context (scope of local variables and stack framework). You can use Proc as an anonymous function, but it does not import the scope of local variables (dynamic local variables can be used as Proc local variables). In the next example, because Proc keeps the […]

  • How to Simply Simulate Lambda Calculus with Ruby

    Time:2019-3-13

    Preface Recently, I read a book called The Essence of Computing, which mainly talks about the knowledge of low-level computing. It can be said that it has refreshed my three views, and today I see that when I can use Y combination to achieve recursion, my world outlook basically collapsed. So I will write an […]