numeric-ranges

Interpreting Number Ranges in Python

我们两清 提交于 2019-12-23 14:59:24
问题 In a Pylons webapp, I need to take a string such as "<3, 45, 46, 48-51, 77" and create a list of ints (which are actually IDs of objects) to search on. Any suggestions on ways to do this? I'm new to Python, and I haven't found anything out there that helps with this kind of thing. The list would be: [1, 2, 3, 45, 46, 48, 49, 50, 51, 77] 回答1: Use parseIntSet from here I also like the pyparsing implementation in the comments at the end. The parseIntSet has been modified here to handle "<3"-type

Adding Numeric Range Filtering to ActiveAdmin

为君一笑 提交于 2019-12-13 15:33:34
问题 Greetings and Happy Holidays 2015 -- I tried to add numeric range filtering per the excellent blog post by Boris Stall. I'm running: Rails 4.2.4 Ruby 2.2.3 ActiveAdmin 1.0.0pre2 I keep running into this error: Unable to find input class NumericRangeInput Here is my config/initializers/active_admin/filter_numeric_range_input.rb module ActiveAdmin module Inputs class FilterNumericRangeInput < ::Formtastic::Inputs::StringInput # Add filter module wrapper include ActiveAdmin::Inputs::Filters:

Managing ranges with LINQ challenge

故事扮演 提交于 2019-12-13 03:41:23
问题 Given the following numbers (representing days of week): 1,2,3,4,5,6,7 . Here are some combination examples and their desired output: 1,2,3,5,6,7 -> 1-3,5-7 1,3,5,7 -> 1,3,5,7 1,2,5,6 -> 1,2,5,6 1,2,3,6,7 -> 1-3,6,7 The idea is that 3 or more consecutive days become a range while single or non-following days are rendered separately (or is it nicer to make range starting from 2). I don't know where to start should I write a complicated if ed function or this can be done with one of the LINQ